Index: ui/gl/gl_context_egl.cc |
diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc |
index 52c60e25e8902889995328672bd866fee7a2cdee..6067070a5171b909448ad0dd7fd5553f5cc77b58 100644 |
--- a/ui/gl/gl_context_egl.cc |
+++ b/ui/gl/gl_context_egl.cc |
@@ -112,6 +112,9 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) { |
return false; |
} |
+ if (!RecreateSurfaceIfNeeded(surface)) |
epenner
2013/04/16 01:02:27
Just one extra note on this. I did think about try
|
+ return false; |
+ |
if (!surface->OnMakeCurrent(this)) { |
LOG(ERROR) << "Could not make current."; |
return false; |
@@ -121,6 +124,35 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) { |
return true; |
} |
+bool GLContextEGL::RecreateSurfaceIfNeeded(GLSurface* surface) { |
+ if (!surface || !surface->RecreateOnMakeCurrent()) |
+ return true; |
+ |
+ // This is specifically needed for Vivante GPU's on Android. |
+ // A native view surface will not be configured correctly |
+ // unless we do all of the following steps after making the |
+ // surface current. |
+ |
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
+ eglMakeCurrent(display_, |
+ EGL_NO_SURFACE, |
+ EGL_NO_SURFACE, |
+ EGL_NO_CONTEXT); |
+ if (!surface->Recreate()) { |
+ LOG(ERROR) << "Failed to recreate surface"; |
+ return false; |
+ } |
+ if (!eglMakeCurrent(display_, |
+ surface->GetHandle(), |
+ surface->GetHandle(), |
+ context_)) { |
+ LOG(ERROR) << "eglMakeCurrent failed with error " |
+ << GetLastEGLErrorString(); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
void GLContextEGL::ReleaseCurrent(GLSurface* surface) { |
if (!IsCurrent(surface)) |
return; |