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 GLContextReal; | |
20 class VirtualGLApi; | |
19 class VSyncProvider; | 21 class VSyncProvider; |
20 | 22 |
21 // Encapsulates a surface that can be rendered to with GL, hiding platform | 23 // Encapsulates a surface that can be rendered to with GL, hiding platform |
22 // specific management. | 24 // specific management. |
23 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { | 25 class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { |
24 public: | 26 public: |
25 GLSurface(); | 27 GLSurface(); |
26 | 28 |
27 // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the | 29 // (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 | 30 // 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. | 102 // Create a GL surface that renders directly to a view. |
101 static scoped_refptr<GLSurface> CreateViewGLSurface( | 103 static scoped_refptr<GLSurface> CreateViewGLSurface( |
102 bool software, | 104 bool software, |
103 gfx::AcceleratedWidget window); | 105 gfx::AcceleratedWidget window); |
104 | 106 |
105 // Create a GL surface used for offscreen rendering. | 107 // Create a GL surface used for offscreen rendering. |
106 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 108 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
107 bool software, | 109 bool software, |
108 const gfx::Size& size); | 110 const gfx::Size& size); |
109 | 111 |
112 // Returns the last GLSurface made current, virtual or real. | |
110 static GLSurface* GetCurrent(); | 113 static GLSurface* GetCurrent(); |
111 | 114 |
112 protected: | 115 protected: |
113 virtual ~GLSurface(); | 116 virtual ~GLSurface(); |
114 static bool InitializeOneOffInternal(); | 117 static bool InitializeOneOffInternal(); |
115 static void SetCurrent(GLSurface* surface); | 118 static void SetCurrent(GLSurface* surface); |
119 static void SetRealCurrent(GLSurface* surface); | |
116 | 120 |
117 static bool ExtensionsContain(const char* extensions, const char* name); | 121 static bool ExtensionsContain(const char* extensions, const char* name); |
118 | 122 |
123 // Returns the last GLSurface made current with a real (non-virtual) context. | |
124 static GLSurface* GetRealCurrent(); | |
no sievers
2013/06/05 16:43:37
...and do we then really need to track this separa
jonathan.backer
2013/06/05 20:40:11
Nope. I think that the DCHECK in gl_gl_api_impleme
| |
125 | |
119 private: | 126 private: |
120 friend class base::RefCounted<GLSurface>; | 127 friend class base::RefCounted<GLSurface>; |
121 friend class GLContext; | 128 friend class GLContext; |
122 | 129 |
130 // For GetRealCurrent. | |
131 friend class VirtualGLApi; | |
132 | |
133 // For SetRealCurrent. | |
134 friend class GLContextReal; | |
135 | |
123 DISALLOW_COPY_AND_ASSIGN(GLSurface); | 136 DISALLOW_COPY_AND_ASSIGN(GLSurface); |
124 }; | 137 }; |
125 | 138 |
126 // Implementation of GLSurface that forwards all calls through to another | 139 // Implementation of GLSurface that forwards all calls through to another |
127 // GLSurface. | 140 // GLSurface. |
128 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 141 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
129 public: | 142 public: |
130 explicit GLSurfaceAdapter(GLSurface* surface); | 143 explicit GLSurfaceAdapter(GLSurface* surface); |
131 | 144 |
132 virtual bool Initialize() OVERRIDE; | 145 virtual bool Initialize() OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... | |
157 | 170 |
158 private: | 171 private: |
159 scoped_refptr<GLSurface> surface_; | 172 scoped_refptr<GLSurface> surface_; |
160 | 173 |
161 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 174 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
162 }; | 175 }; |
163 | 176 |
164 } // namespace gfx | 177 } // namespace gfx |
165 | 178 |
166 #endif // UI_GL_GL_SURFACE_H_ | 179 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |