Index: ui/gl/gl_egl_api_implementation.cc |
diff --git a/ui/gl/gl_egl_api_implementation.cc b/ui/gl/gl_egl_api_implementation.cc |
index 53a1bf63816d6dc399f7dd4ede5de7a2161dd42c..d22f564a23c6dc91f5d336d46627da20268ba05d 100644 |
--- a/ui/gl/gl_egl_api_implementation.cc |
+++ b/ui/gl/gl_egl_api_implementation.cc |
@@ -3,6 +3,11 @@ |
// found in the LICENSE file. |
#include "ui/gl/gl_egl_api_implementation.h" |
+ |
+#include "base/command_line.h" |
+#include "base/strings/string_split.h" |
+#include "base/strings/string_util.h" |
+#include "ui/gl/gl_context.h" |
#include "ui/gl/gl_implementation.h" |
namespace gfx { |
@@ -18,6 +23,11 @@ void InitializeStaticGLBindingsEGL() { |
g_driver_egl.InitializeStaticBindings(); |
} |
+void InitializeDynamicGLBindingsEGL(GLContext* context) { |
no sievers
2015/05/28 19:25:10
I had actually previously removed the notion of in
David Yen
2015/06/05 23:59:51
Done.
|
+ DCHECK(context && context->IsCurrent(NULL)); |
+ g_real_egl->InitializeWithContext(); |
+} |
+ |
void InitializeDebugGLBindingsEGL() { |
g_driver_egl.InitializeDebugBindings(); |
} |
@@ -55,7 +65,52 @@ RealEGLApi::~RealEGLApi() { |
} |
void RealEGLApi::Initialize(DriverEGL* driver) { |
+ InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); |
+} |
+ |
+void RealEGLApi::InitializeWithCommandLine(DriverEGL* driver, |
+ base::CommandLine* command_line) { |
+ DCHECK(command_line); |
InitializeBase(driver); |
+ |
+ const std::string disabled_extensions = command_line->GetSwitchValueASCII( |
+ switches::kDisableExtensions); |
+ if (!disabled_extensions.empty()) { |
+ Tokenize(disabled_extensions, ", ;", &disabled_exts_); |
+ } |
+} |
+ |
+void RealEGLApi::InitializeWithContext() { |
+ InitializeFilteredExtensions(); |
+} |
+ |
+const char* RealEGLApi::eglQueryStringFn(EGLDisplay dpy, EGLint name) { |
+ if (!filtered_exts_.empty() && name == EGL_EXTENSIONS) { |
+ return filtered_exts_.c_str(); |
+ } |
+ return EGLApiBase::eglQueryStringFn(dpy, name); |
+} |
+ |
+void RealEGLApi::InitializeFilteredExtensions() { |
+ if (!disabled_exts_.empty() && filtered_exts_.empty()) { |
+ EGLDisplay display = EGLApiBase::eglGetCurrentDisplayFn(); |
+ std::vector<std::string> extensions_vec; |
+ const char* egl_extensions = EGLApiBase::eglQueryStringFn(display, |
no sievers
2015/05/28 19:25:10
You can call DriverEGL::GetPlatformExtensions() an
David Yen
2015/06/05 23:59:51
Done, although I had to make RealEGLApi a friend o
|
+ EGL_EXTENSIONS); |
+ if (egl_extensions) |
+ base::SplitString(egl_extensions, ' ', &extensions_vec); |
+ |
+ // Filter out extensions from the command line. |
+ for (const std::string& disabled_ext : disabled_exts_) { |
+ extensions_vec.erase(std::remove(extensions_vec.begin(), |
+ extensions_vec.end(), |
+ disabled_ext), |
+ extensions_vec.end()); |
+ } |
+ |
+ // Construct filtered extensions string for GL_EXTENSIONS string lookups. |
+ filtered_exts_ = JoinString(extensions_vec, " "); |
+ } |
} |
TraceEGLApi::~TraceEGLApi() { |