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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "ui/gfx/switches.h" | 12 #include "ui/gfx/switches.h" |
13 #include "ui/gfx/x/x11_types.h" | 13 #include "ui/gfx/x/x11_types.h" |
14 #include "ui/gl/gl_bindings.h" | 14 #include "ui/gl/gl_bindings.h" |
15 #include "ui/gl/gl_egl_api_implementation.h" | 15 #include "ui/gl/gl_egl_api_implementation.h" |
| 16 #include "ui/gl/gl_features.h" |
16 #include "ui/gl/gl_gl_api_implementation.h" | 17 #include "ui/gl/gl_gl_api_implementation.h" |
17 #include "ui/gl/gl_glx_api_implementation.h" | 18 #include "ui/gl/gl_glx_api_implementation.h" |
18 #include "ui/gl/gl_implementation_osmesa.h" | 19 #include "ui/gl/gl_implementation_osmesa.h" |
19 #include "ui/gl/gl_osmesa_api_implementation.h" | 20 #include "ui/gl/gl_osmesa_api_implementation.h" |
20 #include "ui/gl/gl_surface_egl.h" | 21 #include "ui/gl/gl_surface_egl.h" |
21 #include "ui/gl/gl_surface_glx.h" | 22 #include "ui/gl/gl_surface_glx.h" |
22 #include "ui/gl/gl_surface_osmesa_x11.h" | 23 #include "ui/gl/gl_surface_osmesa_x11.h" |
23 #include "ui/gl/gl_switches.h" | 24 #include "ui/gl/gl_switches.h" |
24 | 25 |
25 namespace gl { | 26 namespace gl { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 78 |
78 return true; | 79 return true; |
79 } | 80 } |
80 | 81 |
81 bool InitializeStaticEGLInternal() { | 82 bool InitializeStaticEGLInternal() { |
82 base::FilePath glesv2_path(kGLESv2LibraryName); | 83 base::FilePath glesv2_path(kGLESv2LibraryName); |
83 base::FilePath egl_path(kEGLLibraryName); | 84 base::FilePath egl_path(kEGLLibraryName); |
84 | 85 |
85 const base::CommandLine* command_line = | 86 const base::CommandLine* command_line = |
86 base::CommandLine::ForCurrentProcess(); | 87 base::CommandLine::ForCurrentProcess(); |
87 if (command_line->GetSwitchValueASCII(switches::kUseGL) == | 88 const std::string use_gl = |
88 kGLImplementationANGLEName) { | 89 command_line->GetSwitchValueASCII(switches::kUseGL); |
| 90 if (use_gl == kGLImplementationANGLEName) { |
89 base::FilePath module_path; | 91 base::FilePath module_path; |
90 if (!PathService::Get(base::DIR_MODULE, &module_path)) | 92 if (!PathService::Get(base::DIR_MODULE, &module_path)) |
91 return false; | 93 return false; |
92 | 94 |
93 glesv2_path = module_path.Append(kGLESv2ANGLELibraryName); | 95 glesv2_path = module_path.Append(kGLESv2ANGLELibraryName); |
94 egl_path = module_path.Append(kEGLANGLELibraryName); | 96 egl_path = module_path.Append(kEGLANGLELibraryName); |
95 } else if (command_line->GetSwitchValueASCII(switches::kUseGL) == | 97 } else if ((use_gl == kGLImplementationSwiftShaderName) || |
96 kGLImplementationSwiftShaderName) { | 98 (use_gl == kGLImplementationSwiftShaderForWebGLName)) { |
| 99 #if !BUILDFLAG(ENABLE_SWIFTSHADER) |
| 100 return false; |
| 101 #endif |
97 base::FilePath module_path; | 102 base::FilePath module_path; |
98 if (!command_line->HasSwitch(switches::kSwiftShaderPath)) | 103 if (!PathService::Get(base::DIR_MODULE, &module_path)) |
99 return false; | 104 return false; |
100 module_path = command_line->GetSwitchValuePath(switches::kSwiftShaderPath); | 105 module_path = module_path.Append("swiftshader/"); |
101 | 106 |
102 glesv2_path = module_path.Append(kGLESv2SwiftShaderLibraryName); | 107 glesv2_path = module_path.Append(kGLESv2SwiftShaderLibraryName); |
103 egl_path = module_path.Append(kEGLSwiftShaderLibraryName); | 108 egl_path = module_path.Append(kEGLSwiftShaderLibraryName); |
104 } | 109 } |
105 | 110 |
106 base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path); | 111 base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path); |
107 if (!gles_library) | 112 if (!gles_library) |
108 return false; | 113 return false; |
109 base::NativeLibrary egl_library = LoadLibraryAndPrintError(egl_path); | 114 base::NativeLibrary egl_library = LoadLibraryAndPrintError(egl_path); |
110 if (!egl_library) { | 115 if (!egl_library) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void ShutdownGLPlatform() { | 214 void ShutdownGLPlatform() { |
210 GLSurfaceEGL::ShutdownOneOff(); | 215 GLSurfaceEGL::ShutdownOneOff(); |
211 ClearBindingsEGL(); | 216 ClearBindingsEGL(); |
212 ClearBindingsGL(); | 217 ClearBindingsGL(); |
213 ClearBindingsGLX(); | 218 ClearBindingsGLX(); |
214 ClearBindingsOSMESA(); | 219 ClearBindingsOSMESA(); |
215 } | 220 } |
216 | 221 |
217 } // namespace init | 222 } // namespace init |
218 } // namespace gl | 223 } // namespace gl |
OLD | NEW |