| Index: ui/gl/gl_implementation.cc
|
| diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc
|
| index c0c531746e5852ba9d6ec670dd3b0ba033213ed6..71381c8c4f5a27fce68547f1216252068f3816b2 100644
|
| --- a/ui/gl/gl_implementation.cc
|
| +++ b/ui/gl/gl_implementation.cc
|
| @@ -13,12 +13,14 @@
|
| #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"
|
| #include "ui/gl/gl_bindings.h"
|
| #include "ui/gl/gl_gl_api_implementation.h"
|
| #include "ui/gl/gl_version_info.h"
|
| +#include "ui/gl/init/gl_factory.h"
|
|
|
| namespace gl {
|
|
|
| @@ -96,6 +98,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 ||
|
|
|