Welcome to mirror list, hosted at ThFree Co, Russian Federation.

metal_texture.hpp « metal « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2771f23340c91dbbaf872fc4060edc8bc7c8336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#import <MetalKit/MetalKit.h>

#include "drape/hw_texture.hpp"
#include "drape/pointers.hpp"

namespace dp
{
namespace metal
{
class MetalTextureAllocator : public HWTextureAllocator
{
public:
  drape_ptr<HWTexture> CreateTexture(ref_ptr<dp::GraphicsContext> context) override;
  void Flush() override {}
};

class MetalTexture : public HWTexture
{
  using Base = HWTexture;
public:
  explicit MetalTexture(ref_ptr<MetalTextureAllocator> allocator);

  void Create(ref_ptr<dp::GraphicsContext> context, Params const & params, ref_ptr<void> data) override;
  void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data) override;
  void Bind() const override {}
  void SetFilter(TextureFilter filter) override;
  bool Validate() const override;
  
  id<MTLTexture> GetTexture() const { return m_texture; }
  
private:
  ref_ptr<MetalTextureAllocator> m_allocator;
  id<MTLTexture> m_texture;
  bool m_isMutable = false;
};
}  // namespace metal
}  // namespace dp