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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 class VSyncProvider; | 31 class VSyncProvider; |
32 | 32 |
33 // Encapsulates a surface that can be rendered to with GL, hiding platform | 33 // Encapsulates a surface that can be rendered to with GL, hiding platform |
34 // specific management. | 34 // specific management. |
35 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { | 35 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { |
36 public: | 36 public: |
37 GLSurface(); | 37 GLSurface(); |
38 | 38 |
39 // Minimum bit depth of surface. | 39 // Minimum bit depth of surface. |
40 enum Format { | 40 enum Format { |
41 SURFACE_ARGB8888 = 1, // 32 bits | 41 SURFACE_ARGB8888, |
42 SURFACE_RGB565 = 2, // 16 bits | 42 SURFACE_RGB565, |
| 43 SURFACE_OSMESA_BGRA, |
| 44 SURFACE_OSMESA_RGBA, |
43 SURFACE_DEFAULT = SURFACE_ARGB8888 | 45 SURFACE_DEFAULT = SURFACE_ARGB8888 |
44 }; | 46 }; |
45 | 47 |
46 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the | 48 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the |
47 // EGL surface associated to be recreated without destroying the associated | 49 // EGL surface associated to be recreated without destroying the associated |
48 // context. The implementation of this function for other GLSurface derived | 50 // context. The implementation of this function for other GLSurface derived |
49 // classes is in a pending changelist. | 51 // classes is in a pending changelist. |
50 virtual bool Initialize(); | 52 virtual bool Initialize(); |
51 virtual bool Initialize(GLSurface::Format format); | 53 virtual bool Initialize(GLSurface::Format format); |
52 | 54 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 virtual void* GetShareHandle(); | 147 virtual void* GetShareHandle(); |
146 | 148 |
147 // Get the platform specific display on which this surface resides, if | 149 // Get the platform specific display on which this surface resides, if |
148 // available. | 150 // available. |
149 virtual void* GetDisplay(); | 151 virtual void* GetDisplay(); |
150 | 152 |
151 // Get the platfrom specific configuration for this surface, if available. | 153 // Get the platfrom specific configuration for this surface, if available. |
152 virtual void* GetConfig(); | 154 virtual void* GetConfig(); |
153 | 155 |
154 // Get the GL pixel format of the surface, if available. | 156 // Get the GL pixel format of the surface, if available. |
155 virtual unsigned GetFormat(); | 157 virtual GLSurface::Format GetFormat(); |
156 | 158 |
157 // Get access to a helper providing time of recent refresh and period | 159 // Get access to a helper providing time of recent refresh and period |
158 // of screen refresh. If unavailable, returns NULL. | 160 // of screen refresh. If unavailable, returns NULL. |
159 virtual VSyncProvider* GetVSyncProvider(); | 161 virtual VSyncProvider* GetVSyncProvider(); |
160 | 162 |
161 // Schedule an overlay plane to be shown at swap time, or on the next | 163 // Schedule an overlay plane to be shown at swap time, or on the next |
162 // CommitOverlayPlanes call. | 164 // CommitOverlayPlanes call. |
163 // |z_order| specifies the stacking order of the plane relative to the | 165 // |z_order| specifies the stacking order of the plane relative to the |
164 // main framebuffer located at index 0. For the case where there is no | 166 // main framebuffer located at index 0. For the case where there is no |
165 // main framebuffer, overlays may be scheduled at 0, taking its place. | 167 // main framebuffer, overlays may be scheduled at 0, taking its place. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Create a GL surface that renders directly into a window with surfaceless | 206 // Create a GL surface that renders directly into a window with surfaceless |
205 // semantics - there is no default framebuffer and the primary surface must | 207 // semantics - there is no default framebuffer and the primary surface must |
206 // be presented as an overlay. If surfaceless mode is not supported or | 208 // be presented as an overlay. If surfaceless mode is not supported or |
207 // enabled it will return a null pointer. | 209 // enabled it will return a null pointer. |
208 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( | 210 static scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( |
209 gfx::AcceleratedWidget window); | 211 gfx::AcceleratedWidget window); |
210 #endif // defined(USE_OZONE) | 212 #endif // defined(USE_OZONE) |
211 | 213 |
212 // Create a GL surface used for offscreen rendering. | 214 // Create a GL surface used for offscreen rendering. |
213 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 215 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
214 const gfx::Size& size) { | 216 const gfx::Size& size); |
215 return CreateOffscreenGLSurface(size, SURFACE_DEFAULT); | |
216 } | |
217 | |
218 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | |
219 const gfx::Size& size, GLSurface::Format format); | |
220 | 217 |
221 static GLSurface* GetCurrent(); | 218 static GLSurface* GetCurrent(); |
222 | 219 |
223 // Called when the swap interval for the associated context changes. | 220 // Called when the swap interval for the associated context changes. |
224 virtual void OnSetSwapInterval(int interval); | 221 virtual void OnSetSwapInterval(int interval); |
225 | 222 |
226 protected: | 223 protected: |
227 virtual ~GLSurface(); | 224 virtual ~GLSurface(); |
228 static bool InitializeOneOffImplementation(GLImplementation impl, | 225 static bool InitializeOneOffImplementation(GLImplementation impl, |
229 bool fallback_to_osmesa, | 226 bool fallback_to_osmesa, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 bool SupportsAsyncSwap() override; | 269 bool SupportsAsyncSwap() override; |
273 gfx::Size GetSize() override; | 270 gfx::Size GetSize() override; |
274 void* GetHandle() override; | 271 void* GetHandle() override; |
275 unsigned int GetBackingFrameBufferObject() override; | 272 unsigned int GetBackingFrameBufferObject() override; |
276 bool OnMakeCurrent(GLContext* context) override; | 273 bool OnMakeCurrent(GLContext* context) override; |
277 bool SetBackbufferAllocation(bool allocated) override; | 274 bool SetBackbufferAllocation(bool allocated) override; |
278 void SetFrontbufferAllocation(bool allocated) override; | 275 void SetFrontbufferAllocation(bool allocated) override; |
279 void* GetShareHandle() override; | 276 void* GetShareHandle() override; |
280 void* GetDisplay() override; | 277 void* GetDisplay() override; |
281 void* GetConfig() override; | 278 void* GetConfig() override; |
282 unsigned GetFormat() override; | 279 GLSurface::Format GetFormat() override; |
283 VSyncProvider* GetVSyncProvider() override; | 280 VSyncProvider* GetVSyncProvider() override; |
284 bool ScheduleOverlayPlane(int z_order, | 281 bool ScheduleOverlayPlane(int z_order, |
285 OverlayTransform transform, | 282 OverlayTransform transform, |
286 gl::GLImage* image, | 283 gl::GLImage* image, |
287 const Rect& bounds_rect, | 284 const Rect& bounds_rect, |
288 const RectF& crop_rect) override; | 285 const RectF& crop_rect) override; |
289 bool IsSurfaceless() const override; | 286 bool IsSurfaceless() const override; |
290 bool FlipsVertically() const override; | 287 bool FlipsVertically() const override; |
291 bool BuffersFlipped() const override; | 288 bool BuffersFlipped() const override; |
292 | 289 |
293 GLSurface* surface() const { return surface_.get(); } | 290 GLSurface* surface() const { return surface_.get(); } |
294 | 291 |
295 protected: | 292 protected: |
296 ~GLSurfaceAdapter() override; | 293 ~GLSurfaceAdapter() override; |
297 | 294 |
298 private: | 295 private: |
299 scoped_refptr<GLSurface> surface_; | 296 scoped_refptr<GLSurface> surface_; |
300 | 297 |
301 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 298 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
302 }; | 299 }; |
303 | 300 |
304 } // namespace gfx | 301 } // namespace gfx |
305 | 302 |
306 #endif // UI_GL_GL_SURFACE_H_ | 303 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |