| 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 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/gfx/vsync_provider.h" | 13 #include "ui/gfx/vsync_provider.h" |
| 14 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
| 15 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 // Get default EGL display for GLSurfaceEGL (differs by platform). | 19 // Get default EGL display for GLSurfaceEGL (differs by platform). |
| 20 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); | 20 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); |
| 21 | 21 |
| 22 // Interface for EGL surface. | 22 // Interface for EGL surface. |
| 23 class GL_EXPORT GLSurfaceEGL : public GLSurface { | 23 class GL_EXPORT GLSurfaceEGL : public GLSurface { |
| 24 public: | 24 public: |
| 25 GLSurfaceEGL(); | 25 explicit GLSurfaceEGL( |
| 26 const gfx::SurfaceConfiguration requested_configuration); |
| 26 | 27 |
| 27 // Implement GLSurface. | 28 // Implement GLSurface. |
| 28 void DestroyAndTerminateDisplay() override; | 29 void DestroyAndTerminateDisplay() override; |
| 29 EGLDisplay GetDisplay() override; | 30 EGLDisplay GetDisplay() override; |
| 30 | 31 |
| 31 static bool InitializeOneOff(); | 32 static bool InitializeOneOff(); |
| 32 static EGLDisplay GetHardwareDisplay(); | 33 static EGLDisplay GetHardwareDisplay(); |
| 33 static EGLNativeDisplayType GetNativeDisplay(); | 34 static EGLNativeDisplayType GetNativeDisplay(); |
| 34 | 35 |
| 35 // These aren't particularly tied to surfaces, but since we already | 36 // These aren't particularly tied to surfaces, but since we already |
| 36 // have the static InitializeOneOff here, it's easiest to reuse its | 37 // have the static InitializeOneOff here, it's easiest to reuse its |
| 37 // initialization guards. | 38 // initialization guards. |
| 38 static const char* GetEGLExtensions(); | 39 static const char* GetEGLExtensions(); |
| 39 static bool HasEGLExtension(const char* name); | 40 static bool HasEGLExtension(const char* name); |
| 40 static bool IsCreateContextRobustnessSupported(); | 41 static bool IsCreateContextRobustnessSupported(); |
| 41 static bool IsEGLSurfacelessContextSupported(); | 42 static bool IsEGLSurfacelessContextSupported(); |
| 42 | 43 |
| 43 protected: | 44 protected: |
| 44 ~GLSurfaceEGL() override; | 45 ~GLSurfaceEGL() override; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); | 48 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 // Encapsulates an EGL surface bound to a view. | 51 // Encapsulates an EGL surface bound to a view. |
| 51 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { | 52 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { |
| 52 public: | 53 public: |
| 53 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); | 54 NativeViewGLSurfaceEGL( |
| 55 EGLNativeWindowType window, |
| 56 const gfx::SurfaceConfiguration requested_configuration); |
| 54 | 57 |
| 55 // Implement GLSurface. | 58 // Implement GLSurface. |
| 56 EGLConfig GetConfig() override; | 59 EGLConfig GetConfig() override; |
| 57 bool Initialize() override; | 60 bool Initialize() override; |
| 58 void Destroy() override; | 61 void Destroy() override; |
| 59 bool Resize(const gfx::Size& size) override; | 62 bool Resize(const gfx::Size& size) override; |
| 60 bool Recreate() override; | 63 bool Recreate() override; |
| 61 bool IsOffscreen() override; | 64 bool IsOffscreen() override; |
| 62 bool SwapBuffers() override; | 65 bool SwapBuffers() override; |
| 63 gfx::Size GetSize() override; | 66 gfx::Size GetSize() override; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 scoped_ptr<VSyncProvider> vsync_provider_; | 89 scoped_ptr<VSyncProvider> vsync_provider_; |
| 87 | 90 |
| 88 int swap_interval_; | 91 int swap_interval_; |
| 89 | 92 |
| 90 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); | 93 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); |
| 91 }; | 94 }; |
| 92 | 95 |
| 93 // Encapsulates a pbuffer EGL surface. | 96 // Encapsulates a pbuffer EGL surface. |
| 94 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { | 97 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { |
| 95 public: | 98 public: |
| 96 explicit PbufferGLSurfaceEGL(const gfx::Size& size); | 99 PbufferGLSurfaceEGL(const gfx::Size& size, |
| 100 const gfx::SurfaceConfiguration requested_configuration); |
| 97 | 101 |
| 98 // Implement GLSurface. | 102 // Implement GLSurface. |
| 99 EGLConfig GetConfig() override; | 103 EGLConfig GetConfig() override; |
| 100 bool Initialize() override; | 104 bool Initialize() override; |
| 101 void Destroy() override; | 105 void Destroy() override; |
| 102 bool IsOffscreen() override; | 106 bool IsOffscreen() override; |
| 103 bool SwapBuffers() override; | 107 bool SwapBuffers() override; |
| 104 gfx::Size GetSize() override; | 108 gfx::Size GetSize() override; |
| 105 bool Resize(const gfx::Size& size) override; | 109 bool Resize(const gfx::Size& size) override; |
| 106 EGLSurface GetHandle() override; | 110 EGLSurface GetHandle() override; |
| 107 void* GetShareHandle() override; | 111 void* GetShareHandle() override; |
| 108 | 112 |
| 109 protected: | 113 protected: |
| 110 ~PbufferGLSurfaceEGL() override; | 114 ~PbufferGLSurfaceEGL() override; |
| 111 | 115 |
| 112 private: | 116 private: |
| 113 gfx::Size size_; | 117 gfx::Size size_; |
| 114 EGLSurface surface_; | 118 EGLSurface surface_; |
| 119 EGLConfig config_; |
| 115 | 120 |
| 116 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); | 121 DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 // SurfacelessEGL is used as Offscreen surface when platform supports | 124 // SurfacelessEGL is used as Offscreen surface when platform supports |
| 120 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the | 125 // KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the |
| 121 // need to create a dummy EGLsurface in case we render to client API targets. | 126 // need to create a dummy EGLsurface in case we render to client API targets. |
| 122 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { | 127 class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { |
| 123 public: | 128 public: |
| 124 explicit SurfacelessEGL(const gfx::Size& size); | 129 SurfacelessEGL(const gfx::Size& size, |
| 130 SurfaceConfiguration requested_configuration); |
| 125 | 131 |
| 126 // Implement GLSurface. | 132 // Implement GLSurface. |
| 127 EGLConfig GetConfig() override; | 133 EGLConfig GetConfig() override; |
| 128 bool Initialize() override; | 134 bool Initialize() override; |
| 129 void Destroy() override; | 135 void Destroy() override; |
| 130 bool IsOffscreen() override; | 136 bool IsOffscreen() override; |
| 131 bool IsSurfaceless() const override; | 137 bool IsSurfaceless() const override; |
| 132 bool SwapBuffers() override; | 138 bool SwapBuffers() override; |
| 133 gfx::Size GetSize() override; | 139 gfx::Size GetSize() override; |
| 134 bool Resize(const gfx::Size& size) override; | 140 bool Resize(const gfx::Size& size) override; |
| 135 EGLSurface GetHandle() override; | 141 EGLSurface GetHandle() override; |
| 136 void* GetShareHandle() override; | 142 void* GetShareHandle() override; |
| 137 | 143 |
| 138 protected: | 144 protected: |
| 139 ~SurfacelessEGL() override; | 145 ~SurfacelessEGL() override; |
| 140 | 146 |
| 141 private: | 147 private: |
| 142 gfx::Size size_; | 148 gfx::Size size_; |
| 143 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); | 149 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); |
| 144 }; | 150 }; |
| 145 | 151 |
| 146 } // namespace gfx | 152 } // namespace gfx |
| 147 | 153 |
| 148 #endif // UI_GL_GL_SURFACE_EGL_H_ | 154 #endif // UI_GL_GL_SURFACE_EGL_H_ |
| OLD | NEW |