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_CONTEXT_H_ | 5 #ifndef UI_GL_GL_CONTEXT_H_ |
6 #define UI_GL_GL_CONTEXT_H_ | 6 #define UI_GL_GL_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/gl/gl_share_group.h" | 13 #include "ui/gl/gl_share_group.h" |
14 #include "ui/gl/gl_state_restorer.h" | 14 #include "ui/gl/gl_state_restorer.h" |
15 #include "ui/gl/gpu_preference.h" | 15 #include "ui/gl/gpu_preference.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 | 18 |
19 class GLSurface; | 19 class GLSurface; |
20 class VirtualGLApi; | 20 class VirtualGLApi; |
21 struct GLVersionInfo; | |
21 | 22 |
22 // Encapsulates an OpenGL context, hiding platform specific management. | 23 // Encapsulates an OpenGL context, hiding platform specific management. |
23 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { | 24 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { |
24 public: | 25 public: |
25 explicit GLContext(GLShareGroup* share_group); | 26 explicit GLContext(GLShareGroup* share_group); |
26 | 27 |
27 // Initializes the GL context to be compatible with the given surface. The GL | 28 // Initializes the GL context to be compatible with the given surface. The GL |
28 // context can be made with other surface's of the same type. The compatible | 29 // context can be made with other surface's of the same type. The compatible |
29 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It | 30 // surface is only needed for certain platforms like WGL, OSMesa and GLX. It |
30 // should be specific for all platforms though. | 31 // should be specific for all platforms though. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 virtual void SetSafeToForceGpuSwitch(); | 70 virtual void SetSafeToForceGpuSwitch(); |
70 | 71 |
71 // Indicate that the real context switches should unbind the FBO first | 72 // Indicate that the real context switches should unbind the FBO first |
72 // (For an Android work-around only). | 73 // (For an Android work-around only). |
73 virtual void SetUnbindFboOnMakeCurrent(); | 74 virtual void SetUnbindFboOnMakeCurrent(); |
74 | 75 |
75 // Returns whether the current context supports the named extension. The | 76 // Returns whether the current context supports the named extension. The |
76 // context must be current. | 77 // context must be current. |
77 bool HasExtension(const char* name); | 78 bool HasExtension(const char* name); |
78 | 79 |
80 // Returns version info of the underlying GL context. The context must be | |
81 // current. | |
82 const GLVersionInfo* GetVersionInfo(); | |
83 | |
79 GLShareGroup* share_group(); | 84 GLShareGroup* share_group(); |
80 | 85 |
81 // Create a GL context that is compatible with the given surface. | 86 // Create a GL context that is compatible with the given surface. |
82 // |share_group|, if non-NULL, is a group of contexts which the | 87 // |share_group|, if non-NULL, is a group of contexts which the |
83 // internally created OpenGL context shares textures and other resources. | 88 // internally created OpenGL context shares textures and other resources. |
84 static scoped_refptr<GLContext> CreateGLContext( | 89 static scoped_refptr<GLContext> CreateGLContext( |
85 GLShareGroup* share_group, | 90 GLShareGroup* share_group, |
86 GLSurface* compatible_surface, | 91 GLSurface* compatible_surface, |
87 GpuPreference gpu_preference); | 92 GpuPreference gpu_preference); |
88 | 93 |
(...skipping 14 matching lines...) Expand all Loading... | |
103 // being released or destroyed. | 108 // being released or destroyed. |
104 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 109 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
105 | 110 |
106 protected: | 111 protected: |
107 virtual ~GLContext(); | 112 virtual ~GLContext(); |
108 | 113 |
109 // Sets the GL api to the real hardware API (vs the VirtualAPI) | 114 // Sets the GL api to the real hardware API (vs the VirtualAPI) |
110 static void SetRealGLApi(); | 115 static void SetRealGLApi(); |
111 virtual void SetCurrent(GLSurface* surface); | 116 virtual void SetCurrent(GLSurface* surface); |
112 | 117 |
113 // Initialize function pointers to extension functions in the GL | 118 // Initialize function pointers to functions where the bound version depends |
114 // implementation. Should be called immediately after this context is made | 119 // on GL version or supported extensions. Should be called immediately after |
115 // current. | 120 // this context is made current. |
116 bool InitializeExtensionBindings(); | 121 bool InitializeDynamicBindings(); |
no sievers
2013/12/05 20:51:57
Is a call to this missing in GLContextNSView::Make
no sievers
2013/12/05 21:07:17
I also suggest that we initialize the dynamic bind
oetuaho
2013/12/09 17:17:07
Yeah, after seeing the gpu_main.cc code it looks l
| |
117 | 122 |
118 // Returns the last real (non-virtual) GLContext made current. | 123 // Returns the last real (non-virtual) GLContext made current. |
119 static GLContext* GetRealCurrent(); | 124 static GLContext* GetRealCurrent(); |
120 | 125 |
126 // Returns the GL version string. The context must be current. | |
127 virtual std::string GetGLVersion(); | |
128 | |
121 private: | 129 private: |
122 friend class base::RefCounted<GLContext>; | 130 friend class base::RefCounted<GLContext>; |
123 | 131 |
124 // For GetRealCurrent. | 132 // For GetRealCurrent. |
125 friend class VirtualGLApi; | 133 friend class VirtualGLApi; |
126 | 134 |
127 scoped_refptr<GLShareGroup> share_group_; | 135 scoped_refptr<GLShareGroup> share_group_; |
128 scoped_ptr<VirtualGLApi> virtual_gl_api_; | 136 scoped_ptr<VirtualGLApi> virtual_gl_api_; |
129 scoped_ptr<GLStateRestorer> state_restorer_; | 137 scoped_ptr<GLStateRestorer> state_restorer_; |
138 scoped_ptr<GLVersionInfo> version_info_; | |
130 | 139 |
131 DISALLOW_COPY_AND_ASSIGN(GLContext); | 140 DISALLOW_COPY_AND_ASSIGN(GLContext); |
132 }; | 141 }; |
133 | 142 |
134 class GL_EXPORT GLContextReal : public GLContext { | 143 class GL_EXPORT GLContextReal : public GLContext { |
135 public: | 144 public: |
136 explicit GLContextReal(GLShareGroup* share_group); | 145 explicit GLContextReal(GLShareGroup* share_group); |
137 | 146 |
138 protected: | 147 protected: |
139 virtual ~GLContextReal(); | 148 virtual ~GLContextReal(); |
140 | 149 |
141 virtual void SetCurrent(GLSurface* surface) OVERRIDE; | 150 virtual void SetCurrent(GLSurface* surface) OVERRIDE; |
142 | 151 |
143 private: | 152 private: |
144 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | 153 DISALLOW_COPY_AND_ASSIGN(GLContextReal); |
145 }; | 154 }; |
146 | 155 |
147 } // namespace gfx | 156 } // namespace gfx |
148 | 157 |
149 #endif // UI_GL_GL_CONTEXT_H_ | 158 #endif // UI_GL_GL_CONTEXT_H_ |
OLD | NEW |