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

Side by Side Diff: ui/gl/init/gl_initializer_x11.cc

Issue 2715563002: Moving SwiftShader from component to bundled library (Closed)
Patch Set: Update past extension test fixes Created 3 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/init/gl_initializer_win.cc ('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 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 {
26 namespace init { 27 namespace init {
27 28
28 namespace { 29 namespace {
29 30
30 #if defined(OS_OPENBSD) 31 #if defined(OS_OPENBSD)
31 const char kGLLibraryName[] = "libGL.so"; 32 const char kGLLibraryName[] = "libGL.so";
32 #else 33 #else
33 const char kGLLibraryName[] = "libGL.so.1"; 34 const char kGLLibraryName[] = "libGL.so.1";
34 #endif 35 #endif
35 36
36 const char kGLESv2LibraryName[] = "libGLESv2.so.2"; 37 const char kGLESv2LibraryName[] = "libGLESv2.so.2";
37 const char kEGLLibraryName[] = "libEGL.so.1"; 38 const char kEGLLibraryName[] = "libEGL.so.1";
38 39
39 const char kGLESv2ANGLELibraryName[] = "libGLESv2.so"; 40 const char kGLESv2ANGLELibraryName[] = "libGLESv2.so";
40 const char kEGLANGLELibraryName[] = "libEGL.so"; 41 const char kEGLANGLELibraryName[] = "libEGL.so";
41 42
43 #if BUILDFLAG(ENABLE_SWIFTSHADER)
42 const char kGLESv2SwiftShaderLibraryName[] = "libGLESv2.so"; 44 const char kGLESv2SwiftShaderLibraryName[] = "libGLESv2.so";
43 const char kEGLSwiftShaderLibraryName[] = "libEGL.so"; 45 const char kEGLSwiftShaderLibraryName[] = "libEGL.so";
46 #endif
44 47
45 bool InitializeStaticGLXInternal() { 48 bool InitializeStaticGLXInternal() {
46 base::NativeLibrary library = NULL; 49 base::NativeLibrary library = NULL;
47 const base::CommandLine* command_line = 50 const base::CommandLine* command_line =
48 base::CommandLine::ForCurrentProcess(); 51 base::CommandLine::ForCurrentProcess();
49 52
50 if (command_line->HasSwitch(switches::kTestGLLib)) 53 if (command_line->HasSwitch(switches::kTestGLLib))
51 library = LoadLibraryAndPrintError( 54 library = LoadLibraryAndPrintError(
52 command_line->GetSwitchValueASCII(switches::kTestGLLib).c_str()); 55 command_line->GetSwitchValueASCII(switches::kTestGLLib).c_str());
53 56
(...skipping 23 matching lines...) Expand all
77 80
78 return true; 81 return true;
79 } 82 }
80 83
81 bool InitializeStaticEGLInternal() { 84 bool InitializeStaticEGLInternal() {
82 base::FilePath glesv2_path(kGLESv2LibraryName); 85 base::FilePath glesv2_path(kGLESv2LibraryName);
83 base::FilePath egl_path(kEGLLibraryName); 86 base::FilePath egl_path(kEGLLibraryName);
84 87
85 const base::CommandLine* command_line = 88 const base::CommandLine* command_line =
86 base::CommandLine::ForCurrentProcess(); 89 base::CommandLine::ForCurrentProcess();
87 if (command_line->GetSwitchValueASCII(switches::kUseGL) == 90 const std::string use_gl =
88 kGLImplementationANGLEName) { 91 command_line->GetSwitchValueASCII(switches::kUseGL);
92 if (use_gl == kGLImplementationANGLEName) {
89 base::FilePath module_path; 93 base::FilePath module_path;
90 if (!PathService::Get(base::DIR_MODULE, &module_path)) 94 if (!PathService::Get(base::DIR_MODULE, &module_path))
91 return false; 95 return false;
92 96
93 glesv2_path = module_path.Append(kGLESv2ANGLELibraryName); 97 glesv2_path = module_path.Append(kGLESv2ANGLELibraryName);
94 egl_path = module_path.Append(kEGLANGLELibraryName); 98 egl_path = module_path.Append(kEGLANGLELibraryName);
95 } else if (command_line->GetSwitchValueASCII(switches::kUseGL) == 99 } else if ((use_gl == kGLImplementationSwiftShaderName) ||
96 kGLImplementationSwiftShaderName) { 100 (use_gl == kGLImplementationSwiftShaderForWebGLName)) {
101 #if BUILDFLAG(ENABLE_SWIFTSHADER)
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);
109 #else
110 return false;
111 #endif
104 } 112 }
105 113
106 base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path); 114 base::NativeLibrary gles_library = LoadLibraryAndPrintError(glesv2_path);
107 if (!gles_library) 115 if (!gles_library)
108 return false; 116 return false;
109 base::NativeLibrary egl_library = LoadLibraryAndPrintError(egl_path); 117 base::NativeLibrary egl_library = LoadLibraryAndPrintError(egl_path);
110 if (!egl_library) { 118 if (!egl_library) {
111 base::UnloadNativeLibrary(gles_library); 119 base::UnloadNativeLibrary(gles_library);
112 return false; 120 return false;
113 } 121 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void ShutdownGLPlatform() { 217 void ShutdownGLPlatform() {
210 GLSurfaceEGL::ShutdownOneOff(); 218 GLSurfaceEGL::ShutdownOneOff();
211 ClearBindingsEGL(); 219 ClearBindingsEGL();
212 ClearBindingsGL(); 220 ClearBindingsGL();
213 ClearBindingsGLX(); 221 ClearBindingsGLX();
214 ClearBindingsOSMESA(); 222 ClearBindingsOSMESA();
215 } 223 }
216 224
217 } // namespace init 225 } // namespace init
218 } // namespace gl 226 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_initializer_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698