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

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

Issue 1007513006: Add ANGLE Platform implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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.gyp ('k') | 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/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
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
100 } // namespace 107 } // namespace
101 108
102 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 109 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
103 impls->push_back(kGLImplementationEGLGLES2); 110 impls->push_back(kGLImplementationEGLGLES2);
104 impls->push_back(kGLImplementationDesktopGL); 111 impls->push_back(kGLImplementationDesktopGL);
105 impls->push_back(kGLImplementationOSMesaGL); 112 impls->push_back(kGLImplementationOSMesaGL);
106 } 113 }
107 114
108 bool InitializeStaticGLBindings(GLImplementation implementation) { 115 bool InitializeStaticGLBindings(GLImplementation implementation) {
109 // Prevent reinitialization with a different implementation. Once the gpu 116 // Prevent reinitialization with a different implementation. Once the gpu
110 // unit tests have initialized with kGLImplementationMock, we don't want to 117 // unit tests have initialized with kGLImplementationMock, we don't want to
111 // later switch to another GL implementation. 118 // later switch to another GL implementation.
112 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); 119 DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
113 120
121 // Init ANGLE platform here, before we call GetPlatformDisplay().
122 // TODO(jmadill): Apply to all platforms eventually
123 base::NativeLibrary libGLESv2_module = base::LoadNativeLibrary(
124 base::FilePath(L"libGLESv2.dll"),
125 nullptr);
126
127 if (libGLESv2_module) {
128 ANGLEPlatformInitializeFunc initFunc =
129 reinterpret_cast<ANGLEPlatformInitializeFunc>(
130 base::GetFunctionPointerFromNativeLibrary(
131 libGLESv2_module,
132 "ANGLEPlatformInitialize"));
133 if (initFunc) {
134 initFunc(&g_angle_platform_impl.Get());
135 }
136 }
piman 2015/03/18 19:27:07 I think we'd only want to do this in the kGLImplem
Jamie Madill 2015/03/18 21:01:50 Done.
137
114 // Allow the main thread or another to initialize these bindings 138 // Allow the main thread or another to initialize these bindings
115 // after instituting restrictions on I/O. Going forward they will 139 // after instituting restrictions on I/O. Going forward they will
116 // likely be used in the browser process on most platforms. The 140 // likely be used in the browser process on most platforms. The
117 // one-time initialization cost is small, between 2 and 5 ms. 141 // one-time initialization cost is small, between 2 and 5 ms.
118 base::ThreadRestrictions::ScopedAllowIO allow_io; 142 base::ThreadRestrictions::ScopedAllowIO allow_io;
119 143
120 switch (implementation) { 144 switch (implementation) {
121 case kGLImplementationOSMesaGL: { 145 case kGLImplementationOSMesaGL: {
122 base::FilePath module_path; 146 base::FilePath module_path;
123 if (!PathService::Get(base::DIR_MODULE, &module_path)) { 147 if (!PathService::Get(base::DIR_MODULE, &module_path)) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 365 }
342 366
343 void InitializeDebugGLBindings() { 367 void InitializeDebugGLBindings() {
344 InitializeDebugGLBindingsEGL(); 368 InitializeDebugGLBindingsEGL();
345 InitializeDebugGLBindingsGL(); 369 InitializeDebugGLBindingsGL();
346 InitializeDebugGLBindingsOSMESA(); 370 InitializeDebugGLBindingsOSMESA();
347 InitializeDebugGLBindingsWGL(); 371 InitializeDebugGLBindingsWGL();
348 } 372 }
349 373
350 void ClearGLBindings() { 374 void ClearGLBindings() {
375 // TODO(jmadill): Apply to all platforms eventually
376 base::NativeLibrary libGLESv2_module = base::LoadNativeLibrary(
377 base::FilePath(L"libGLESv2.dll"),
378 nullptr);
379
380 if (libGLESv2_module) {
381 ANGLEPlatformShutdownFunc shutdownFunc =
piman 2015/03/18 19:27:07 We could just lookup this function at the same tim
Jamie Madill 2015/03/18 21:01:50 Done.
382 reinterpret_cast<ANGLEPlatformShutdownFunc>(
383 base::GetFunctionPointerFromNativeLibrary(
384 libGLESv2_module,
385 "ANGLEPlatformShutdown"));
386 if (shutdownFunc) {
387 shutdownFunc();
388 }
389 }
390
351 ClearGLBindingsEGL(); 391 ClearGLBindingsEGL();
352 ClearGLBindingsGL(); 392 ClearGLBindingsGL();
353 ClearGLBindingsOSMESA(); 393 ClearGLBindingsOSMESA();
354 ClearGLBindingsWGL(); 394 ClearGLBindingsWGL();
355 SetGLImplementation(kGLImplementationNone); 395 SetGLImplementation(kGLImplementationNone);
356 UnloadGLNativeLibraries(); 396 UnloadGLNativeLibraries();
357 } 397 }
358 398
359 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 399 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
360 switch (GetGLImplementation()) { 400 switch (GetGLImplementation()) {
361 case kGLImplementationDesktopGL: 401 case kGLImplementationDesktopGL:
362 return GetGLWindowSystemBindingInfoWGL(info); 402 return GetGLWindowSystemBindingInfoWGL(info);
363 case kGLImplementationEGLGLES2: 403 case kGLImplementationEGLGLES2:
364 return GetGLWindowSystemBindingInfoEGL(info); 404 return GetGLWindowSystemBindingInfoEGL(info);
365 default: 405 default:
366 return false; 406 return false;
367 } 407 }
368 } 408 }
369 409
370 } // namespace gfx 410 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698