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

Unified 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: Rebase Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_implementation.h ('k') | ui/gl/init/gl_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_implementation.cc
diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc
index c0c531746e5852ba9d6ec670dd3b0ba033213ed6..1d808b5346630d5e06537df0b5bfa55c97a9aa66 100644
--- a/ui/gl/gl_implementation.cc
+++ b/ui/gl/gl_implementation.cc
@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
@@ -96,6 +97,44 @@ GLImplementation GetGLImplementation() {
return g_gl_implementation;
}
+bool SelectGLImplementation(const std::vector<GLImplementation>& allowed_impls,
+ GLImplementation* out_impl,
+ bool* out_fallback_to_osmesa) {
+ DCHECK(out_impl);
+ DCHECK(out_fallback_to_osmesa);
+ DCHECK(!allowed_impls.empty());
+
+ base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
+
+ // The default implementation is always the first one in list.
+ GLImplementation impl = allowed_impls[0];
+ bool fallback_to_osmesa = false;
+ if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
+ impl = kGLImplementationOSMesaGL;
+ } else if (cmd->HasSwitch(switches::kUseGL)) {
+ std::string requested_implementation_name =
+ cmd->GetSwitchValueASCII(switches::kUseGL);
+ if (requested_implementation_name == "any") {
+ fallback_to_osmesa = true;
+ } else if (requested_implementation_name ==
+ kGLImplementationSwiftShaderName ||
+ requested_implementation_name == kGLImplementationANGLEName) {
+ impl = kGLImplementationEGLGLES2;
+ } else {
+ impl = GetNamedGLImplementation(requested_implementation_name);
+ if (!base::ContainsValue(allowed_impls, impl)) {
+ LOG(ERROR) << "Requested GL implementation is not available.";
+ return false;
+ }
+ }
+ }
+
+ *out_impl = impl;
+ *out_fallback_to_osmesa = fallback_to_osmesa;
+
+ return true;
+}
+
bool HasDesktopGLFeatures() {
return kGLImplementationDesktopGL == g_gl_implementation ||
kGLImplementationDesktopGLCoreProfile == g_gl_implementation ||
« no previous file with comments | « ui/gl/gl_implementation.h ('k') | ui/gl/init/gl_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698