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