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

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

Issue 12207003: Add TRACE calls for all gpu driver calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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_glx_api_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/string_util.h" 11 #include "base/string_util.h"
11 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
12 #include "ui/gl/gl_state_restorer.h" 13 #include "ui/gl/gl_state_restorer.h"
13 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface.h"
15 #include "ui/gl/gl_switches.h"
14 16
15 namespace gfx { 17 namespace gfx {
16 18
17 RealGLApi* g_real_gl; 19 // The GL Api being used. This could be g_real_gl or gl_trace_gl
20 static GLApi* g_gl;
21 // A GL Api that calls directly into the driver.
22 static RealGLApi* g_real_gl;
23 // A GL Api that calls TRACE and then calls another GL api.
24 static TraceGLApi* g_trace_gl;
18 25
19 void InitializeGLBindingsGL() { 26 void InitializeGLBindingsGL() {
20 g_driver_gl.InitializeBindings(); 27 g_driver_gl.InitializeBindings();
21 if (!g_real_gl) { 28 if (!g_real_gl) {
22 g_real_gl = new RealGLApi(); 29 g_real_gl = new RealGLApi();
30 g_trace_gl = new TraceGLApi(g_real_gl);
23 } 31 }
24 g_real_gl->Initialize(&g_driver_gl); 32 g_real_gl->Initialize(&g_driver_gl);
33 g_gl = g_real_gl;
34 if (CommandLine::ForCurrentProcess()->HasSwitch(
35 switches::kEnableGPUServiceTracing)) {
36 g_gl = g_trace_gl;
37 }
25 SetGLToRealGLApi(); 38 SetGLToRealGLApi();
26 } 39 }
27 40
28 GLApi* GetCurrentGLApi() { 41 GLApi* GetCurrentGLApi() {
29 return g_current_gl_context; 42 return g_current_gl_context;
30 } 43 }
31 44
32 void SetGLApi(GLApi* api) { 45 void SetGLApi(GLApi* api) {
33 g_current_gl_context = api; 46 g_current_gl_context = api;
34 } 47 }
35 48
36 void SetGLToRealGLApi() { 49 void SetGLToRealGLApi() {
37 SetGLApi(g_real_gl); 50 SetGLApi(g_gl);
38 } 51 }
39 52
40 void InitializeGLExtensionBindingsGL(GLContext* context) { 53 void InitializeGLExtensionBindingsGL(GLContext* context) {
41 g_driver_gl.InitializeExtensionBindings(context); 54 g_driver_gl.InitializeExtensionBindings(context);
42 } 55 }
43 56
44 void InitializeDebugGLBindingsGL() { 57 void InitializeDebugGLBindingsGL() {
45 g_driver_gl.InitializeDebugBindings(); 58 g_driver_gl.InitializeDebugBindings();
46 } 59 }
47 60
48 void ClearGLBindingsGL() { 61 void ClearGLBindingsGL() {
49 if (g_real_gl) { 62 if (g_real_gl) {
50 delete g_real_gl; 63 delete g_real_gl;
51 g_real_gl = NULL; 64 g_real_gl = NULL;
52 } 65 }
66 if (g_trace_gl) {
67 delete g_trace_gl;
68 g_trace_gl = NULL;
69 }
70 g_gl = NULL;
53 g_current_gl_context = NULL; 71 g_current_gl_context = NULL;
54 g_driver_gl.ClearBindings(); 72 g_driver_gl.ClearBindings();
55 } 73 }
56 74
57 GLApi::GLApi() { 75 GLApi::GLApi() {
58 } 76 }
59 77
60 GLApi::~GLApi() { 78 GLApi::~GLApi() {
61 } 79 }
62 80
(...skipping 11 matching lines...) Expand all
74 RealGLApi::RealGLApi() { 92 RealGLApi::RealGLApi() {
75 } 93 }
76 94
77 RealGLApi::~RealGLApi() { 95 RealGLApi::~RealGLApi() {
78 } 96 }
79 97
80 void RealGLApi::Initialize(DriverGL* driver) { 98 void RealGLApi::Initialize(DriverGL* driver) {
81 InitializeBase(driver); 99 InitializeBase(driver);
82 } 100 }
83 101
102 TraceGLApi::~TraceGLApi() {
103 }
104
84 VirtualGLApi::VirtualGLApi() 105 VirtualGLApi::VirtualGLApi()
85 : real_context_(NULL), 106 : real_context_(NULL),
86 current_context_(NULL) { 107 current_context_(NULL) {
87 } 108 }
88 109
89 VirtualGLApi::~VirtualGLApi() { 110 VirtualGLApi::~VirtualGLApi() {
90 } 111 }
91 112
92 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) { 113 void VirtualGLApi::Initialize(DriverGL* driver, GLContext* real_context) {
93 InitializeBase(driver); 114 InitializeBase(driver);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 181 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
161 switch (name) { 182 switch (name) {
162 case GL_EXTENSIONS: 183 case GL_EXTENSIONS:
163 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 184 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
164 default: 185 default:
165 return driver_->fn.glGetStringFn(name); 186 return driver_->fn.glGetStringFn(name);
166 } 187 }
167 } 188 }
168 189
169 } // namespace gfx 190 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | ui/gl/gl_glx_api_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698