| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GL_GL_SURFACE_EGL_H_ | 5 #ifndef UI_GL_GL_SURFACE_EGL_H_ |
| 6 #define UI_GL_GL_SURFACE_EGL_H_ | 6 #define UI_GL_GL_SURFACE_EGL_H_ |
| 7 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Interface for EGL surface. | 70 // Interface for EGL surface. |
| 71 class GL_EXPORT GLSurfaceEGL : public GLSurface { | 71 class GL_EXPORT GLSurfaceEGL : public GLSurface { |
| 72 public: | 72 public: |
| 73 GLSurfaceEGL(); | 73 GLSurfaceEGL(); |
| 74 | 74 |
| 75 // Implement GLSurface. | 75 // Implement GLSurface. |
| 76 EGLDisplay GetDisplay() override; | 76 EGLDisplay GetDisplay() override; |
| 77 EGLConfig GetConfig() override; | 77 EGLConfig GetConfig() override; |
| 78 GLSurface::Format GetFormat() override; | 78 GLSurfaceFormat GetFormat() override; |
| 79 | 79 |
| 80 static bool InitializeOneOff(EGLNativeDisplayType native_display); | 80 static bool InitializeOneOff(EGLNativeDisplayType native_display); |
| 81 static void ShutdownOneOff(); | 81 static void ShutdownOneOff(); |
| 82 static EGLDisplay GetHardwareDisplay(); | 82 static EGLDisplay GetHardwareDisplay(); |
| 83 static EGLDisplay InitializeDisplay(EGLNativeDisplayType native_display); | 83 static EGLDisplay InitializeDisplay(EGLNativeDisplayType native_display); |
| 84 static EGLNativeDisplayType GetNativeDisplay(); | 84 static EGLNativeDisplayType GetNativeDisplay(); |
| 85 | 85 |
| 86 // These aren't particularly tied to surfaces, but since we already | 86 // These aren't particularly tied to surfaces, but since we already |
| 87 // have the static InitializeOneOff here, it's easiest to reuse its | 87 // have the static InitializeOneOff here, it's easiest to reuse its |
| 88 // initialization guards. | 88 // initialization guards. |
| 89 static const char* GetEGLExtensions(); | 89 static const char* GetEGLExtensions(); |
| 90 static bool HasEGLExtension(const char* name); | 90 static bool HasEGLExtension(const char* name); |
| 91 static bool IsCreateContextRobustnessSupported(); | 91 static bool IsCreateContextRobustnessSupported(); |
| 92 static bool IsCreateContextBindGeneratesResourceSupported(); | 92 static bool IsCreateContextBindGeneratesResourceSupported(); |
| 93 static bool IsCreateContextWebGLCompatabilitySupported(); | 93 static bool IsCreateContextWebGLCompatabilitySupported(); |
| 94 static bool IsEGLSurfacelessContextSupported(); | 94 static bool IsEGLSurfacelessContextSupported(); |
| 95 static bool IsDirectCompositionSupported(); | 95 static bool IsDirectCompositionSupported(); |
| 96 | 96 |
| 97 protected: | 97 protected: |
| 98 ~GLSurfaceEGL() override; | 98 ~GLSurfaceEGL() override; |
| 99 | 99 |
| 100 EGLConfig config_ = nullptr; | 100 EGLConfig config_ = nullptr; |
| 101 GLSurface::Format format_ = GLSurface::SURFACE_DEFAULT; | 101 GLSurfaceFormat format_; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); | 104 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); |
| 105 static bool initialized_; | 105 static bool initialized_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 // Encapsulates an EGL surface bound to a view. | 108 // Encapsulates an EGL surface bound to a view. |
| 109 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { | 109 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { |
| 110 public: | 110 public: |
| 111 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); | 111 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); |
| 112 | 112 |
| 113 // Implement GLSurface. | 113 // Implement GLSurface. |
| 114 using GLSurfaceEGL::Initialize; | 114 using GLSurfaceEGL::Initialize; |
| 115 bool Initialize(GLSurface::Format format) override; | 115 bool Initialize(GLSurfaceFormat format) override; |
| 116 void Destroy() override; | 116 void Destroy() override; |
| 117 bool Resize(const gfx::Size& size, | 117 bool Resize(const gfx::Size& size, |
| 118 float scale_factor, | 118 float scale_factor, |
| 119 bool has_alpha) override; | 119 bool has_alpha) override; |
| 120 bool Recreate() override; | 120 bool Recreate() override; |
| 121 bool IsOffscreen() override; | 121 bool IsOffscreen() override; |
| 122 gfx::SwapResult SwapBuffers() override; | 122 gfx::SwapResult SwapBuffers() override; |
| 123 gfx::Size GetSize() override; | 123 gfx::Size GetSize() override; |
| 124 EGLSurface GetHandle() override; | 124 EGLSurface GetHandle() override; |
| 125 bool SupportsSwapBuffersWithDamage() override; | 125 bool SupportsSwapBuffersWithDamage() override; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); | 185 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 // Encapsulates a pbuffer EGL surface. | 188 // Encapsulates a pbuffer EGL surface. |
| 189 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { | 189 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { |
| 190 public: | 190 public: |
| 191 explicit PbufferGLSurfaceEGL(const gfx::Size& size); | 191 explicit PbufferGLSurfaceEGL(const gfx::Size& size); |
| 192 | 192 |
| 193 // Implement GLSurface. | 193 // Implement GLSurface. |
| 194 bool Initialize() override; | 194 bool Initialize(GLSurfaceFormat format) override; |
| 195 bool Initialize(GLSurface::Format format) override; | |
| 196 void Destroy() override; | 195 void Destroy() override; |
| 197 bool IsOffscreen() override; | 196 bool IsOffscreen() override; |
| 198 gfx::SwapResult SwapBuffers() override; | 197 gfx::SwapResult SwapBuffers() override; |
| 199 gfx::Size GetSize() override; | 198 gfx::Size GetSize() override; |
| 200 bool Resize(const gfx::Size& size, | 199 bool Resize(const gfx::Size& size, |
| 201 float scale_factor, | 200 float scale_factor, |
| 202 bool has_alpha) override; | 201 bool has_alpha) override; |
| 203 EGLSurface GetHandle() override; | 202 EGLSurface GetHandle() override; |
| 204 void* GetShareHandle() override; | 203 void* GetShareHandle() override; |
| 205 | 204 |
| 206 protected: | 205 protected: |
| 207 ~PbufferGLSurfaceEGL() override; | 206 ~PbufferGLSurfaceEGL() override; |
| 208 | 207 |
| 209 private: | 208 private: |
| 210 gfx::Size size_; | 209 gfx::Size size_; |
| 211 EGLSurface surface_; | 210 EGLSurface surface_; |
| 212 | 211 |
| 213 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); | 212 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); |
| 214 }; | 213 }; |
| 215 | 214 |
| 216 // SurfacelessEGL is used as Offscreen surface when platform supports | 215 // SurfacelessEGL is used as Offscreen surface when platform supports |
| 217 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the | 216 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the |
| 218 // need to create a dummy EGLsurface in case we render to client API targets. | 217 // need to create a dummy EGLsurface in case we render to client API targets. |
| 219 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { | 218 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { |
| 220 public: | 219 public: |
| 221 explicit SurfacelessEGL(const gfx::Size& size); | 220 explicit SurfacelessEGL(const gfx::Size& size); |
| 222 | 221 |
| 223 // Implement GLSurface. | 222 // Implement GLSurface. |
| 224 bool Initialize() override; | 223 bool Initialize(GLSurfaceFormat format) override; |
| 225 bool Initialize(GLSurface::Format format) override; | |
| 226 void Destroy() override; | 224 void Destroy() override; |
| 227 bool IsOffscreen() override; | 225 bool IsOffscreen() override; |
| 228 bool IsSurfaceless() const override; | 226 bool IsSurfaceless() const override; |
| 229 gfx::SwapResult SwapBuffers() override; | 227 gfx::SwapResult SwapBuffers() override; |
| 230 gfx::Size GetSize() override; | 228 gfx::Size GetSize() override; |
| 231 bool Resize(const gfx::Size& size, | 229 bool Resize(const gfx::Size& size, |
| 232 float scale_factor, | 230 float scale_factor, |
| 233 bool has_alpha) override; | 231 bool has_alpha) override; |
| 234 EGLSurface GetHandle() override; | 232 EGLSurface GetHandle() override; |
| 235 void* GetShareHandle() override; | 233 void* GetShareHandle() override; |
| 236 | 234 |
| 237 protected: | 235 protected: |
| 238 ~SurfacelessEGL() override; | 236 ~SurfacelessEGL() override; |
| 239 | 237 |
| 240 private: | 238 private: |
| 241 gfx::Size size_; | 239 gfx::Size size_; |
| 242 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); | 240 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); |
| 243 }; | 241 }; |
| 244 | 242 |
| 245 } // namespace gl | 243 } // namespace gl |
| 246 | 244 |
| 247 #endif // UI_GL_GL_SURFACE_EGL_H_ | 245 #endif // UI_GL_GL_SURFACE_EGL_H_ |
| OLD | NEW |