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

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

Issue 22744005: initialize trace_event hooks in angle on gpu startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate from angle Created 7 years, 4 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 | « no previous file | no next file » | 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 <vector> 5 #include <vector>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base_paths.h" 8 #include "base/base_paths.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/native_library.h" 14 #include "base/native_library.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
17 #include "base/win/windows_version.h" 18 #include "base/win/windows_version.h"
18 #include "ui/gl/gl_bindings.h" 19 #include "ui/gl/gl_bindings.h"
19 #include "ui/gl/gl_egl_api_implementation.h" 20 #include "ui/gl/gl_egl_api_implementation.h"
20 #include "ui/gl/gl_gl_api_implementation.h" 21 #include "ui/gl/gl_gl_api_implementation.h"
(...skipping 30 matching lines...) Expand all
51 if (!library) { 52 if (!library) {
52 library = base::LoadNativeLibrary(module_path.Append(name), NULL); 53 library = base::LoadNativeLibrary(module_path.Append(name), NULL);
53 if (!library) { 54 if (!library) {
54 DVLOG(1) << name << " not found."; 55 DVLOG(1) << name << " not found.";
55 return false; 56 return false;
56 } 57 }
57 } 58 }
58 return true; 59 return true;
59 } 60 }
60 61
62 const unsigned char* AngleGetTraceCategoryEnabledFlag(const char* name) {
63 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name);
64 }
65
66 void AngleAddTraceEvent(char phase,
67 const unsigned char* category_group_enabled,
68 const char* name,
69 unsigned long long id,
70 int num_args,
71 const char** arg_names,
72 const unsigned char* arg_types,
73 const unsigned long long* arg_values,
74 unsigned char flags) {
75 TRACE_EVENT_API_ADD_TRACE_EVENT(phase,
76 category_group_enabled,
77 name,
78 id,
79 num_args,
80 arg_names,
81 arg_types,
82 arg_values,
83 NULL,
84 flags);
85 }
86
87 typedef const unsigned char* (*GetCategoryEnabledFlagFunc)(const char* name);
88 typedef void (*AddTraceEventFunc)(char phase,
89 const unsigned char* categoryGroupEnabled,
90 const char* name,
91 unsigned long long id,
92 int numArgs,
93 const char** argNames,
94 const unsigned char* argTypes,
95 const unsigned long long* argValues,
96 unsigned char flags);
97 typedef void (*SetTraceFunctionPointersFunc)(
98 GetCategoryEnabledFlagFunc get_category_enabled_flag,
99 AddTraceEventFunc add_trace_event_func);
100
61 } // namespace 101 } // namespace
62 102
63 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 103 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
64 impls->push_back(kGLImplementationEGLGLES2); 104 impls->push_back(kGLImplementationEGLGLES2);
65 impls->push_back(kGLImplementationDesktopGL); 105 impls->push_back(kGLImplementationDesktopGL);
66 impls->push_back(kGLImplementationOSMesaGL); 106 impls->push_back(kGLImplementationOSMesaGL);
67 } 107 }
68 108
69 bool InitializeGLBindings(GLImplementation implementation) { 109 bool InitializeGLBindings(GLImplementation implementation) {
70 // Prevent reinitialization with a different implementation. Once the gpu 110 // Prevent reinitialization with a different implementation. Once the gpu
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 base::UnloadNativeLibrary(gles_library); 200 base::UnloadNativeLibrary(gles_library);
161 return false; 201 return false;
162 } 202 }
163 203
164 #if defined(ENABLE_SWIFTSHADER) 204 #if defined(ENABLE_SWIFTSHADER)
165 if (using_swift_shader) { 205 if (using_swift_shader) {
166 SetupSoftwareRenderer(gles_library); 206 SetupSoftwareRenderer(gles_library);
167 } 207 }
168 #endif 208 #endif
169 209
210 if (!using_swift_shader) {
211 SetTraceFunctionPointersFunc set_trace_function_pointers =
212 reinterpret_cast<SetTraceFunctionPointersFunc>(
213 base::GetFunctionPointerFromNativeLibrary(
214 gles_library, "SetTraceFunctionPointers"));
215 if (set_trace_function_pointers) {
216 set_trace_function_pointers(&AngleGetTraceCategoryEnabledFlag,
217 &AngleAddTraceEvent);
218 }
219 }
220
170 GLGetProcAddressProc get_proc_address = 221 GLGetProcAddressProc get_proc_address =
171 reinterpret_cast<GLGetProcAddressProc>( 222 reinterpret_cast<GLGetProcAddressProc>(
172 base::GetFunctionPointerFromNativeLibrary( 223 base::GetFunctionPointerFromNativeLibrary(
173 egl_library, "eglGetProcAddress")); 224 egl_library, "eglGetProcAddress"));
174 if (!get_proc_address) { 225 if (!get_proc_address) {
175 LOG(ERROR) << "eglGetProcAddress not found."; 226 LOG(ERROR) << "eglGetProcAddress not found.";
176 base::UnloadNativeLibrary(egl_library); 227 base::UnloadNativeLibrary(egl_library);
177 base::UnloadNativeLibrary(gles_library); 228 base::UnloadNativeLibrary(gles_library);
178 return false; 229 return false;
179 } 230 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return GetGLWindowSystemBindingInfoWGL(info); 331 return GetGLWindowSystemBindingInfoWGL(info);
281 case kGLImplementationEGLGLES2: 332 case kGLImplementationEGLGLES2:
282 return GetGLWindowSystemBindingInfoEGL(info); 333 return GetGLWindowSystemBindingInfoEGL(info);
283 default: 334 default:
284 return false; 335 return false;
285 } 336 }
286 return false; 337 return false;
287 } 338 }
288 339
289 } // namespace gfx 340 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698