Caffe2 - C++ API
A deep learning, cross platform ML framework
IOSGLTexture.h
1 
2 #pragma once
3 
4 #include "../core/GLContext.h"
5 #include "../core/GLTexture.h"
6 
7 #import <CoreVideo/CoreVideo.h>
8 
9 class IOSGLTexture : public GLTexture {
10  CVOpenGLESTextureRef textureRef;
11 
12  IOSGLTexture(const Type& type,
13  CVOpenGLESTextureCacheRef textureCache,
14  CVPixelBufferRef sourceImage,
15  GLint _filter = GL_NEAREST,
16  GLint _wrap = GL_CLAMP_TO_EDGE);
17 
18  friend class IOSGLContext;
19 
20  public:
21  const CVPixelBufferRef sourceImage;
22 
23  ~IOSGLTexture() { CFRelease(textureRef); }
24 
25  void map_buffer(std::function<void(void* buffer,
26  size_t width,
27  size_t height,
28  size_t stride,
29  size_t channels,
30  const Type& type)> process) const;
31 
32  virtual void map_read(std::function<void(const void* buffer,
33  size_t width,
34  size_t height,
35  size_t stride,
36  size_t channels,
37  const Type& type)> process) const;
38 
39  virtual void map_load(std::function<void(void* buffer,
40  size_t width,
41  size_t height,
42  size_t stride,
43  size_t channels,
44  const Type& type)> process) const;
45 
46  GLuint name() const { return CVOpenGLESTextureGetName(textureRef); }
47  GLenum target() const { return CVOpenGLESTextureGetTarget(textureRef); };
48  bool flipped() const { return CVOpenGLESTextureIsFlipped(textureRef); };
49 
50  static CVPixelBufferRef createCVPixelBuffer(OSType pixelType, int32_t width, int32_t height);
51 };