| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/init/gl_initializer.h" | 5 #include "ui/gl/init/gl_initializer.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 // Attempt to load the D3DX shader compiler using the default search path | 92 // Attempt to load the D3DX shader compiler using the default search path |
| 93 // and if that fails, using an absolute path. This is to ensure these DLLs | 93 // and if that fails, using an absolute path. This is to ensure these DLLs |
| 94 // are loaded before ANGLE is loaded in case they are not in the default | 94 // are loaded before ANGLE is loaded in case they are not in the default |
| 95 // search path. | 95 // search path. |
| 96 LoadD3DXLibrary(module_path, kD3DCompiler); | 96 LoadD3DXLibrary(module_path, kD3DCompiler); |
| 97 | 97 |
| 98 base::FilePath gles_path; | 98 base::FilePath gles_path; |
| 99 const base::CommandLine* command_line = | 99 const base::CommandLine* command_line = |
| 100 base::CommandLine::ForCurrentProcess(); | 100 base::CommandLine::ForCurrentProcess(); |
| 101 const std::string use_gl = |
| 102 command_line->GetSwitchValueASCII(switches::kUseGL); |
| 101 bool using_swift_shader = | 103 bool using_swift_shader = |
| 102 command_line->GetSwitchValueASCII(switches::kUseGL) == | 104 (use_gl == kGLImplementationSwiftShaderName) || |
| 103 kGLImplementationSwiftShaderName; | 105 (use_gl == kGLImplementationSwiftShaderForWebGLName); |
| 104 if (using_swift_shader) { | 106 if (using_swift_shader) { |
| 105 if (!command_line->HasSwitch(switches::kSwiftShaderPath)) | 107 if (!command_line->HasSwitch(switches::kSwiftShaderPath)) |
| 106 return false; | 108 return false; |
| 107 gles_path = command_line->GetSwitchValuePath(switches::kSwiftShaderPath); | 109 gles_path = command_line->GetSwitchValuePath(switches::kSwiftShaderPath); |
| 108 // Preload library | 110 // Preload library |
| 109 LoadLibrary(L"ddraw.dll"); | 111 LoadLibrary(L"ddraw.dll"); |
| 110 } else { | 112 } else { |
| 111 gles_path = module_path; | 113 gles_path = module_path; |
| 112 } | 114 } |
| 113 | 115 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 bool InitializeGLOneOffPlatform() { | 237 bool InitializeGLOneOffPlatform() { |
| 236 VSyncProviderWin::InitializeOneOff(); | 238 VSyncProviderWin::InitializeOneOff(); |
| 237 | 239 |
| 238 switch (GetGLImplementation()) { | 240 switch (GetGLImplementation()) { |
| 239 case kGLImplementationDesktopGL: | 241 case kGLImplementationDesktopGL: |
| 240 if (!GLSurfaceWGL::InitializeOneOff()) { | 242 if (!GLSurfaceWGL::InitializeOneOff()) { |
| 241 LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed."; | 243 LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed."; |
| 242 return false; | 244 return false; |
| 243 } | 245 } |
| 244 break; | 246 break; |
| 247 case kGLImplementationSwiftShaderGL: |
| 245 case kGLImplementationEGLGLES2: | 248 case kGLImplementationEGLGLES2: |
| 246 if (!GLSurfaceEGL::InitializeOneOff(GetDC(nullptr))) { | 249 if (!GLSurfaceEGL::InitializeOneOff(GetDC(nullptr))) { |
| 247 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 250 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
| 248 return false; | 251 return false; |
| 249 } | 252 } |
| 250 break; | 253 break; |
| 251 case kGLImplementationOSMesaGL: | 254 case kGLImplementationOSMesaGL: |
| 252 case kGLImplementationMockGL: | 255 case kGLImplementationMockGL: |
| 253 case kGLImplementationStubGL: | 256 case kGLImplementationStubGL: |
| 254 break; | 257 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 266 | 269 |
| 267 // Allow the main thread or another to initialize these bindings | 270 // Allow the main thread or another to initialize these bindings |
| 268 // after instituting restrictions on I/O. Going forward they will | 271 // after instituting restrictions on I/O. Going forward they will |
| 269 // likely be used in the browser process on most platforms. The | 272 // likely be used in the browser process on most platforms. The |
| 270 // one-time initialization cost is small, between 2 and 5 ms. | 273 // one-time initialization cost is small, between 2 and 5 ms. |
| 271 base::ThreadRestrictions::ScopedAllowIO allow_io; | 274 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 272 | 275 |
| 273 switch (implementation) { | 276 switch (implementation) { |
| 274 case kGLImplementationOSMesaGL: | 277 case kGLImplementationOSMesaGL: |
| 275 return InitializeStaticOSMesaInternal(); | 278 return InitializeStaticOSMesaInternal(); |
| 279 case kGLImplementationSwiftShaderGL: |
| 276 case kGLImplementationEGLGLES2: | 280 case kGLImplementationEGLGLES2: |
| 277 return InitializeStaticEGLInternal(); | 281 return InitializeStaticEGLInternal(); |
| 278 case kGLImplementationDesktopGL: | 282 case kGLImplementationDesktopGL: |
| 279 return InitializeStaticWGLInternal(); | 283 return InitializeStaticWGLInternal(); |
| 280 case kGLImplementationMockGL: | 284 case kGLImplementationMockGL: |
| 281 case kGLImplementationStubGL: | 285 case kGLImplementationStubGL: |
| 282 SetGLImplementation(implementation); | 286 SetGLImplementation(implementation); |
| 283 InitializeStaticGLBindingsGL(); | 287 InitializeStaticGLBindingsGL(); |
| 284 return true; | 288 return true; |
| 285 default: | 289 default: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 299 void ShutdownGLPlatform() { | 303 void ShutdownGLPlatform() { |
| 300 GLSurfaceEGL::ShutdownOneOff(); | 304 GLSurfaceEGL::ShutdownOneOff(); |
| 301 ClearBindingsEGL(); | 305 ClearBindingsEGL(); |
| 302 ClearBindingsGL(); | 306 ClearBindingsGL(); |
| 303 ClearBindingsOSMESA(); | 307 ClearBindingsOSMESA(); |
| 304 ClearBindingsWGL(); | 308 ClearBindingsWGL(); |
| 305 } | 309 } |
| 306 | 310 |
| 307 } // namespace init | 311 } // namespace init |
| 308 } // namespace gl | 312 } // namespace gl |
| OLD | NEW |