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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
14 #include "ui/gl/gl_export.h" | 14 #include "ui/gl/gl_export.h" |
| 15 #include "ui/gl/gl_implementation.h" |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 | 18 |
18 class GLContext; | 19 class GLContext; |
19 class VSyncProvider; | 20 class VSyncProvider; |
20 | 21 |
21 // Encapsulates a surface that can be rendered to with GL, hiding platform | 22 // Encapsulates a surface that can be rendered to with GL, hiding platform |
22 // specific management. | 23 // specific management. |
23 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { | 24 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { |
24 public: | 25 public: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 63 |
63 bool HasExtension(const char* name); | 64 bool HasExtension(const char* name); |
64 | 65 |
65 // Returns the internal frame buffer object name if the surface is backed by | 66 // Returns the internal frame buffer object name if the surface is backed by |
66 // FBO. Otherwise returns 0. | 67 // FBO. Otherwise returns 0. |
67 virtual unsigned int GetBackingFrameBufferObject(); | 68 virtual unsigned int GetBackingFrameBufferObject(); |
68 | 69 |
69 // Copy part of the backbuffer to the frontbuffer. | 70 // Copy part of the backbuffer to the frontbuffer. |
70 virtual bool PostSubBuffer(int x, int y, int width, int height); | 71 virtual bool PostSubBuffer(int x, int y, int width, int height); |
71 | 72 |
| 73 // Initialize GL bindings. |
72 static bool InitializeOneOff(); | 74 static bool InitializeOneOff(); |
73 | 75 |
| 76 // Unit tests should call these instead of InitializeOneOff() to set up |
| 77 // GL bindings appropriate for tests. |
| 78 static void InitializeOneOffForTests(); |
| 79 static void InitializeOneOffWithMockBindingsForTests(); |
| 80 static void InitializeDynamicMockBindingsForTests(GLContext* context); |
| 81 |
74 // Called after a context is made current with this surface. Returns false | 82 // Called after a context is made current with this surface. Returns false |
75 // on error. | 83 // on error. |
76 virtual bool OnMakeCurrent(GLContext* context); | 84 virtual bool OnMakeCurrent(GLContext* context); |
77 | 85 |
78 // Used for explicit buffer management. | 86 // Used for explicit buffer management. |
79 virtual bool SetBackbufferAllocation(bool allocated); | 87 virtual bool SetBackbufferAllocation(bool allocated); |
80 virtual void SetFrontbufferAllocation(bool allocated); | 88 virtual void SetFrontbufferAllocation(bool allocated); |
81 | 89 |
82 // Get a handle used to share the surface with another process. Returns null | 90 // Get a handle used to share the surface with another process. Returns null |
83 // if this is not possible. | 91 // if this is not possible. |
(...skipping 18 matching lines...) Expand all Loading... |
102 gfx::AcceleratedWidget window); | 110 gfx::AcceleratedWidget window); |
103 | 111 |
104 // Create a GL surface used for offscreen rendering. | 112 // Create a GL surface used for offscreen rendering. |
105 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 113 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
106 const gfx::Size& size); | 114 const gfx::Size& size); |
107 | 115 |
108 static GLSurface* GetCurrent(); | 116 static GLSurface* GetCurrent(); |
109 | 117 |
110 protected: | 118 protected: |
111 virtual ~GLSurface(); | 119 virtual ~GLSurface(); |
| 120 static bool InitializeOneOffImplementation(GLImplementation impl, |
| 121 bool fallback_to_osmesa, |
| 122 bool gpu_service_logging, |
| 123 bool disable_gl_drawing); |
112 static bool InitializeOneOffInternal(); | 124 static bool InitializeOneOffInternal(); |
113 static void SetCurrent(GLSurface* surface); | 125 static void SetCurrent(GLSurface* surface); |
114 | 126 |
115 static bool ExtensionsContain(const char* extensions, const char* name); | 127 static bool ExtensionsContain(const char* extensions, const char* name); |
116 | 128 |
117 private: | 129 private: |
118 friend class base::RefCounted<GLSurface>; | 130 friend class base::RefCounted<GLSurface>; |
119 friend class GLContext; | 131 friend class GLContext; |
120 | 132 |
121 DISALLOW_COPY_AND_ASSIGN(GLSurface); | 133 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 167 |
156 private: | 168 private: |
157 scoped_refptr<GLSurface> surface_; | 169 scoped_refptr<GLSurface> surface_; |
158 | 170 |
159 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 171 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
160 }; | 172 }; |
161 | 173 |
162 } // namespace gfx | 174 } // namespace gfx |
163 | 175 |
164 #endif // UI_GL_GL_SURFACE_H_ | 176 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |