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

Side by Side Diff: ui/gl/gl_gl_api_implementation.cc

Issue 165723010: Move NullDraw GL bindings and allow them to be disabled temporarily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: glnulldraw: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_implementation.h » ('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 #include "ui/gl/gl_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 CustomRenderbufferStorageEXT); 195 CustomRenderbufferStorageEXT);
196 196
197 DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL); 197 DCHECK(orig_fn.glRenderbufferStorageMultisampleEXTFn == NULL);
198 orig_fn.glRenderbufferStorageMultisampleEXTFn = 198 orig_fn.glRenderbufferStorageMultisampleEXTFn =
199 fn.glRenderbufferStorageMultisampleEXTFn; 199 fn.glRenderbufferStorageMultisampleEXTFn;
200 fn.glRenderbufferStorageMultisampleEXTFn = 200 fn.glRenderbufferStorageMultisampleEXTFn =
201 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>( 201 reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>(
202 CustomRenderbufferStorageMultisampleEXT); 202 CustomRenderbufferStorageMultisampleEXT);
203 } 203 }
204 204
205 static void GL_BINDING_CALL NullDrawClearFn(GLbitfield mask) {
206 if (!g_driver_gl.null_draw_bindings_enabled)
207 g_driver_gl.orig_fn.glClearFn(mask);
208 }
209
210 static void GL_BINDING_CALL
211 NullDrawDrawArraysFn(GLenum mode, GLint first, GLsizei count) {
212 if (!g_driver_gl.null_draw_bindings_enabled)
213 g_driver_gl.orig_fn.glDrawArraysFn(mode, first, count);
214 }
215
216 static void GL_BINDING_CALL NullDrawDrawElementsFn(GLenum mode,
217 GLsizei count,
218 GLenum type,
219 const void* indices) {
220 if (!g_driver_gl.null_draw_bindings_enabled)
221 g_driver_gl.orig_fn.glDrawElementsFn(mode, count, type, indices);
222 }
223
224 void DriverGL::InitializeNullDrawBindings() {
225 DCHECK(orig_fn.glClearFn == NULL);
226 orig_fn.glClearFn = fn.glClearFn;
227 fn.glClearFn = NullDrawClearFn;
228
229 DCHECK(orig_fn.glDrawArraysFn == NULL);
230 orig_fn.glDrawArraysFn = fn.glDrawArraysFn;
231 fn.glDrawArraysFn = NullDrawDrawArraysFn;
232
233 DCHECK(orig_fn.glDrawElementsFn == NULL);
234 orig_fn.glDrawElementsFn = fn.glDrawElementsFn;
235 fn.glDrawElementsFn = NullDrawDrawElementsFn;
236
237 null_draw_bindings_enabled = true;
238 }
239
240 bool DriverGL::SetNullDrawBindingsEnabled(bool enabled) {
241 DCHECK(orig_fn.glClearFn != NULL);
242 DCHECK(orig_fn.glDrawArraysFn != NULL);
243 DCHECK(orig_fn.glDrawElementsFn != NULL);
244
245 bool before = null_draw_bindings_enabled;
246 null_draw_bindings_enabled = enabled;
247 return before;
248 }
249
205 void InitializeStaticGLBindingsGL() { 250 void InitializeStaticGLBindingsGL() {
206 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; 251 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>;
207 g_driver_gl.InitializeStaticBindings(); 252 g_driver_gl.InitializeStaticBindings();
208 if (!g_real_gl) { 253 if (!g_real_gl) {
209 g_real_gl = new RealGLApi(); 254 g_real_gl = new RealGLApi();
210 g_trace_gl = new TraceGLApi(g_real_gl); 255 g_trace_gl = new TraceGLApi(g_real_gl);
211 } 256 }
212 g_real_gl->Initialize(&g_driver_gl); 257 g_real_gl->Initialize(&g_driver_gl);
213 g_gl = g_real_gl; 258 g_gl = g_real_gl;
214 if (CommandLine::ForCurrentProcess()->HasSwitch( 259 if (CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 23 matching lines...) Expand all
238 } 283 }
239 284
240 void InitializeDebugGLBindingsGL() { 285 void InitializeDebugGLBindingsGL() {
241 g_driver_gl.InitializeDebugBindings(); 286 g_driver_gl.InitializeDebugBindings();
242 } 287 }
243 288
244 void InitializeNullDrawGLBindingsGL() { 289 void InitializeNullDrawGLBindingsGL() {
245 g_driver_gl.InitializeNullDrawBindings(); 290 g_driver_gl.InitializeNullDrawBindings();
246 } 291 }
247 292
293 bool SetNullDrawGLBindingsEnabledGL(bool enabled) {
294 return g_driver_gl.SetNullDrawBindingsEnabled(enabled);
295 }
296
248 void ClearGLBindingsGL() { 297 void ClearGLBindingsGL() {
249 if (g_real_gl) { 298 if (g_real_gl) {
250 delete g_real_gl; 299 delete g_real_gl;
251 g_real_gl = NULL; 300 g_real_gl = NULL;
252 } 301 }
253 if (g_trace_gl) { 302 if (g_trace_gl) {
254 delete g_trace_gl; 303 delete g_trace_gl;
255 g_trace_gl = NULL; 304 g_trace_gl = NULL;
256 } 305 }
257 g_gl = NULL; 306 g_gl = NULL;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 430 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
382 switch (name) { 431 switch (name) {
383 case GL_EXTENSIONS: 432 case GL_EXTENSIONS:
384 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 433 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
385 default: 434 default:
386 return driver_->fn.glGetStringFn(name); 435 return driver_->fn.glGetStringFn(name);
387 } 436 }
388 } 437 }
389 438
390 } // namespace gfx 439 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698