From 3ab88557947d708cc36d60ce6566509ceff944e4 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 1 Aug 2011 20:24:02 -0700 Subject: 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 --- opengl/java/android/opengl/GLSurfaceView.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'opengl') 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; } -- cgit v1.1