| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 GLSurfaceFormat format_; | 81 GLSurfaceFormat format_; |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); | 84 DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); |
| 85 static bool initialized_; | 85 static bool initialized_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // Encapsulates an EGL surface bound to a view. | 88 // Encapsulates an EGL surface bound to a view. |
| 89 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { | 89 class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { |
| 90 public: | 90 public: |
| 91 explicit NativeViewGLSurfaceEGL(EGLNativeWindowType window); | 91 NativeViewGLSurfaceEGL(EGLNativeWindowType window, |
| 92 std::unique_ptr<gfx::VSyncProvider> vsync_provider); |
| 92 | 93 |
| 93 // Implement GLSurface. | 94 // Implement GLSurface. |
| 94 using GLSurfaceEGL::Initialize; | |
| 95 bool Initialize(GLSurfaceFormat format) override; | 95 bool Initialize(GLSurfaceFormat format) override; |
| 96 void Destroy() override; | 96 void Destroy() override; |
| 97 bool Resize(const gfx::Size& size, | 97 bool Resize(const gfx::Size& size, |
| 98 float scale_factor, | 98 float scale_factor, |
| 99 bool has_alpha) override; | 99 bool has_alpha) override; |
| 100 bool Recreate() override; | 100 bool Recreate() override; |
| 101 bool IsOffscreen() override; | 101 bool IsOffscreen() override; |
| 102 gfx::SwapResult SwapBuffers() override; | 102 gfx::SwapResult SwapBuffers() override; |
| 103 gfx::Size GetSize() override; | 103 gfx::Size GetSize() override; |
| 104 EGLSurface GetHandle() override; | 104 EGLSurface GetHandle() override; |
| 105 bool SupportsPostSubBuffer() override; | 105 bool SupportsPostSubBuffer() override; |
| 106 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 106 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 107 bool SupportsCommitOverlayPlanes() override; | 107 bool SupportsCommitOverlayPlanes() override; |
| 108 gfx::SwapResult CommitOverlayPlanes() override; | 108 gfx::SwapResult CommitOverlayPlanes() override; |
| 109 gfx::VSyncProvider* GetVSyncProvider() override; | 109 gfx::VSyncProvider* GetVSyncProvider() override; |
| 110 bool ScheduleOverlayPlane(int z_order, | 110 bool ScheduleOverlayPlane(int z_order, |
| 111 gfx::OverlayTransform transform, | 111 gfx::OverlayTransform transform, |
| 112 GLImage* image, | 112 GLImage* image, |
| 113 const gfx::Rect& bounds_rect, | 113 const gfx::Rect& bounds_rect, |
| 114 const gfx::RectF& crop_rect) override; | 114 const gfx::RectF& crop_rect) override; |
| 115 bool FlipsVertically() const override; | 115 bool FlipsVertically() const override; |
| 116 bool BuffersFlipped() const override; | 116 bool BuffersFlipped() const override; |
| 117 | 117 |
| 118 // Create a NativeViewGLSurfaceEGL with an externally provided | |
| 119 // gfx::VSyncProvider. Takes ownership of the gfx::VSyncProvider. | |
| 120 virtual bool Initialize(std::unique_ptr<gfx::VSyncProvider> sync_provider); | |
| 121 | |
| 122 // Takes care of the platform dependant bits, of any, for creating the window. | 118 // Takes care of the platform dependant bits, of any, for creating the window. |
| 123 virtual bool InitializeNativeWindow(); | 119 virtual bool InitializeNativeWindow(); |
| 124 | 120 |
| 125 protected: | 121 protected: |
| 126 ~NativeViewGLSurfaceEGL() override; | 122 ~NativeViewGLSurfaceEGL() override; |
| 127 | 123 |
| 128 EGLNativeWindowType window_; | 124 EGLNativeWindowType window_; |
| 129 gfx::Size size_; | 125 gfx::Size size_; |
| 130 bool enable_fixed_size_angle_; | 126 bool enable_fixed_size_angle_; |
| 131 | 127 |
| 132 void OnSetSwapInterval(int interval) override; | 128 void OnSetSwapInterval(int interval) override; |
| 133 gfx::SwapResult SwapBuffersWithDamage(const std::vector<int>& rects); | 129 gfx::SwapResult SwapBuffersWithDamage(const std::vector<int>& rects); |
| 134 | 130 |
| 135 private: | 131 private: |
| 136 // Commit the |pending_overlays_| and clear the vector. Returns false if any | 132 // Commit the |pending_overlays_| and clear the vector. Returns false if any |
| 137 // fail to be committed. | 133 // fail to be committed. |
| 138 bool CommitAndClearPendingOverlays(); | 134 bool CommitAndClearPendingOverlays(); |
| 139 void UpdateSwapInterval(); | 135 void UpdateSwapInterval(); |
| 140 | 136 |
| 141 EGLSurface surface_; | 137 EGLSurface surface_; |
| 142 bool supports_post_sub_buffer_; | 138 bool supports_post_sub_buffer_; |
| 143 bool supports_swap_buffer_with_damage_; | 139 bool supports_swap_buffer_with_damage_; |
| 144 bool flips_vertically_; | 140 bool flips_vertically_; |
| 145 | 141 |
| 146 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; | 142 std::unique_ptr<gfx::VSyncProvider> vsync_provider_external_; |
| 143 std::unique_ptr<gfx::VSyncProvider> vsync_provider_internal_; |
| 147 | 144 |
| 148 int swap_interval_; | 145 int swap_interval_; |
| 149 | 146 |
| 150 std::vector<GLSurfaceOverlay> pending_overlays_; | 147 std::vector<GLSurfaceOverlay> pending_overlays_; |
| 151 | 148 |
| 152 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
| 153 bool vsync_override_; | 150 bool vsync_override_; |
| 154 | 151 |
| 155 unsigned int swap_generation_; | 152 unsigned int swap_generation_; |
| 156 static unsigned int current_swap_generation_; | 153 static unsigned int current_swap_generation_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 ~SurfacelessEGL() override; | 209 ~SurfacelessEGL() override; |
| 213 | 210 |
| 214 private: | 211 private: |
| 215 gfx::Size size_; | 212 gfx::Size size_; |
| 216 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); | 213 DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL); |
| 217 }; | 214 }; |
| 218 | 215 |
| 219 } // namespace gl | 216 } // namespace gl |
| 220 | 217 |
| 221 #endif // UI_GL_GL_SURFACE_EGL_H_ | 218 #endif // UI_GL_GL_SURFACE_EGL_H_ |
| OLD | NEW |