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

Side by Side Diff: ui/gl/init/gl_initializer_win.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/BUILD.gn ('k') | ui/gl/init/gl_initializer_x11.cc » ('j') | 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 <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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 101 const std::string use_gl =
102 command_line->GetSwitchValueASCII(switches::kUseGL); 102 command_line->GetSwitchValueASCII(switches::kUseGL);
103 bool using_swift_shader = 103 bool using_swift_shader =
104 (use_gl == kGLImplementationSwiftShaderName) || 104 (use_gl == kGLImplementationSwiftShaderName) ||
105 (use_gl == kGLImplementationSwiftShaderForWebGLName); 105 (use_gl == kGLImplementationSwiftShaderForWebGLName);
106 if (using_swift_shader) { 106 if (using_swift_shader) {
107 if (!command_line->HasSwitch(switches::kSwiftShaderPath)) 107 #if BUILDFLAG(ENABLE_SWIFTSHADER)
108 return false; 108 gles_path = module_path.Append(L"swiftshader/");
109 gles_path = command_line->GetSwitchValuePath(switches::kSwiftShaderPath);
110 // Preload library 109 // Preload library
111 LoadLibrary(L"ddraw.dll"); 110 LoadLibrary(L"ddraw.dll");
111 #else
112 return false;
113 #endif
112 } else { 114 } else {
113 gles_path = module_path; 115 gles_path = module_path;
114 } 116 }
115 117
116 // Load libglesv2.dll before libegl.dll because the latter is dependent on 118 // Load libglesv2.dll before libegl.dll because the latter is dependent on
117 // the former and if there is another version of libglesv2.dll in the dll 119 // the former and if there is another version of libglesv2.dll in the dll
118 // search path, it will get loaded instead. 120 // search path, it will get loaded instead.
119 base::NativeLibrary gles_library = 121 base::NativeLibrary gles_library =
120 base::LoadNativeLibrary(gles_path.Append(L"libglesv2.dll"), nullptr); 122 base::LoadNativeLibrary(gles_path.Append(L"libglesv2.dll"), nullptr);
121 if (!gles_library) { 123 if (!gles_library) {
122 DVLOG(1) << "libglesv2.dll not found"; 124 DVLOG(1) << "libglesv2.dll not found";
123 return false; 125 return false;
124 } 126 }
125 127
126 // When using EGL, first try eglGetProcAddress and then Windows 128 // When using EGL, first try eglGetProcAddress and then Windows
127 // GetProcAddress on both the EGL and GLES2 DLLs. 129 // GetProcAddress on both the EGL and GLES2 DLLs.
128 base::NativeLibrary egl_library = 130 base::NativeLibrary egl_library =
129 base::LoadNativeLibrary(gles_path.Append(L"libegl.dll"), nullptr); 131 base::LoadNativeLibrary(gles_path.Append(L"libegl.dll"), nullptr);
130 if (!egl_library) { 132 if (!egl_library) {
131 DVLOG(1) << "libegl.dll not found."; 133 DVLOG(1) << "libegl.dll not found.";
132 base::UnloadNativeLibrary(gles_library); 134 base::UnloadNativeLibrary(gles_library);
133 return false; 135 return false;
134 } 136 }
135 137
136 #if BUILDFLAG(ENABLE_SWIFTSHADER)
137 if (using_swift_shader) {
138 // Register key so that SwiftShader doesn't display watermark logo.
139 typedef void (__stdcall *RegisterFunc)(const char* key);
140 RegisterFunc reg = reinterpret_cast<RegisterFunc>(
141 base::GetFunctionPointerFromNativeLibrary(gles_library, "Register"));
142 if (reg) {
143 reg("SS3GCKK6B448CF63");
144 }
145 }
146 #endif
147
148 GLGetProcAddressProc get_proc_address = 138 GLGetProcAddressProc get_proc_address =
149 reinterpret_cast<GLGetProcAddressProc>( 139 reinterpret_cast<GLGetProcAddressProc>(
150 base::GetFunctionPointerFromNativeLibrary(egl_library, 140 base::GetFunctionPointerFromNativeLibrary(egl_library,
151 "eglGetProcAddress")); 141 "eglGetProcAddress"));
152 if (!get_proc_address) { 142 if (!get_proc_address) {
153 LOG(ERROR) << "eglGetProcAddress not found."; 143 LOG(ERROR) << "eglGetProcAddress not found.";
154 base::UnloadNativeLibrary(egl_library); 144 base::UnloadNativeLibrary(egl_library);
155 base::UnloadNativeLibrary(gles_library); 145 base::UnloadNativeLibrary(gles_library);
156 return false; 146 return false;
157 } 147 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void ShutdownGLPlatform() { 293 void ShutdownGLPlatform() {
304 GLSurfaceEGL::ShutdownOneOff(); 294 GLSurfaceEGL::ShutdownOneOff();
305 ClearBindingsEGL(); 295 ClearBindingsEGL();
306 ClearBindingsGL(); 296 ClearBindingsGL();
307 ClearBindingsOSMESA(); 297 ClearBindingsOSMESA();
308 ClearBindingsWGL(); 298 ClearBindingsWGL();
309 } 299 }
310 300
311 } // namespace init 301 } // namespace init
312 } // namespace gl 302 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/BUILD.gn ('k') | ui/gl/init/gl_initializer_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698