| Index: ui/gl/gl_implementation.cc
|
| diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc
|
| index 4951de06fdaa08e13b037f364d2084e6e3aa7cc5..1fa9c8522bd73bb58fea12b953abba7674a593db 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,42 @@ GLImplementation GetGLImplementation() {
|
| return g_gl_implementation;
|
| }
|
|
|
| +bool SelectGLImplementation(GLImplementation* impl, bool* fallback_to_osmesa) {
|
| + DCHECK(impl);
|
| + DCHECK(fallback_to_osmesa);
|
| +
|
| + std::vector<GLImplementation> allowed_impls;
|
| + GetAllowedGLImplementations(&allowed_impls);
|
| + DCHECK(!allowed_impls.empty());
|
| +
|
| + base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
| +
|
| + // The default implementation is always the first one in list.
|
| + *impl = allowed_impls[0];
|
| + *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 (!ContainsValue(allowed_impls, *impl)) {
|
| + LOG(ERROR) << "Requested GL implementation is not available.";
|
| + return false;
|
| + }
|
| + }
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| bool HasDesktopGLFeatures() {
|
| return kGLImplementationDesktopGL == g_gl_implementation ||
|
| kGLImplementationDesktopGLCoreProfile == g_gl_implementation ||
|
|
|