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

Side by Side Diff: ui/gl/gl_implementation.cc

Issue 1542013005: Add a new driver bug workaround SANDBOX_START_EARLY Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just rebase Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gl_implementation.h" 5 #include "ui/gl/gl_implementation.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
11 11
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/stl_util.h"
16 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "ui/gl/gl_bindings.h" 20 #include "ui/gl/gl_bindings.h"
20 #include "ui/gl/gl_gl_api_implementation.h" 21 #include "ui/gl/gl_gl_api_implementation.h"
21 #include "ui/gl/gl_version_info.h" 22 #include "ui/gl/gl_version_info.h"
22 23
23 namespace gfx { 24 namespace gfx {
24 25
25 namespace { 26 namespace {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 void SetGLImplementation(GLImplementation implementation) { 92 void SetGLImplementation(GLImplementation implementation) {
92 g_gl_implementation = implementation; 93 g_gl_implementation = implementation;
93 } 94 }
94 95
95 GLImplementation GetGLImplementation() { 96 GLImplementation GetGLImplementation() {
96 return g_gl_implementation; 97 return g_gl_implementation;
97 } 98 }
98 99
100 bool SelectGLImplementation(GLImplementation* impl, bool* fallback_to_osmesa) {
101 DCHECK(impl);
102 DCHECK(fallback_to_osmesa);
103
104 std::vector<GLImplementation> allowed_impls;
105 GetAllowedGLImplementations(&allowed_impls);
106 DCHECK(!allowed_impls.empty());
107
108 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
109
110 // The default implementation is always the first one in list.
111 *impl = allowed_impls[0];
112 *fallback_to_osmesa = false;
113 if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
114 *impl = kGLImplementationOSMesaGL;
115 } else if (cmd->HasSwitch(switches::kUseGL)) {
116 std::string requested_implementation_name =
117 cmd->GetSwitchValueASCII(switches::kUseGL);
118 if (requested_implementation_name == "any") {
119 *fallback_to_osmesa = true;
120 } else if (requested_implementation_name ==
121 kGLImplementationSwiftShaderName ||
122 requested_implementation_name == kGLImplementationANGLEName) {
123 *impl = kGLImplementationEGLGLES2;
124 } else {
125 *impl = GetNamedGLImplementation(requested_implementation_name);
126 if (!ContainsValue(allowed_impls, *impl)) {
127 LOG(ERROR) << "Requested GL implementation is not available.";
128 return false;
129 }
130 }
131 }
132
133 return true;
134 }
135
99 bool HasDesktopGLFeatures() { 136 bool HasDesktopGLFeatures() {
100 return kGLImplementationDesktopGL == g_gl_implementation || 137 return kGLImplementationDesktopGL == g_gl_implementation ||
101 kGLImplementationDesktopGLCoreProfile == g_gl_implementation || 138 kGLImplementationDesktopGLCoreProfile == g_gl_implementation ||
102 kGLImplementationOSMesaGL == g_gl_implementation || 139 kGLImplementationOSMesaGL == g_gl_implementation ||
103 kGLImplementationAppleGL == g_gl_implementation; 140 kGLImplementationAppleGL == g_gl_implementation;
104 } 141 }
105 142
106 void AddGLNativeLibrary(base::NativeLibrary library) { 143 void AddGLNativeLibrary(base::NativeLibrary library) {
107 DCHECK(library); 144 DCHECK(library);
108 145
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); 259 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
223 if (!library) { 260 if (!library) {
224 LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " 261 LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": "
225 << error.ToString(); 262 << error.ToString();
226 return NULL; 263 return NULL;
227 } 264 }
228 return library; 265 return library;
229 } 266 }
230 267
231 } // namespace gfx 268 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698