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 4cbe8b6d51027ae39787ab9a17e2640096f5a714..e7b5580360722a7a523a00acca420f5cae10d7c6 100644 |
--- a/ui/gl/gl_gl_api_implementation.cc |
+++ b/ui/gl/gl_gl_api_implementation.cc |
@@ -334,6 +334,7 @@ const GLVersionInfo* GetGLVersionInfo() { |
} |
void InitializeDynamicGLBindingsGL(GLContext* context) { |
+ g_real_gl->InitializeFilteredExtensions(); |
g_driver_gl.InitializeCustomDynamicBindings(context); |
DCHECK(context && context->IsCurrent(NULL) && !g_version_info); |
g_real_gl->InitializeWithContext(); |
@@ -404,6 +405,9 @@ void GLApiBase::InitializeBase(DriverGL* driver) { |
} |
RealGLApi::RealGLApi() { |
+#if DCHECK_IS_ON() |
+ filtered_exts_initialized_ = false; |
+#endif |
} |
RealGLApi::~RealGLApi() { |
@@ -428,11 +432,13 @@ void RealGLApi::InitializeWithCommandLine(DriverGL* driver, |
} |
void RealGLApi::InitializeWithContext() { |
no sievers
2015/07/23 23:45:57
So this method can go?
Tobias Sargeant
2015/07/24 09:29:14
Yes.
|
- InitializeFilteredExtensions(); |
} |
void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
- if (!filtered_exts_.empty() && pname == GL_NUM_EXTENSIONS) { |
+ if (pname == GL_NUM_EXTENSIONS && disabled_exts_.size()) { |
+#if DCHECK_IS_ON() |
no sievers
2015/07/23 23:45:57
nit: #if DCHECK_IS_ON is redundant here and below
Tobias Sargeant
2015/07/24 09:29:15
I thought so too, but it turns out that because it
|
+ DCHECK(filtered_exts_initialized_); |
+#endif |
*params = static_cast<GLint>(filtered_exts_.size()); |
} else { |
GLApiBase::glGetIntegervFn(pname, params); |
@@ -440,14 +446,20 @@ void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
} |
const GLubyte* RealGLApi::glGetStringFn(GLenum name) { |
- if (!filtered_exts_.empty() && name == GL_EXTENSIONS) { |
+ if (name == GL_EXTENSIONS && disabled_exts_.size()) { |
+#if DCHECK_IS_ON() |
+ DCHECK(filtered_exts_initialized_); |
+#endif |
return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); |
} |
return GLApiBase::glGetStringFn(name); |
} |
const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { |
- if (!filtered_exts_str_.empty() && name == GL_EXTENSIONS) { |
+ if (name == GL_EXTENSIONS && disabled_exts_.size()) { |
+#if DCHECK_IS_ON() |
+ DCHECK(filtered_exts_initialized_); |
+#endif |
if (index >= filtered_exts_.size()) { |
return NULL; |
} |
@@ -465,17 +477,15 @@ void RealGLApi::glFinishFn() { |
} |
void RealGLApi::InitializeFilteredExtensions() { |
- if (!disabled_exts_.empty() && filtered_exts_.empty()) { |
- DCHECK(filtered_exts_.empty() && filtered_exts_str_.empty()); |
- // Fill in filtered_exts_ vector first. |
+ if (disabled_exts_.size()) { |
+ filtered_exts_.clear(); |
if (gfx::GetGLImplementation() != |
gfx::kGLImplementationDesktopGLCoreProfile) { |
- const char* gl_extensions = reinterpret_cast<const char*>( |
- GLApiBase::glGetStringFn(GL_EXTENSIONS)); |
- if (gl_extensions) { |
- filtered_exts_ = base::SplitString( |
- gl_extensions, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
- } |
+ filtered_exts_str_ = |
+ FilterGLExtensionList(reinterpret_cast<const char*>( |
no sievers
2015/07/23 23:45:57
Hmm a bit back and forth going on in here (vector
Tobias Sargeant
2015/07/24 09:29:14
I agree, but I felt that the smaller code offset t
|
+ GLApiBase::glGetStringFn(GL_EXTENSIONS)), |
+ disabled_exts_); |
+ base::SplitString(filtered_exts_str_, ' ', &filtered_exts_); |
} else { |
GLint num_extensions = 0; |
GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions); |
@@ -483,20 +493,16 @@ void RealGLApi::InitializeFilteredExtensions() { |
const char* gl_extension = reinterpret_cast<const char*>( |
GLApiBase::glGetStringiFn(GL_EXTENSIONS, i)); |
DCHECK(gl_extension != NULL); |
- filtered_exts_.push_back(gl_extension); |
+ if (std::find(disabled_exts_.begin(), disabled_exts_.end(), |
+ gl_extension) == disabled_exts_.end()) { |
+ filtered_exts_.push_back(gl_extension); |
+ } |
} |
+ filtered_exts_str_ = base::JoinString(filtered_exts_, " "); |
} |
- |
- // Filter out extensions from the command line. |
- for (const std::string& disabled_ext : disabled_exts_) { |
- filtered_exts_.erase(std::remove(filtered_exts_.begin(), |
- filtered_exts_.end(), |
- disabled_ext), |
- filtered_exts_.end()); |
- } |
- |
- // Construct filtered extensions string for GL_EXTENSIONS string lookups. |
- filtered_exts_str_ = base::JoinString(filtered_exts_, " "); |
+#if DCHECK_IS_ON() |
+ filtered_exts_initialized_ = true; |
+#endif |
} |
} |