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 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 class GLContext; | 18 class GLContext; |
| 19 class VirtualGLApi; |
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: |
25 GLSurface(); | 26 GLSurface(); |
26 | 27 |
27 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the | 28 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the |
28 // EGL surface associated to be recreated without destroying the associated | 29 // EGL surface associated to be recreated without destroying the associated |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Create a GL surface that renders directly to a view. | 101 // Create a GL surface that renders directly to a view. |
101 static scoped_refptr<GLSurface> CreateViewGLSurface( | 102 static scoped_refptr<GLSurface> CreateViewGLSurface( |
102 bool software, | 103 bool software, |
103 gfx::AcceleratedWidget window); | 104 gfx::AcceleratedWidget window); |
104 | 105 |
105 // Create a GL surface used for offscreen rendering. | 106 // Create a GL surface used for offscreen rendering. |
106 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 107 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
107 bool software, | 108 bool software, |
108 const gfx::Size& size); | 109 const gfx::Size& size); |
109 | 110 |
| 111 // Returns the last GLSurface made current, virtual or real. |
110 static GLSurface* GetCurrent(); | 112 static GLSurface* GetCurrent(); |
111 | 113 |
112 protected: | 114 protected: |
113 virtual ~GLSurface(); | 115 virtual ~GLSurface(); |
114 static bool InitializeOneOffInternal(); | 116 static bool InitializeOneOffInternal(); |
115 static void SetCurrent(GLSurface* surface); | 117 static void SetCurrent(GLSurface* surface); |
| 118 static void SetRealCurrent(GLSurface* surface); |
116 | 119 |
117 static bool ExtensionsContain(const char* extensions, const char* name); | 120 static bool ExtensionsContain(const char* extensions, const char* name); |
118 | 121 |
| 122 // Returns the last GLSurface made current with a real (non-virtual) context. |
| 123 static GLSurface* GetRealCurrent(); |
| 124 |
119 private: | 125 private: |
120 friend class base::RefCounted<GLSurface>; | 126 friend class base::RefCounted<GLSurface>; |
121 friend class GLContext; | 127 friend class GLContext; |
122 | 128 |
| 129 // For GetRealCurrent. |
| 130 friend class VirtualGLApi; |
| 131 |
123 DISALLOW_COPY_AND_ASSIGN(GLSurface); | 132 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
124 }; | 133 }; |
125 | 134 |
126 // Implementation of GLSurface that forwards all calls through to another | 135 // Implementation of GLSurface that forwards all calls through to another |
127 // GLSurface. | 136 // GLSurface. |
128 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 137 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
129 public: | 138 public: |
130 explicit GLSurfaceAdapter(GLSurface* surface); | 139 explicit GLSurfaceAdapter(GLSurface* surface); |
131 | 140 |
132 virtual bool Initialize() OVERRIDE; | 141 virtual bool Initialize() OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... |
157 | 166 |
158 private: | 167 private: |
159 scoped_refptr<GLSurface> surface_; | 168 scoped_refptr<GLSurface> surface_; |
160 | 169 |
161 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 170 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
162 }; | 171 }; |
163 | 172 |
164 } // namespace gfx | 173 } // namespace gfx |
165 | 174 |
166 #endif // UI_GL_GL_SURFACE_H_ | 175 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |