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 3a7e2491e6cb9f844b6876dbca19bc141263b814..5393383b4d97e89a79aaa8bc2a5cc03114b8367f 100644 |
--- a/ui/gl/gl_gl_api_implementation.cc |
+++ b/ui/gl/gl_gl_api_implementation.cc |
@@ -413,46 +413,15 @@ void RealGLApi::InitializeWithCommandLine(DriverGL* driver, |
DCHECK(command_line); |
InitializeBase(driver); |
- DCHECK(filtered_exts_.empty() && filtered_exts_str_.empty()); |
- |
const std::string disabled_extensions = command_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(), |
- filtered_exts_.end(), |
- disabled_ext), |
- filtered_exts_.end()); |
- } |
- |
- // Construct filtered extensions string for GL_EXTENSIONS string lookups. |
- filtered_exts_str_ = JoinString(filtered_exts_, " "); |
+ Tokenize(disabled_extensions, ", ;", &disabled_exts_); |
} |
} |
void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
+ InitializeFilteredExtensions(); |
no sievers
2015/05/15 18:31:51
Why this change and make this initialization lazy
no sievers
2015/05/15 23:58:56
Still wondering about this change.
David Yen
2015/05/16 00:01:31
Sorry, I wrote about it in my first message. I had
no sievers
2015/05/16 00:17:19
Can you do it from InitializeCustomDynamicBindings
David Yen
2015/05/18 17:08:48
InitializeCustomDynamicBindings() is a DriverGL fu
no sievers
2015/05/18 18:19:32
Can you call g_real_gl->InitializeWithContext() or
David Yen
2015/05/18 18:23:37
I'll try the g_real_gl method.
Virtual contexts w
|
if (!filtered_exts_.empty() && pname == GL_NUM_EXTENSIONS) { |
*params = static_cast<GLint>(filtered_exts_.size()); |
} else { |
@@ -461,6 +430,7 @@ void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { |
} |
const GLubyte* RealGLApi::glGetStringFn(GLenum name) { |
+ InitializeFilteredExtensions(); |
if (!filtered_exts_.empty() && name == GL_EXTENSIONS) { |
return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); |
} |
@@ -468,6 +438,7 @@ const GLubyte* RealGLApi::glGetStringFn(GLenum name) { |
} |
const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { |
+ InitializeFilteredExtensions(); |
if (!filtered_exts_str_.empty() && name == GL_EXTENSIONS) { |
if (index >= filtered_exts_.size()) { |
return NULL; |
@@ -485,6 +456,40 @@ void RealGLApi::glFinishFn() { |
GLApiBase::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 (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_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_ = JoinString(filtered_exts_, " "); |
+ } |
+} |
+ |
TraceGLApi::~TraceGLApi() { |
} |