diff options
author | Jack Palevich <jackpal@google.com> | 2012-04-16 12:25:36 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2012-04-16 12:25:36 -0700 |
commit | cee059dc764a57860da6b1574952089680b5ddc6 (patch) | |
tree | 3ab06ffe788422219fbe225af7c70c66a3692d63 /opengl | |
parent | 6e0ac89f3896369363698801e75671b3478e8d4f (diff) | |
download | frameworks_base-cee059dc764a57860da6b1574952089680b5ddc6.zip frameworks_base-cee059dc764a57860da6b1574952089680b5ddc6.tar.gz frameworks_base-cee059dc764a57860da6b1574952089680b5ddc6.tar.bz2 |
Improve GLSurfaceView Pausing.
When pausing we want to do three separate things, in order:
+ release the EGL surface
+ optionally release the EGL context
+ optionally terminate Egl
Previously we would only do these things if we had an EGL surface. But
it is possible that we don't have an EGL Surface, but still have an EGL
context. And in that situation we still want to release the EGL context.
Now we check the preconditions for the three cases separately.
Bug: 6338235
Change-Id: I804683b3d5c136cc98ea3f5051067eea18152ddf
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/java/android/opengl/GLSurfaceView.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index 2a4d59b..8acbae3 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -1298,7 +1298,9 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback } // Update the pause state. + boolean pausing = false; if (mPaused != mRequestPaused) { + pausing = mRequestPaused; mPaused = mRequestPaused; sGLThreadManager.notifyAll(); if (LOG_PAUSE_RESUME) { @@ -1324,12 +1326,16 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback lostEglContext = false; } - // Do we need to release the EGL surface? - if (mHaveEglSurface && mPaused) { + // When pausing, release the EGL surface: + if (pausing && mHaveEglSurface) { if (LOG_SURFACE) { Log.i("GLThread", "releasing EGL surface because paused tid=" + getId()); } stopEglSurfaceLocked(); + } + + // When pausing, optionally release the EGL Context: + if (pausing && mHaveEglContext) { GLSurfaceView view = mGLSurfaceViewWeakRef.get(); boolean preserveEglContextOnPause = view == null ? false : view.mPreserveEGLContextOnPause; @@ -1339,6 +1345,10 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback Log.i("GLThread", "releasing EGL context because paused tid=" + getId()); } } + } + + // When pausing, optionally terminate EGL: + if (pausing) { if (sGLThreadManager.shouldTerminateEGLWhenPausing()) { mEglHelper.finish(); if (LOG_SURFACE) { |