1 // 2 // Copyright 2017 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // PBufferSurfaceCGL.h: an implementation of PBuffers created from IOSurfaces using 8 // EGL_ANGLE_iosurface_client_buffer 9 10 #ifndef LIBANGLE_RENDERER_GL_CGL_IOSURFACESURFACECGL_H_ 11 #define LIBANGLE_RENDERER_GL_CGL_IOSURFACESURFACECGL_H_ 12 13 #include "libANGLE/renderer/gl/SurfaceGL.h" 14 #include "libANGLE/renderer/gl/cgl/DisplayCGL.h" 15 16 struct __IOSurface; 17 typedef __IOSurface *IOSurfaceRef; 18 19 namespace egl 20 { 21 class AttributeMap; 22 } // namespace egl 23 24 namespace rx 25 { 26 27 class DisplayCGL; 28 class FunctionsGL; 29 class StateManagerGL; 30 31 class IOSurfaceSurfaceCGL : public SurfaceGL 32 { 33 public: 34 IOSurfaceSurfaceCGL(const egl::SurfaceState &state, 35 CGLContextObj cglContext, 36 EGLClientBuffer buffer, 37 const egl::AttributeMap &attribs); 38 ~IOSurfaceSurfaceCGL() override; 39 40 egl::Error initialize(const egl::Display *display) override; 41 egl::Error makeCurrent(const gl::Context *context) override; 42 egl::Error unMakeCurrent(const gl::Context *context) override; 43 44 egl::Error swap(const gl::Context *context) override; 45 egl::Error postSubBuffer(const gl::Context *context, 46 EGLint x, 47 EGLint y, 48 EGLint width, 49 EGLint height) override; 50 egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override; 51 egl::Error bindTexImage(const gl::Context *context, 52 gl::Texture *texture, 53 EGLint buffer) override; 54 egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override; 55 void setSwapInterval(EGLint interval) override; 56 57 EGLint getWidth() const override; 58 EGLint getHeight() const override; 59 60 EGLint isPostSubBufferSupported() const override; 61 EGLint getSwapBehavior() const override; 62 63 static bool validateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs); 64 FramebufferImpl *createDefaultFramebuffer(const gl::Context *context, 65 const gl::FramebufferState &state) override; 66 67 bool hasEmulatedAlphaChannel() const override; 68 69 private: 70 angle::Result initializeAlphaChannel(const gl::Context *context, GLuint texture); 71 72 CGLContextObj mCGLContext; 73 IOSurfaceRef mIOSurface; 74 int mWidth; 75 int mHeight; 76 int mPlane; 77 int mFormatIndex; 78 79 bool mAlphaInitialized; 80 }; 81 82 } // namespace rx 83 84 #endif // LIBANGLE_RENDERER_GL_CGL_IOSURFACESURFACECGL_H_ 85