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

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

Issue 2136223002: Introduce GLStubApi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_gl_api_implementation.h ('k') | ui/gl/gl_mock_autogen_gl.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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 10 matching lines...) Expand all
21 21
22 // The GL Api being used. This could be g_real_gl or gl_trace_gl 22 // The GL Api being used. This could be g_real_gl or gl_trace_gl
23 static GLApi* g_gl = NULL; 23 static GLApi* g_gl = NULL;
24 // A GL Api that calls directly into the driver. 24 // A GL Api that calls directly into the driver.
25 static RealGLApi* g_real_gl = NULL; 25 static RealGLApi* g_real_gl = NULL;
26 // A GL Api that does nothing but warn about illegal GL calls without a context 26 // A GL Api that does nothing but warn about illegal GL calls without a context
27 // current. 27 // current.
28 static NoContextGLApi* g_no_context_gl = NULL; 28 static NoContextGLApi* g_no_context_gl = NULL;
29 // A GL Api that calls TRACE and then calls another GL api. 29 // A GL Api that calls TRACE and then calls another GL api.
30 static TraceGLApi* g_trace_gl = NULL; 30 static TraceGLApi* g_trace_gl = NULL;
31 // The GL Api being used for stub contexts. If null, g_gl is used instead.
32 static GLApi* g_stub_gl = NULL;
31 // GL version used when initializing dynamic bindings. 33 // GL version used when initializing dynamic bindings.
32 static GLVersionInfo* g_version_info = NULL; 34 static GLVersionInfo* g_version_info = NULL;
33 35
34 namespace { 36 namespace {
35 37
36 static inline GLenum GetInternalFormat(GLenum internal_format) { 38 static inline GLenum GetInternalFormat(GLenum internal_format) {
37 if (GetGLImplementation() != kGLImplementationEGLGLES2) { 39 if (GetGLImplementation() != kGLImplementationEGLGLES2) {
38 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) 40 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
39 return GL_RGBA8; 41 return GL_RGBA8;
40 } 42 }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 375 }
374 376
375 void SetGLApi(GLApi* api) { 377 void SetGLApi(GLApi* api) {
376 g_current_gl_context_tls->Set(api); 378 g_current_gl_context_tls->Set(api);
377 } 379 }
378 380
379 void SetGLToRealGLApi() { 381 void SetGLToRealGLApi() {
380 SetGLApi(g_gl); 382 SetGLApi(g_gl);
381 } 383 }
382 384
385 void SetGLToStubGLApi() {
386 SetGLApi(g_stub_gl ? g_stub_gl : g_gl);
no sievers 2016/07/11 22:42:41 What uses GLContextStub in a way that this has to
piman 2016/07/11 23:57:27 The mock bindings use RealGLApi, but hooking GetPr
387 }
388
383 void SetGLApiToNoContext() { 389 void SetGLApiToNoContext() {
384 SetGLApi(g_no_context_gl); 390 SetGLApi(g_no_context_gl);
385 } 391 }
386 392
393 void SetStubGLApi(GLApi* api) {
394 g_stub_gl = api;
395 }
396
387 const GLVersionInfo* GetGLVersionInfo() { 397 const GLVersionInfo* GetGLVersionInfo() {
388 return g_version_info; 398 return g_version_info;
389 } 399 }
390 400
391 void InitializeDynamicGLBindingsGL(GLContext* context) { 401 void InitializeDynamicGLBindingsGL(GLContext* context) {
392 if (g_version_info) 402 if (g_version_info)
393 return; 403 return;
394 g_real_gl->InitializeFilteredExtensions(); 404 g_real_gl->InitializeFilteredExtensions();
395 g_driver_gl.InitializeCustomDynamicBindings(context); 405 g_driver_gl.InitializeCustomDynamicBindings(context);
396 DCHECK(context && context->IsCurrent(NULL) && !g_version_info); 406 DCHECK(context && context->IsCurrent(NULL) && !g_version_info);
(...skipping 26 matching lines...) Expand all
423 } 433 }
424 if (g_trace_gl) { 434 if (g_trace_gl) {
425 delete g_trace_gl; 435 delete g_trace_gl;
426 g_trace_gl = NULL; 436 g_trace_gl = NULL;
427 } 437 }
428 if (g_no_context_gl) { 438 if (g_no_context_gl) {
429 delete g_no_context_gl; 439 delete g_no_context_gl;
430 g_no_context_gl = NULL; 440 g_no_context_gl = NULL;
431 } 441 }
432 g_gl = NULL; 442 g_gl = NULL;
443 g_stub_gl = NULL;
433 g_driver_gl.ClearBindings(); 444 g_driver_gl.ClearBindings();
434 if (g_current_gl_context_tls) { 445 if (g_current_gl_context_tls) {
435 delete g_current_gl_context_tls; 446 delete g_current_gl_context_tls;
436 g_current_gl_context_tls = NULL; 447 g_current_gl_context_tls = NULL;
437 } 448 }
438 if (g_version_info) { 449 if (g_version_info) {
439 delete g_version_info; 450 delete g_version_info;
440 g_version_info = NULL; 451 g_version_info = NULL;
441 } 452 }
442 } 453 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 TraceGLApi::~TraceGLApi() { 563 TraceGLApi::~TraceGLApi() {
553 } 564 }
554 565
555 NoContextGLApi::NoContextGLApi() { 566 NoContextGLApi::NoContextGLApi() {
556 } 567 }
557 568
558 NoContextGLApi::~NoContextGLApi() { 569 NoContextGLApi::~NoContextGLApi() {
559 } 570 }
560 571
561 } // namespace gl 572 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_mock_autogen_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698