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

Unified Diff: ui/gl/gl_egl_api_implementation.cc

Issue 1151093006: Added disabling EGL extensions support with --disable-extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied nits Created 5 years, 6 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_egl_api_implementation.h ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8acaf0f460d034f71ace4701402c69fc6e69a3d6 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 {
@@ -16,6 +21,8 @@ void InitializeStaticGLBindingsEGL() {
g_real_egl->Initialize(&g_driver_egl);
g_current_egl_context = g_real_egl;
g_driver_egl.InitializeStaticBindings();
+
+ g_real_egl->InitializeFilteredExtensions();
}
void InitializeDebugGLBindingsEGL() {
@@ -55,7 +62,56 @@ 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::kDisableGLExtensions);
+ if (!disabled_extensions.empty()) {
+ Tokenize(disabled_extensions, ", ;", &disabled_exts_);
+ }
+}
+
+void RealEGLApi::InitializeFilteredExtensions() {
+ if (!disabled_exts_.empty() && filtered_exts_.empty()) {
+ std::vector<std::string> platform_extensions_vec;
+ std::string platform_ext = DriverEGL::GetPlatformExtensions();
+ base::SplitString(platform_ext, ' ', &platform_extensions_vec);
+
+ std::vector<std::string> client_extensions_vec;
+ std::string client_ext = DriverEGL::GetClientExtensions();
+ base::SplitString(client_ext, ' ', &client_extensions_vec);
+
+ // Filter out extensions from the command line.
+ for (const std::string& disabled_ext : disabled_exts_) {
+ platform_extensions_vec.erase(std::remove(platform_extensions_vec.begin(),
+ platform_extensions_vec.end(),
+ disabled_ext),
+ platform_extensions_vec.end());
+ client_extensions_vec.erase(std::remove(client_extensions_vec.begin(),
+ client_extensions_vec.end(),
+ disabled_ext),
+ client_extensions_vec.end());
+ }
+
+ // Construct filtered extensions string for GL_EXTENSIONS string lookups.
+ filtered_exts_ = JoinString(platform_extensions_vec, " ");
+ if (!platform_extensions_vec.empty() && !client_extensions_vec.empty())
+ filtered_exts_ += " ";
+ filtered_exts_ += JoinString(client_extensions_vec, " ");
+ }
+}
+
+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);
}
TraceEGLApi::~TraceEGLApi() {
« no previous file with comments | « ui/gl/gl_egl_api_implementation.h ('k') | ui/gl/gl_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698