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" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // Create a GL context that is compatible with the given surface. | 81 // Create a GL context that is compatible with the given surface. |
82 // |share_group|, if non-NULL, is a group of contexts which the | 82 // |share_group|, if non-NULL, is a group of contexts which the |
83 // internally created OpenGL context shares textures and other resources. | 83 // internally created OpenGL context shares textures and other resources. |
84 static scoped_refptr<GLContext> CreateGLContext( | 84 static scoped_refptr<GLContext> CreateGLContext( |
85 GLShareGroup* share_group, | 85 GLShareGroup* share_group, |
86 GLSurface* compatible_surface, | 86 GLSurface* compatible_surface, |
87 GpuPreference gpu_preference); | 87 GpuPreference gpu_preference); |
88 | 88 |
89 static bool LosesAllContextsOnContextLost(); | 89 static bool LosesAllContextsOnContextLost(); |
90 | 90 |
91 // Returns the last GLContext made current, virtual or real. | |
91 static GLContext* GetCurrent(); | 92 static GLContext* GetCurrent(); |
92 | 93 |
93 virtual bool WasAllocatedUsingRobustnessExtension(); | 94 virtual bool WasAllocatedUsingRobustnessExtension(); |
94 | 95 |
95 // Use this context for virtualization. | 96 // Use this context for virtualization. |
96 void SetupForVirtualization(); | 97 void SetupForVirtualization(); |
97 | 98 |
98 // Make this context current when used for context virtualization. | 99 // Make this context current when used for context virtualization. |
99 bool MakeVirtuallyCurrent(GLContext* virtual_context, GLSurface* surface); | 100 bool MakeVirtuallyCurrent(GLContext* virtual_context, GLSurface* surface); |
100 | 101 |
101 // Notify this context that |virtual_context|, that was using us, is | 102 // Notify this context that |virtual_context|, that was using us, is |
102 // being released or destroyed. | 103 // being released or destroyed. |
103 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 104 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
104 | 105 |
105 protected: | 106 protected: |
106 virtual ~GLContext(); | 107 virtual ~GLContext(); |
107 | 108 |
108 // Sets the GL api to the real hardware API (vs the VirtualAPI) | 109 // Sets the GL api to the real hardware API (vs the VirtualAPI) |
109 static void SetRealGLApi(); | 110 static void SetRealGLApi(); |
110 static void SetCurrent(GLContext* context, GLSurface* surface); | 111 virtual void SetCurrent(GLSurface* surface); |
111 | 112 |
112 // Initialize function pointers to extension functions in the GL | 113 // Initialize function pointers to extension functions in the GL |
113 // implementation. Should be called immediately after this context is made | 114 // implementation. Should be called immediately after this context is made |
114 // current. | 115 // current. |
115 bool InitializeExtensionBindings(); | 116 bool InitializeExtensionBindings(); |
116 | 117 |
118 // Returns the last real (non-virtual) GLContext made current. | |
119 static GLContext* GetRealCurrent(); | |
no sievers
2013/06/05 16:43:37
Acutally, can we do this now instead:
GLContext::
jonathan.backer
2013/06/05 20:40:11
This is fundamentally the same as IsVirtualContext
| |
120 | |
117 private: | 121 private: |
118 friend class base::RefCounted<GLContext>; | 122 friend class base::RefCounted<GLContext>; |
119 | 123 |
124 // For GetRealCurrent. | |
125 friend class VirtualGLApi; | |
126 | |
120 scoped_refptr<GLShareGroup> share_group_; | 127 scoped_refptr<GLShareGroup> share_group_; |
121 scoped_ptr<VirtualGLApi> virtual_gl_api_; | 128 scoped_ptr<VirtualGLApi> virtual_gl_api_; |
122 scoped_ptr<GLStateRestorer> state_restorer_; | 129 scoped_ptr<GLStateRestorer> state_restorer_; |
123 | 130 |
124 DISALLOW_COPY_AND_ASSIGN(GLContext); | 131 DISALLOW_COPY_AND_ASSIGN(GLContext); |
125 }; | 132 }; |
126 | 133 |
134 class GL_EXPORT GLContextReal : public GLContext { | |
135 public: | |
136 explicit GLContextReal(GLShareGroup* share_group); | |
137 | |
138 protected: | |
139 virtual ~GLContextReal(); | |
140 | |
141 virtual void SetCurrent(GLSurface* surface) OVERRIDE; | |
142 | |
143 private: | |
144 DISALLOW_COPY_AND_ASSIGN(GLContextReal); | |
145 }; | |
146 | |
127 } // namespace gfx | 147 } // namespace gfx |
128 | 148 |
129 #endif // UI_GL_GL_CONTEXT_H_ | 149 #endif // UI_GL_GL_CONTEXT_H_ |
OLD | NEW |