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

hw_texture_ios.hpp « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f93ca15f9f12e14cc52dc5e9b93a385486bd5a80 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once

#import "hw_texture.hpp"

#ifndef OMIM_OS_IPHONE
  #error Only for ios
#endif

#import <CoreVideo/CVPixelBuffer.h>
#import <CoreVideo/CVOpenGLESTexture.h>
#import <CoreVideo/CVOpenGLESTextureCache.h>

namespace dp
{

class HWTextureAllocatorApple : public HWTextureAllocator
{
public:
  HWTextureAllocatorApple();
  ~HWTextureAllocatorApple();

  CVPixelBufferRef CVCreatePixelBuffer(uint32_t width, uint32_t height, int format);
  void CVDestroyPixelBuffer(CVPixelBufferRef buffer);

  CVOpenGLESTextureRef CVCreateTexture(CVPixelBufferRef buffer, uint32_t width, uint32_t height,
                                   glConst layout, glConst pixelType);
  void CVDestroyTexture(CVOpenGLESTextureRef texture);

  void RiseFlushFlag();

  drape_ptr<HWTexture> CreateTexture() override;
  void Flush() override;

private:
  bool m_needFlush;
  CVOpenGLESTextureCacheRef m_textureCache;
};

class HWTextureApple : public HWTexture
{
  using TBase = HWTexture;

public:
  HWTextureApple(ref_ptr<HWTextureAllocatorApple> allocator);
  ~HWTextureApple();

  void Create(Params const & params, ref_ptr<void> data);
  void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data);

private:
  void Lock();
  void Unlock();

private:
  CVPixelBufferRef m_directBuffer;
  CVOpenGLESTextureRef m_texture;
  ref_ptr<HWTextureAllocatorApple> m_allocator;

  void * m_directPointer;
};

}