OLD | NEW |
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/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/lazy_instance.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/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
18 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
| 20 // TODO(jmadill): Apply to all platforms eventually |
| 21 #include "ui/gl/angle_platform_impl.h" |
19 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
20 #include "ui/gl/gl_context_stub_with_extensions.h" | 23 #include "ui/gl/gl_context_stub_with_extensions.h" |
21 #include "ui/gl/gl_egl_api_implementation.h" | 24 #include "ui/gl/gl_egl_api_implementation.h" |
22 #include "ui/gl/gl_gl_api_implementation.h" | 25 #include "ui/gl/gl_gl_api_implementation.h" |
23 #include "ui/gl/gl_implementation.h" | 26 #include "ui/gl/gl_implementation.h" |
24 #include "ui/gl/gl_osmesa_api_implementation.h" | 27 #include "ui/gl/gl_osmesa_api_implementation.h" |
25 #include "ui/gl/gl_surface_wgl.h" | 28 #include "ui/gl/gl_surface_wgl.h" |
26 #include "ui/gl/gl_wgl_api_implementation.h" | 29 #include "ui/gl/gl_wgl_api_implementation.h" |
27 | 30 |
28 #if defined(ENABLE_SWIFTSHADER) | 31 #if defined(ENABLE_SWIFTSHADER) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 unsigned long long id, | 93 unsigned long long id, |
91 int numArgs, | 94 int numArgs, |
92 const char** argNames, | 95 const char** argNames, |
93 const unsigned char* argTypes, | 96 const unsigned char* argTypes, |
94 const unsigned long long* argValues, | 97 const unsigned long long* argValues, |
95 unsigned char flags); | 98 unsigned char flags); |
96 typedef void (__stdcall *SetTraceFunctionPointersFunc)( | 99 typedef void (__stdcall *SetTraceFunctionPointersFunc)( |
97 GetCategoryEnabledFlagFunc get_category_enabled_flag, | 100 GetCategoryEnabledFlagFunc get_category_enabled_flag, |
98 AddTraceEventFunc add_trace_event_func); | 101 AddTraceEventFunc add_trace_event_func); |
99 | 102 |
| 103 // TODO(jmadill): Apply to all platforms eventually |
| 104 base::LazyInstance<ANGLEPlatformImpl> g_angle_platform_impl = |
| 105 LAZY_INSTANCE_INITIALIZER; |
| 106 |
| 107 ANGLEPlatformShutdownFunc g_angle_platform_shutdown = nullptr; |
| 108 |
100 } // namespace | 109 } // namespace |
101 | 110 |
102 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 111 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
103 impls->push_back(kGLImplementationEGLGLES2); | 112 impls->push_back(kGLImplementationEGLGLES2); |
104 impls->push_back(kGLImplementationDesktopGL); | 113 impls->push_back(kGLImplementationDesktopGL); |
105 impls->push_back(kGLImplementationOSMesaGL); | 114 impls->push_back(kGLImplementationOSMesaGL); |
106 } | 115 } |
107 | 116 |
108 bool InitializeStaticGLBindings(GLImplementation implementation) { | 117 bool InitializeStaticGLBindings(GLImplementation implementation) { |
109 // Prevent reinitialization with a different implementation. Once the gpu | 118 // Prevent reinitialization with a different implementation. Once the gpu |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return false; | 206 return false; |
198 } | 207 } |
199 | 208 |
200 #if defined(ENABLE_SWIFTSHADER) | 209 #if defined(ENABLE_SWIFTSHADER) |
201 if (using_swift_shader) { | 210 if (using_swift_shader) { |
202 SetupSoftwareRenderer(gles_library); | 211 SetupSoftwareRenderer(gles_library); |
203 } | 212 } |
204 #endif | 213 #endif |
205 | 214 |
206 if (!using_swift_shader) { | 215 if (!using_swift_shader) { |
| 216 // TODO(jmadill): remove when platform impl supports tracing |
207 SetTraceFunctionPointersFunc set_trace_function_pointers = | 217 SetTraceFunctionPointersFunc set_trace_function_pointers = |
208 reinterpret_cast<SetTraceFunctionPointersFunc>( | 218 reinterpret_cast<SetTraceFunctionPointersFunc>( |
209 base::GetFunctionPointerFromNativeLibrary( | 219 base::GetFunctionPointerFromNativeLibrary( |
210 gles_library, "SetTraceFunctionPointers")); | 220 gles_library, "SetTraceFunctionPointers")); |
211 if (set_trace_function_pointers) { | 221 if (set_trace_function_pointers) { |
212 set_trace_function_pointers(&AngleGetTraceCategoryEnabledFlag, | 222 set_trace_function_pointers(&AngleGetTraceCategoryEnabledFlag, |
213 &AngleAddTraceEvent); | 223 &AngleAddTraceEvent); |
214 } | 224 } |
| 225 |
| 226 // Init ANGLE platform here, before we call GetPlatformDisplay(). |
| 227 // TODO(jmadill): Apply to all platforms eventually |
| 228 ANGLEPlatformInitializeFunc angle_platform_init = |
| 229 reinterpret_cast<ANGLEPlatformInitializeFunc>( |
| 230 base::GetFunctionPointerFromNativeLibrary( |
| 231 gles_library, |
| 232 "ANGLEPlatformInitialize")); |
| 233 if (angle_platform_init) { |
| 234 angle_platform_init(&g_angle_platform_impl.Get()); |
| 235 |
| 236 g_angle_platform_shutdown = |
| 237 reinterpret_cast<ANGLEPlatformShutdownFunc>( |
| 238 base::GetFunctionPointerFromNativeLibrary( |
| 239 gles_library, |
| 240 "ANGLEPlatformShutdown")); |
| 241 } |
215 } | 242 } |
216 | 243 |
217 GLGetProcAddressProc get_proc_address = | 244 GLGetProcAddressProc get_proc_address = |
218 reinterpret_cast<GLGetProcAddressProc>( | 245 reinterpret_cast<GLGetProcAddressProc>( |
219 base::GetFunctionPointerFromNativeLibrary( | 246 base::GetFunctionPointerFromNativeLibrary( |
220 egl_library, "eglGetProcAddress")); | 247 egl_library, "eglGetProcAddress")); |
221 if (!get_proc_address) { | 248 if (!get_proc_address) { |
222 LOG(ERROR) << "eglGetProcAddress not found."; | 249 LOG(ERROR) << "eglGetProcAddress not found."; |
223 base::UnloadNativeLibrary(egl_library); | 250 base::UnloadNativeLibrary(egl_library); |
224 base::UnloadNativeLibrary(gles_library); | 251 base::UnloadNativeLibrary(gles_library); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 368 } |
342 | 369 |
343 void InitializeDebugGLBindings() { | 370 void InitializeDebugGLBindings() { |
344 InitializeDebugGLBindingsEGL(); | 371 InitializeDebugGLBindingsEGL(); |
345 InitializeDebugGLBindingsGL(); | 372 InitializeDebugGLBindingsGL(); |
346 InitializeDebugGLBindingsOSMESA(); | 373 InitializeDebugGLBindingsOSMESA(); |
347 InitializeDebugGLBindingsWGL(); | 374 InitializeDebugGLBindingsWGL(); |
348 } | 375 } |
349 | 376 |
350 void ClearGLBindings() { | 377 void ClearGLBindings() { |
| 378 // TODO(jmadill): Apply to all platforms eventually |
| 379 if (g_angle_platform_shutdown) { |
| 380 g_angle_platform_shutdown(); |
| 381 } |
| 382 |
351 ClearGLBindingsEGL(); | 383 ClearGLBindingsEGL(); |
352 ClearGLBindingsGL(); | 384 ClearGLBindingsGL(); |
353 ClearGLBindingsOSMESA(); | 385 ClearGLBindingsOSMESA(); |
354 ClearGLBindingsWGL(); | 386 ClearGLBindingsWGL(); |
355 SetGLImplementation(kGLImplementationNone); | 387 SetGLImplementation(kGLImplementationNone); |
356 UnloadGLNativeLibraries(); | 388 UnloadGLNativeLibraries(); |
357 } | 389 } |
358 | 390 |
359 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { | 391 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
360 switch (GetGLImplementation()) { | 392 switch (GetGLImplementation()) { |
361 case kGLImplementationDesktopGL: | 393 case kGLImplementationDesktopGL: |
362 return GetGLWindowSystemBindingInfoWGL(info); | 394 return GetGLWindowSystemBindingInfoWGL(info); |
363 case kGLImplementationEGLGLES2: | 395 case kGLImplementationEGLGLES2: |
364 return GetGLWindowSystemBindingInfoEGL(info); | 396 return GetGLWindowSystemBindingInfoEGL(info); |
365 default: | 397 default: |
366 return false; | 398 return false; |
367 } | 399 } |
368 } | 400 } |
369 | 401 |
370 } // namespace gfx | 402 } // namespace gfx |
OLD | NEW |