• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2020 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 #ifndef LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
8 #define LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
9 
10 #include "libANGLE/renderer/gl/SurfaceGL.h"
11 #include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
12 
13 #include <IOSurface/IOSurfaceRef.h>
14 
15 namespace egl
16 {
17 class AttributeMap;
18 }  // namespace egl
19 
20 namespace rx
21 {
22 
23 class DisplayEAGL;
24 class FunctionsGL;
25 class StateManagerGL;
26 
27 class IOSurfaceSurfaceEAGL : public SurfaceGL
28 {
29   public:
30     IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
31                          RendererGL *renderer,
32                          EAGLContextObj cglContext,
33                          EGLClientBuffer buffer,
34                          const egl::AttributeMap &attribs);
35     ~IOSurfaceSurfaceEAGL() override;
36 
37     egl::Error initialize(const egl::Display *display) override;
38     egl::Error makeCurrent(const gl::Context *context) override;
39     egl::Error unMakeCurrent(const gl::Context *context) override;
40 
41     egl::Error swap(const gl::Context *context) override;
42     egl::Error postSubBuffer(const gl::Context *context,
43                              EGLint x,
44                              EGLint y,
45                              EGLint width,
46                              EGLint height) override;
47     egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
48     egl::Error bindTexImage(const gl::Context *context,
49                             gl::Texture *texture,
50                             EGLint buffer) override;
51     egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
52     void setSwapInterval(EGLint interval) override;
53 
54     EGLint getWidth() const override;
55     EGLint getHeight() const override;
56 
57     EGLint isPostSubBufferSupported() const override;
58     EGLint getSwapBehavior() const override;
59 
60     static bool validateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs);
61 
62     bool hasEmulatedAlphaChannel() const override;
63 
64     egl::Error attachToFramebuffer(const gl::Context *context,
65                                    gl::Framebuffer *framebuffer) override;
66     egl::Error detachFromFramebuffer(const gl::Context *context,
67                                      gl::Framebuffer *framebuffer) override;
68 
69   private:
70     angle::Result initializeAlphaChannel(const gl::Context *context, GLuint texture);
71 
72 #if ANGLE_PLATFORM_IOS_FAMILY_SIMULATOR
73     IOSurfaceLockOptions getIOSurfaceLockOptions() const;
74 #endif
75     // TODO(geofflang): Don't store these, they are potentially specific to a single GL context.
76     // http://anglebug.com/2464
77     const FunctionsGL *mFunctions;
78     StateManagerGL *mStateManager;
79 
80     EAGLContextObj mEAGLContext;
81     IOSurfaceRef mIOSurface;
82     GLuint mFramebufferID;
83     GLuint mTextureID;
84     int mWidth;
85     int mHeight;
86     int mPlane;
87     int mFormatIndex;
88     int mRowStrideInPixels;
89 
90     bool mAlphaInitialized;
91 #if ANGLE_PLATFORM_IOS_FAMILY_SIMULATOR
92     GLuint mBoundTextureID;
93     bool mUploadFromIOSurface;
94     bool mReadbackToIOSurface;
95 #endif
96 };
97 
98 }  // namespace rx
99 
100 #endif  // LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
101