Chromium Code Reviews| Index: ui/gl/gl_gl_api_implementation.cc |
| diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc |
| index 6752a25ee5a83644a00495804ffb027d81a54859..8f86d946d6a63bdc34bdbbfa95da75bbbcbb5005 100644 |
| --- a/ui/gl/gl_gl_api_implementation.cc |
| +++ b/ui/gl/gl_gl_api_implementation.cc |
| @@ -8,6 +8,7 @@ |
| #include <vector> |
| #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" |
| @@ -407,6 +408,34 @@ void RealGLApi::Initialize(DriverGL* driver) { |
| InitializeBase(driver); |
| } |
| +void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
| + if (pname == GL_NUM_EXTENSIONS) { |
| + BuildFilteredExtensions(); |
|
no sievers
2015/04/29 18:48:10
Can we do this once from initialization instead of
David Yen
2015/04/29 19:23:09
Done.
|
| + *params = static_cast<GLint>(filtered_exts_str_.size()); |
| + return; |
| + } |
| + GLApiBase::glGetIntegervFn(pname, params); |
| +} |
| + |
| +const GLubyte* RealGLApi::glGetStringFn(GLenum name) { |
|
no sievers
2015/04/29 18:48:10
You have to do the same thing for VirtualGLApi als
David Yen
2015/04/29 19:23:09
The VirtualGLApi obtains the list of extensions fr
no sievers
2015/04/30 20:45:02
Yes, we should fix those functions too. But that s
David Yen
2015/04/30 22:14:17
Acknowledged.
|
| + if (name == GL_EXTENSIONS) { |
| + BuildFilteredExtensions(); |
| + return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); |
| + } |
| + return GLApiBase::glGetStringFn(name); |
| +} |
| + |
| +const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { |
| + if (name == GL_EXTENSIONS) { |
| + BuildFilteredExtensions(); |
| + if (index >= filtered_exts_.size()) { |
| + return NULL; |
| + } |
| + return reinterpret_cast<const GLubyte*>(filtered_exts_[index].c_str()); |
| + } |
| + return GLApiBase::glGetStringiFn(name, index); |
| +} |
| + |
| void RealGLApi::glFlushFn() { |
| GLApiBase::glFlushFn(); |
| } |
| @@ -415,6 +444,55 @@ void RealGLApi::glFinishFn() { |
| GLApiBase::glFinishFn(); |
| } |
| +void RealGLApi::BuildFilteredExtensions() { |
| + if (filtered_exts_.empty()) { |
| + if (gfx::GetGLImplementation() != |
| + gfx::kGLImplementationDesktopGLCoreProfile) { |
| + base::SplitString( |
| + reinterpret_cast<const char*>( |
| + GLApiBase::glGetStringFn(GL_EXTENSIONS)), |
| + ' ', |
| + &filtered_exts_); |
| + } else { |
| + GLint num_extensions = 0; |
| + GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions); |
| + for (GLint i = 0; i < num_extensions; ++i) { |
| + const char* extension = reinterpret_cast<const char*>( |
| + GLApiBase::glGetStringiFn(GL_EXTENSIONS, i)); |
| + DCHECK(extension != NULL); |
| + filtered_exts_.push_back(extension); |
| + } |
| + } |
| + |
| + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| + const std::string disabled_extensions = cmd_line->GetSwitchValueASCII( |
| + switches::kDisableGLExtensions); |
| + if (!disabled_extensions.empty()) { |
| + std::vector<std::string> disabled_extensions_list; |
| + Tokenize(disabled_extensions, ", ;", &disabled_extensions_list); |
| + |
| + auto ext_iter = filtered_exts_.begin(); |
| + while (ext_iter != filtered_exts_.end()) { |
| + bool filtered = false; |
|
no sievers
2015/04/29 18:48:10
nit:
Is it maybe slightly simpler to iterate over
David Yen
2015/04/29 19:23:09
I've changed it to use std::remove instead.
|
| + for (const std::string& disabled_ext : disabled_extensions_list) { |
| + if (*ext_iter == disabled_ext) { |
| + filtered = true; |
| + break; |
| + } |
| + } |
| + |
| + if (filtered) { |
| + ext_iter = filtered_exts_.erase(ext_iter); |
| + } else { |
| + ++ext_iter; |
| + } |
| + } |
| + } |
| + |
| + filtered_exts_str_ = JoinString(filtered_exts_, " "); |
| + } |
| +} |
| + |
| TraceGLApi::~TraceGLApi() { |
| } |