Chromium Code Reviews| 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 |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "ui/events/platform/platform_event_dispatcher.h" | |
| 17 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 18 #include "ui/gfx/vsync_provider.h" | 19 #include "ui/gfx/vsync_provider.h" |
| 19 #include "ui/gl/gl_bindings.h" | 20 #include "ui/gl/gl_bindings.h" |
| 20 #include "ui/gl/gl_surface.h" | 21 #include "ui/gl/gl_surface.h" |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 | 24 |
| 24 // Get default EGL display for GLSurfaceEGL (differs by platform). | 25 // Get default EGL display for GLSurfaceEGL (differs by platform). |
| 25 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); | 26 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay(); |
| 26 | 27 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 static bool IsEGLSurfacelessContextSupported(); | 65 static bool IsEGLSurfacelessContextSupported(); |
| 65 | 66 |
| 66 protected: | 67 protected: |
| 67 ~GLSurfaceEGL() override; | 68 ~GLSurfaceEGL() override; |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); | 71 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 // Encapsulates an EGL surface bound to a view. | 74 // Encapsulates an EGL surface bound to a view. |
| 74 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { | 75 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL, |
| 76 public ui::PlatformEventDispatcher { | |
| 75 public: | 77 public: |
| 76 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); | 78 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); |
| 77 | 79 |
| 78 // Implement GLSurface. | 80 // Implement GLSurface. |
| 79 EGLConfig GetConfig() override; | 81 EGLConfig GetConfig() override; |
| 80 bool Initialize() override; | 82 bool Initialize() override; |
| 81 void Destroy() override; | 83 void Destroy() override; |
| 82 bool Resize(const gfx::Size& size, float scale_factor) override; | 84 bool Resize(const gfx::Size& size, float scale_factor) override; |
| 83 bool Recreate() override; | 85 bool Recreate() override; |
| 84 bool IsOffscreen() override; | 86 bool IsOffscreen() override; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 96 | 98 |
| 97 // Create a NativeViewGLSurfaceEGL with an externally provided VSyncProvider. | 99 // Create a NativeViewGLSurfaceEGL with an externally provided VSyncProvider. |
| 98 // Takes ownership of the VSyncProvider. | 100 // Takes ownership of the VSyncProvider. |
| 99 virtual bool Initialize(scoped_ptr<VSyncProvider> sync_provider); | 101 virtual bool Initialize(scoped_ptr<VSyncProvider> sync_provider); |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 ~NativeViewGLSurfaceEGL() override; | 104 ~NativeViewGLSurfaceEGL() override; |
| 103 | 105 |
| 104 EGLNativeWindowType window_; | 106 EGLNativeWindowType window_; |
| 105 | 107 |
| 108 #if defined(USE_X11) | |
| 109 EGLNativeWindowType parent_window_; | |
| 110 #endif | |
| 111 | |
| 106 void OnSetSwapInterval(int interval) override; | 112 void OnSetSwapInterval(int interval) override; |
| 107 | 113 |
| 108 private: | 114 private: |
| 109 EGLSurface surface_; | 115 EGLSurface surface_; |
| 110 bool supports_post_sub_buffer_; | 116 bool supports_post_sub_buffer_; |
| 111 EGLConfig config_; | 117 EGLConfig config_; |
| 112 gfx::Size size_; | 118 gfx::Size size_; |
| 113 | 119 |
| 114 scoped_ptr<VSyncProvider> vsync_provider_; | 120 scoped_ptr<VSyncProvider> vsync_provider_; |
| 115 | 121 |
| 116 int swap_interval_; | 122 int swap_interval_; |
| 117 | 123 |
| 118 #if defined(OS_WIN) | 124 #if defined(OS_WIN) |
| 119 bool vsync_override_; | 125 bool vsync_override_; |
| 120 | 126 |
| 121 unsigned int swap_generation_; | 127 unsigned int swap_generation_; |
| 122 static unsigned int current_swap_generation_; | 128 static unsigned int current_swap_generation_; |
| 123 static unsigned int swaps_this_generation_; | 129 static unsigned int swaps_this_generation_; |
| 124 static unsigned int last_multiswap_generation_; | 130 static unsigned int last_multiswap_generation_; |
| 125 #endif | 131 #endif |
| 126 | 132 |
| 127 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); | 133 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); |
| 134 | |
| 135 private: | |
| 136 // PlatformEventDispatcher implementation. | |
| 137 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | |
| 138 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | |
|
piman
2015/11/30 22:07:44
nit: keep these in the existing private: section.
| |
| 128 }; | 139 }; |
| 129 | 140 |
| 130 // Encapsulates a pbuffer EGL surface. | 141 // Encapsulates a pbuffer EGL surface. |
| 131 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { | 142 class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { |
| 132 public: | 143 public: |
| 133 explicit PbufferGLSurfaceEGL(const gfx::Size& size); | 144 explicit PbufferGLSurfaceEGL(const gfx::Size& size); |
| 134 | 145 |
| 135 // Implement GLSurface. | 146 // Implement GLSurface. |
| 136 EGLConfig GetConfig() override; | 147 EGLConfig GetConfig() override; |
| 137 bool Initialize() override; | 148 bool Initialize() override; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 void* GetShareHandle() override; | 184 void* GetShareHandle() override; |
| 174 | 185 |
| 175 protected: | 186 protected: |
| 176 ~SurfacelessEGL() override; | 187 ~SurfacelessEGL() override; |
| 177 | 188 |
| 178 private: | 189 private: |
| 179 gfx::Size size_; | 190 gfx::Size size_; |
| 180 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); | 191 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); |
| 181 }; | 192 }; |
| 182 | 193 |
| 194 #if !defined(USE_X11) | |
| 195 // PlatformEventDispatcher implementation. | |
| 196 bool NativeViewGLSurfaceEGL::CanDispatchEvent(const ui::PlatformEvent&) { | |
| 197 return false; | |
| 198 } | |
| 199 uint32_t NativeViewGLSurfaceEGL::DispatchEvent(const ui::PlatformEvent&) { | |
| 200 return ui::POST_DISPATCH_NONE; | |
| 201 } | |
| 202 #endif | |
|
piman
2015/11/30 22:07:44
nit: move these to the .cc file.
Another option i
| |
| 203 | |
| 183 } // namespace gfx | 204 } // namespace gfx |
| 184 | 205 |
| 185 #endif // UI_GL_GL_SURFACE_EGL_H_ | 206 #endif // UI_GL_GL_SURFACE_EGL_H_ |
| OLD | NEW |