diff options
author | Mathias Agopian <mathias@google.com> | 2011-08-01 20:24:02 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-08-01 20:24:02 -0700 |
commit | 3ab88557947d708cc36d60ce6566509ceff944e4 (patch) | |
tree | 9d5b772a77965900b776c1bd1c3d398a67f7e393 | |
parent | 34e1fb1ee229a7e033dcd42f4efd194e1614d5ce (diff) | |
download | frameworks_base-3ab88557947d708cc36d60ce6566509ceff944e4.zip frameworks_base-3ab88557947d708cc36d60ce6566509ceff944e4.tar.gz frameworks_base-3ab88557947d708cc36d60ce6566509ceff944e4.tar.bz2 |
fix an issue where the screen could be stale after a surface size change
some GLES drivers dequeue buffers before a frame is started
(which is allowed), which can cause a that frame to be rendered
into a buffer of the wrong size. Such buffer will be ignored
by the compositor. If the application draws only once after a
size change, the screen might stay in this stale state.
this can be avoided by telling the GL driver to purge all its
pending buffers, which is done by making the surface not current
and then current again.
this solution is specific to android, but acceptable because
handled solely in the framework.
Bug: 2263168
Change-Id: I3d3c9a019979a9186e329d3160fa54adac78d3f7
-rw-r--r-- | opengl/java/android/opengl/GLSurfaceView.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index 3f547fd..4c7f84e 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -1073,6 +1073,15 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback return gl; } + public void purgeBuffers() { + mEgl.eglMakeCurrent(mEglDisplay, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_CONTEXT); + mEgl.eglMakeCurrent(mEglDisplay, + mEglSurface, mEglSurface, + mEglContext); + } + /** * Display the current render surface. * @return false if the context has been lost. @@ -1415,6 +1424,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback if (LOG_RENDERER) { Log.w("GLThread", "onSurfaceChanged(" + w + ", " + h + ")"); } + mEglHelper.purgeBuffers(); mRenderer.onSurfaceChanged(gl, w, h); sizeChanged = false; } |