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 9184fc3066a0e43fabfbc3e83f1c66267be0ec22..6bbe50527ea32db9158f91bb50c6419d67eb8a81 100644 |
| --- a/ui/gl/gl_gl_api_implementation.cc |
| +++ b/ui/gl/gl_gl_api_implementation.cc |
| @@ -14,6 +14,7 @@ |
| #include "ui/gl/gl_state_restorer.h" |
| #include "ui/gl/gl_surface.h" |
| #include "ui/gl/gl_switches.h" |
| +#include "ui/gl/gl_version_info.h" |
| namespace gfx { |
| @@ -23,6 +24,8 @@ static GLApi* g_gl; |
| static RealGLApi* g_real_gl; |
| // A GL Api that calls TRACE and then calls another GL api. |
| static TraceGLApi* g_trace_gl; |
| +// GL version used when initializing dynamic bindings. |
| +static GLVersionInfo* g_version_info = NULL; |
| namespace { |
| @@ -40,7 +43,25 @@ static inline GLenum GetTexInternalFormat(GLenum internal_format, |
| GLenum type) { |
| GLenum gl_internal_format = GetInternalFormat(internal_format); |
| - if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
| + // g_version_info must be initialized when this function is bound. |
| + DCHECK(gfx::g_version_info); |
| + if (type == GL_FLOAT && gfx::g_version_info->is_angle && |
| + gfx::g_version_info->is_es2) { |
| + // It's possible that the texture is using a sized internal format, and |
| + // ANGLE exposing GLES2 API doesn't support those. |
|
piman
2014/02/12 21:04:08
nit: file a bug and reference here, so that we can
|
| + switch (format) { |
| + case GL_RGBA: |
| + gl_internal_format = GL_RGBA; |
| + break; |
| + case GL_RGB: |
| + gl_internal_format = GL_RGB; |
| + break; |
| + default: |
| + break; |
| + } |
| + } |
| + |
| + if (gfx::g_version_info->is_es) |
| return gl_internal_format; |
| if (type == GL_FLOAT) { |
| @@ -208,6 +229,9 @@ void SetGLToRealGLApi() { |
| void InitializeDynamicGLBindingsGL(GLContext* context) { |
| g_driver_gl.InitializeCustomDynamicBindings(context); |
| + DCHECK(context && context->IsCurrent(NULL) && !g_version_info); |
| + g_version_info = new GLVersionInfo(context->GetGLVersion().c_str(), |
| + context->GetGLRenderer().c_str()); |
| } |
| void InitializeDebugGLBindingsGL() { |
| @@ -233,6 +257,10 @@ void ClearGLBindingsGL() { |
| delete g_current_gl_context_tls; |
| g_current_gl_context_tls = NULL; |
| } |
| + if (g_version_info) { |
| + delete g_version_info; |
| + g_version_info = NULL; |
| + } |
| } |
| GLApi::GLApi() { |