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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 return false; |
109 gles_path = command_line->GetSwitchValuePath(switches::kSwiftShaderPath); | 109 #endif |
110 gles_path = module_path.Append(L"swiftshader/"); | |
grt (UTC plus 2)
2017/02/27 09:31:56
nit: put these next three lines within #else/#endi
sugoi
2017/02/28 16:45:10
Done. Also did a similar fix in the x11 path.
| |
110 // Preload library | 111 // Preload library |
111 LoadLibrary(L"ddraw.dll"); | 112 LoadLibrary(L"ddraw.dll"); |
112 } else { | 113 } else { |
113 gles_path = module_path; | 114 gles_path = module_path; |
114 } | 115 } |
115 | 116 |
116 // Load libglesv2.dll before libegl.dll because the latter is dependent on | 117 // 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 | 118 // the former and if there is another version of libglesv2.dll in the dll |
118 // search path, it will get loaded instead. | 119 // search path, it will get loaded instead. |
119 base::NativeLibrary gles_library = | 120 base::NativeLibrary gles_library = |
120 base::LoadNativeLibrary(gles_path.Append(L"libglesv2.dll"), nullptr); | 121 base::LoadNativeLibrary(gles_path.Append(L"libglesv2.dll"), nullptr); |
121 if (!gles_library) { | 122 if (!gles_library) { |
122 DVLOG(1) << "libglesv2.dll not found"; | 123 DVLOG(1) << "libglesv2.dll not found"; |
123 return false; | 124 return false; |
124 } | 125 } |
125 | 126 |
126 // When using EGL, first try eglGetProcAddress and then Windows | 127 // When using EGL, first try eglGetProcAddress and then Windows |
127 // GetProcAddress on both the EGL and GLES2 DLLs. | 128 // GetProcAddress on both the EGL and GLES2 DLLs. |
128 base::NativeLibrary egl_library = | 129 base::NativeLibrary egl_library = |
129 base::LoadNativeLibrary(gles_path.Append(L"libegl.dll"), nullptr); | 130 base::LoadNativeLibrary(gles_path.Append(L"libegl.dll"), nullptr); |
130 if (!egl_library) { | 131 if (!egl_library) { |
131 DVLOG(1) << "libegl.dll not found."; | 132 DVLOG(1) << "libegl.dll not found."; |
132 base::UnloadNativeLibrary(gles_library); | 133 base::UnloadNativeLibrary(gles_library); |
133 return false; | 134 return false; |
134 } | 135 } |
135 | 136 |
136 #if BUILDFLAG(ENABLE_SWIFTSHADER) | 137 // Note: This is no longer required by SwiftShader, but we will keep this |
138 // registration code for the time being in case someone attemps to | |
139 // use a legacy version of SwiftShader with Chromium. | |
137 if (using_swift_shader) { | 140 if (using_swift_shader) { |
138 // Register key so that SwiftShader doesn't display watermark logo. | 141 // Register key so that SwiftShader doesn't display watermark logo. |
139 typedef void (__stdcall *RegisterFunc)(const char* key); | 142 typedef void (__stdcall *RegisterFunc)(const char* key); |
140 RegisterFunc reg = reinterpret_cast<RegisterFunc>( | 143 RegisterFunc reg = reinterpret_cast<RegisterFunc>( |
141 base::GetFunctionPointerFromNativeLibrary(gles_library, "Register")); | 144 base::GetFunctionPointerFromNativeLibrary(gles_library, "Register")); |
142 if (reg) { | 145 if (reg) { |
143 reg("SS3GCKK6B448CF63"); | 146 reg("SS3GCKK6B448CF63"); |
144 } | 147 } |
145 } | 148 } |
146 #endif | |
147 | 149 |
148 GLGetProcAddressProc get_proc_address = | 150 GLGetProcAddressProc get_proc_address = |
149 reinterpret_cast<GLGetProcAddressProc>( | 151 reinterpret_cast<GLGetProcAddressProc>( |
150 base::GetFunctionPointerFromNativeLibrary(egl_library, | 152 base::GetFunctionPointerFromNativeLibrary(egl_library, |
151 "eglGetProcAddress")); | 153 "eglGetProcAddress")); |
152 if (!get_proc_address) { | 154 if (!get_proc_address) { |
153 LOG(ERROR) << "eglGetProcAddress not found."; | 155 LOG(ERROR) << "eglGetProcAddress not found."; |
154 base::UnloadNativeLibrary(egl_library); | 156 base::UnloadNativeLibrary(egl_library); |
155 base::UnloadNativeLibrary(gles_library); | 157 base::UnloadNativeLibrary(gles_library); |
156 return false; | 158 return false; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 void ShutdownGLPlatform() { | 305 void ShutdownGLPlatform() { |
304 GLSurfaceEGL::ShutdownOneOff(); | 306 GLSurfaceEGL::ShutdownOneOff(); |
305 ClearBindingsEGL(); | 307 ClearBindingsEGL(); |
306 ClearBindingsGL(); | 308 ClearBindingsGL(); |
307 ClearBindingsOSMESA(); | 309 ClearBindingsOSMESA(); |
308 ClearBindingsWGL(); | 310 ClearBindingsWGL(); |
309 } | 311 } |
310 | 312 |
311 } // namespace init | 313 } // namespace init |
312 } // namespace gl | 314 } // namespace gl |
OLD | NEW |