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..81e6c1bf51283d9d9d56816b54cb35dce7885484 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" |
| @@ -398,6 +399,44 @@ void GLApiBase::InitializeBase(DriverGL* driver) { |
| } |
| RealGLApi::RealGLApi() { |
|
no sievers
2015/04/30 20:45:02
That doesn't work. |driver_| will be NULL when Rea
David Yen
2015/04/30 22:14:17
Done.
|
| + 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_vec; |
| + Tokenize(disabled_extensions, ", ;", &disabled_extensions_vec); |
| + |
| + // Fill in filtered_exts_ vector first. |
| + if (gfx::GetGLImplementation() != |
| + gfx::kGLImplementationDesktopGLCoreProfile) { |
| + const char* gl_extensions = reinterpret_cast<const char*>( |
| + GLApiBase::glGetStringFn(GL_EXTENSIONS)); |
| + if (gl_extensions) |
| + base::SplitString(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* gl_extension = reinterpret_cast<const char*>( |
| + GLApiBase::glGetStringiFn(GL_EXTENSIONS, i)); |
| + DCHECK(gl_extension != NULL); |
| + filtered_exts_.push_back(gl_extension); |
| + } |
| + } |
| + |
| + // Filter out extensions from the command line. |
| + for (const std::string& disabled_ext : disabled_extensions_vec) { |
| + filtered_exts_.erase(std::remove(filtered_exts_.begin(), |
|
no sievers
2015/04/30 20:45:02
Actually can you just use std::set<> instead of ve
|
| + filtered_exts_.end(), |
| + disabled_ext), |
| + filtered_exts_.end()); |
| + } |
| + |
| + // Construct filtered extensions string for GL_EXTENSIONS string lookups. |
| + filtered_exts_str_ = JoinString(filtered_exts_, " "); |
| + |
| + extensions_filtered_ = true; |
|
no sievers
2015/04/30 20:45:02
Why do we need this?
It seems like it would just c
David Yen
2015/04/30 22:14:17
This was originally added to fix the mock interfac
|
| + } |
| } |
| RealGLApi::~RealGLApi() { |
| @@ -407,6 +446,31 @@ void RealGLApi::Initialize(DriverGL* driver) { |
| InitializeBase(driver); |
| } |
| +void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
| + if (extensions_filtered_ && pname == GL_NUM_EXTENSIONS) { |
| + *params = static_cast<GLint>(filtered_exts_str_.size()); |
|
Zhenyao Mo
2015/04/29 20:04:23
This is incorrect. I think you mean filtered_ext_.
David Yen
2015/04/30 22:14:17
Ah good catch, Done.
|
| + } else { |
| + GLApiBase::glGetIntegervFn(pname, params); |
| + } |
| +} |
| + |
| +const GLubyte* RealGLApi::glGetStringFn(GLenum name) { |
| + if (extensions_filtered_ && name == GL_EXTENSIONS) { |
| + return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); |
| + } |
| + return GLApiBase::glGetStringFn(name); |
| +} |
| + |
| +const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { |
| + if (extensions_filtered_ && name == GL_EXTENSIONS) { |
| + 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(); |
| } |