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_H_ | 5 #ifndef UI_GL_GL_SURFACE_H_ |
6 #define UI_GL_GL_SURFACE_H_ | 6 #define UI_GL_GL_SURFACE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/rect_f.h" | 14 #include "ui/gfx/geometry/rect_f.h" |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/overlay_transform.h" | 17 #include "ui/gfx/overlay_transform.h" |
18 #include "ui/gl/gl_export.h" | 18 #include "ui/gl/gl_export.h" |
19 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 | 22 |
23 class GLContext; | 23 class GLContext; |
24 class GLImage; | 24 class GLImage; |
25 class VSyncProvider; | 25 class VSyncProvider; |
26 | 26 |
27 struct SurfaceConfiguration { | |
28 SurfaceConfiguration() | |
29 : red_bits(8), | |
30 green_bits(8), | |
31 blue_bits(8), | |
32 alpha_bits(8), | |
33 depth_bits(0), | |
34 stencil_bits(0) {} | |
35 | |
36 uint8_t red_bits; | |
37 uint8_t green_bits; | |
38 uint8_t blue_bits; | |
39 uint8_t alpha_bits; | |
40 uint8_t depth_bits; | |
41 uint8_t stencil_bits; | |
42 }; | |
43 | |
27 // Encapsulates a surface that can be rendered to with GL, hiding platform | 44 // Encapsulates a surface that can be rendered to with GL, hiding platform |
28 // specific management. | 45 // specific management. |
29 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { | 46 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { |
30 public: | 47 public: |
31 GLSurface(); | 48 explicit GLSurface(SurfaceConfiguration requested_configuration); |
32 | 49 |
33 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the | 50 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the |
34 // EGL surface associated to be recreated without destroying the associated | 51 // EGL surface associated to be recreated without destroying the associated |
35 // context. The implementation of this function for other GLSurface derived | 52 // context. The implementation of this function for other GLSurface derived |
36 // classes is in a pending changelist. | 53 // classes is in a pending changelist. |
37 virtual bool Initialize(); | 54 virtual bool Initialize(); |
38 | 55 |
39 // Destroys the surface. | 56 // Destroys the surface. |
40 virtual void Destroy() = 0; | 57 virtual void Destroy() = 0; |
41 | 58 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 virtual bool ScheduleOverlayPlane(int z_order, | 164 virtual bool ScheduleOverlayPlane(int z_order, |
148 OverlayTransform transform, | 165 OverlayTransform transform, |
149 GLImage* image, | 166 GLImage* image, |
150 const Rect& bounds_rect, | 167 const Rect& bounds_rect, |
151 const RectF& crop_rect); | 168 const RectF& crop_rect); |
152 | 169 |
153 virtual bool IsSurfaceless() const; | 170 virtual bool IsSurfaceless() const; |
154 | 171 |
155 // Create a GL surface that renders directly to a view. | 172 // Create a GL surface that renders directly to a view. |
156 static scoped_refptr<GLSurface> CreateViewGLSurface( | 173 static scoped_refptr<GLSurface> CreateViewGLSurface( |
157 gfx::AcceleratedWidget window); | 174 gfx::AcceleratedWidget window, |
175 gfx::SurfaceConfiguration requested_configuration); | |
158 | 176 |
159 #if defined(USE_OZONE) | 177 #if defined(USE_OZONE) |
160 // Create a GL surface that renders directly into a window with surfaceless | 178 // Create a GL surface that renders directly into a window with surfaceless |
161 // semantics - there is no default framebuffer and the primary surface must | 179 // semantics - there is no default framebuffer and the primary surface must |
162 // be presented as an overlay. If surfaceless mode is not supported or | 180 // be presented as an overlay. If surfaceless mode is not supported or |
163 // enabled it will return a null pointer. | 181 // enabled it will return a null pointer. |
164 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( | 182 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( |
165 gfx::AcceleratedWidget window); | 183 gfx::AcceleratedWidget window, |
184 gfx::SurfaceConfiguration requested_configuration); | |
166 #endif // defined(USE_OZONE) | 185 #endif // defined(USE_OZONE) |
167 | 186 |
168 // Create a GL surface used for offscreen rendering. | 187 // Create a GL surface used for offscreen rendering. |
169 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 188 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
170 const gfx::Size& size); | 189 const gfx::Size& size, |
190 gfx::SurfaceConfiguration requested_configuration); | |
171 | 191 |
172 static GLSurface* GetCurrent(); | 192 static GLSurface* GetCurrent(); |
173 | 193 |
174 // Called when the swap interval for the associated context changes. | 194 // Called when the swap interval for the associated context changes. |
175 virtual void OnSetSwapInterval(int interval); | 195 virtual void OnSetSwapInterval(int interval); |
176 | 196 |
197 SurfaceConfiguration GetSurfaceConfiguration() { | |
198 return surface_configuration_; | |
199 }; | |
viettrungluu
2015/06/09 00:48:15
no semicolon
iansf
2015/06/09 01:52:05
Done.
| |
200 | |
177 protected: | 201 protected: |
178 virtual ~GLSurface(); | 202 virtual ~GLSurface(); |
179 static bool InitializeOneOffImplementation(GLImplementation impl, | 203 static bool InitializeOneOffImplementation(GLImplementation impl, |
180 bool fallback_to_osmesa, | 204 bool fallback_to_osmesa, |
181 bool gpu_service_logging, | 205 bool gpu_service_logging, |
182 bool disable_gl_drawing); | 206 bool disable_gl_drawing); |
183 static bool InitializeOneOffInternal(); | 207 static bool InitializeOneOffInternal(); |
184 static void SetCurrent(GLSurface* surface); | 208 static void SetCurrent(GLSurface* surface); |
185 | 209 |
186 static bool ExtensionsContain(const char* extensions, const char* name); | 210 static bool ExtensionsContain(const char* extensions, const char* name); |
187 | 211 |
188 private: | 212 private: |
213 SurfaceConfiguration surface_configuration_; | |
viettrungluu
2015/06/09 00:48:15
nit: I believe members should be declared after fr
iansf
2015/06/09 01:52:05
Done.
| |
189 friend class base::RefCounted<GLSurface>; | 214 friend class base::RefCounted<GLSurface>; |
190 friend class GLContext; | 215 friend class GLContext; |
191 | 216 |
192 DISALLOW_COPY_AND_ASSIGN(GLSurface); | 217 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
193 }; | 218 }; |
194 | 219 |
195 // Implementation of GLSurface that forwards all calls through to another | 220 // Implementation of GLSurface that forwards all calls through to another |
196 // GLSurface. | 221 // GLSurface. |
197 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 222 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
198 public: | 223 public: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 | 263 |
239 private: | 264 private: |
240 scoped_refptr<GLSurface> surface_; | 265 scoped_refptr<GLSurface> surface_; |
241 | 266 |
242 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 267 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
243 }; | 268 }; |
244 | 269 |
245 } // namespace gfx | 270 } // namespace gfx |
246 | 271 |
247 #endif // UI_GL_GL_SURFACE_H_ | 272 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |