Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: ui/gl/gl_context.h

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_bindings_autogen_wgl.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 namespace gl { 21 namespace gl {
22 class YUVToRGBConverter; 22 class YUVToRGBConverter;
23 } // namespace gl 23 } // namespace gl
24 24
25 namespace gpu { 25 namespace gpu {
26 class GLContextVirtual; 26 class GLContextVirtual;
27 } // namespace gpu 27 } // namespace gpu
28 28
29 namespace gl { 29 namespace gl {
30 30
31 struct CurrentGL;
32 class DebugGLApi;
33 struct DriverGL;
34 class GLApi;
31 class GLSurface; 35 class GLSurface;
32 class GPUTiming; 36 class GPUTiming;
33 class GPUTimingClient; 37 class GPUTimingClient;
34 struct GLVersionInfo; 38 struct GLVersionInfo;
39 class RealGLApi;
40 class TraceGLApi;
35 41
36 struct GLContextAttribs { 42 struct GLContextAttribs {
37 GpuPreference gpu_preference = PreferIntegratedGpu; 43 GpuPreference gpu_preference = PreferIntegratedGpu;
38 bool bind_generates_resource = true; 44 bool bind_generates_resource = true;
39 bool webgl_compatibility_context = false; 45 bool webgl_compatibility_context = false;
40 }; 46 };
41 47
42 // Encapsulates an OpenGL context, hiding platform specific management. 48 // Encapsulates an OpenGL context, hiding platform specific management.
43 class GL_EXPORT GLContext : public base::RefCounted<GLContext> { 49 class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
44 public: 50 public:
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 136
131 // Returns the GL version string. The context must be current. 137 // Returns the GL version string. The context must be current.
132 virtual std::string GetGLVersion(); 138 virtual std::string GetGLVersion();
133 139
134 // Returns the GL renderer string. The context must be current. 140 // Returns the GL renderer string. The context must be current.
135 virtual std::string GetGLRenderer(); 141 virtual std::string GetGLRenderer();
136 142
137 // Returns a helper structure to convert YUV textures to RGB textures. 143 // Returns a helper structure to convert YUV textures to RGB textures.
138 virtual YUVToRGBConverter* GetYUVToRGBConverter(); 144 virtual YUVToRGBConverter* GetYUVToRGBConverter();
139 145
146 // Get the CurrentGL object for this context containing the driver, version
147 // and API.
148 CurrentGL* GetCurrentGL();
149
140 protected: 150 protected:
141 virtual ~GLContext(); 151 virtual ~GLContext();
142 152
153 // Create the GLApi for this context using the provided driver. Creates a
154 // RealGLApi by default.
155 virtual GLApi* CreateGLApi(DriverGL* driver);
156
143 // Will release the current context when going out of scope, unless canceled. 157 // Will release the current context when going out of scope, unless canceled.
144 class ScopedReleaseCurrent { 158 class ScopedReleaseCurrent {
145 public: 159 public:
146 ScopedReleaseCurrent(); 160 ScopedReleaseCurrent();
147 ~ScopedReleaseCurrent(); 161 ~ScopedReleaseCurrent();
148 162
149 void Cancel(); 163 void Cancel();
150 164
151 private: 165 private:
152 bool canceled_; 166 bool canceled_;
153 }; 167 };
154 168
155 // Sets the GL api to the real hardware API (vs the VirtualAPI) 169 // Sets the GL api to the real hardware API (vs the VirtualAPI)
156 static void SetRealGLApi(); 170 void BindGLApi();
157 virtual void SetCurrent(GLSurface* surface); 171 virtual void SetCurrent(GLSurface* surface);
158 172
159 // Initialize function pointers to functions where the bound version depends 173 // Initialize function pointers to functions where the bound version depends
160 // on GL version or supported extensions. Should be called immediately after 174 // on GL version or supported extensions. Should be called immediately after
161 // this context is made current. 175 // this context is made current.
162 void InitializeDynamicBindings(); 176 void InitializeDynamicBindings();
163 177
164 // Returns the last real (non-virtual) GLContext made current. 178 // Returns the last real (non-virtual) GLContext made current.
165 static GLContext* GetRealCurrent(); 179 static GLContext* GetRealCurrent();
166 180
167 virtual void OnSetSwapInterval(int interval) = 0; 181 virtual void OnSetSwapInterval(int interval) = 0;
168 182
169 private: 183 private:
170 friend class base::RefCounted<GLContext>; 184 friend class base::RefCounted<GLContext>;
171 185
172 // For GetRealCurrent. 186 // For GetRealCurrent.
173 friend class gpu::GLContextVirtual; 187 friend class gpu::GLContextVirtual;
174 188
189 std::unique_ptr<GLVersionInfo> GenerateGLVersionInfo();
190
191 bool static_bindings_initialized_;
192 bool dynamic_bindings_initialized_;
193 std::unique_ptr<DriverGL> driver_gl_;
194 std::unique_ptr<GLApi> gl_api_;
195 std::unique_ptr<TraceGLApi> trace_gl_api_;
196 std::unique_ptr<DebugGLApi> debug_gl_api_;
197 std::unique_ptr<CurrentGL> current_gl_;
198
199 // Copy of the real API (if one was created) for dynamic initialization
200 RealGLApi* real_gl_api_ = nullptr;
201
175 scoped_refptr<GLShareGroup> share_group_; 202 scoped_refptr<GLShareGroup> share_group_;
176 GLContext* current_virtual_context_; 203 GLContext* current_virtual_context_;
177 bool state_dirtied_externally_; 204 bool state_dirtied_externally_;
178 std::unique_ptr<GLStateRestorer> state_restorer_; 205 std::unique_ptr<GLStateRestorer> state_restorer_;
179 std::unique_ptr<GLVersionInfo> version_info_; 206 std::unique_ptr<GLVersionInfo> version_info_;
180 207
181 int swap_interval_; 208 int swap_interval_;
182 bool force_swap_interval_zero_; 209 bool force_swap_interval_zero_;
183 210
184 DISALLOW_COPY_AND_ASSIGN(GLContext); 211 DISALLOW_COPY_AND_ASSIGN(GLContext);
(...skipping 18 matching lines...) Expand all
203 // scoped_refptr containing the initialized GLContext or nullptr if 230 // scoped_refptr containing the initialized GLContext or nullptr if
204 // initialization fails. 231 // initialization fails.
205 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( 232 GL_EXPORT scoped_refptr<GLContext> InitializeGLContext(
206 scoped_refptr<GLContext> context, 233 scoped_refptr<GLContext> context,
207 GLSurface* compatible_surface, 234 GLSurface* compatible_surface,
208 const GLContextAttribs& attribs); 235 const GLContextAttribs& attribs);
209 236
210 } // namespace gl 237 } // namespace gl
211 238
212 #endif // UI_GL_GL_CONTEXT_H_ 239 #endif // UI_GL_GL_CONTEXT_H_
OLDNEW
« no previous file with comments | « ui/gl/gl_bindings_autogen_wgl.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698