diff options
| author | 2017-03-22 20:26:36 +0000 | |
|---|---|---|
| committer | 2017-03-22 20:26:40 +0000 | |
| commit | fcc79f5474fb00d6ecdbe7303bf96e47124d415c (patch) | |
| tree | 1241b8ff4460fbbd2a6888bad5fb1b998f2213b9 | |
| parent | dddc8fd1940ddba82c2d153d537b94ca4814dc5c (diff) | |
| parent | 3bc95b5b712c44c687ef04156b63c70c930f69f2 (diff) | |
Merge "SurfaceView: Fix Surface leak when changing format."
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index f559d42b6f55..e59073999683 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -114,6 +114,9 @@ public class SurfaceView extends View { SurfaceSession mSurfaceSession; SurfaceControl mSurfaceControl; + // In the case of format changes we switch out the surface in-place + // we need to preserve the old one until the new one has drawn. + SurfaceControl mDeferredDestroySurfaceControl; final Rect mTmpRect = new Rect(); final Configuration mConfiguration = new Configuration(); @@ -475,6 +478,7 @@ public class SurfaceView extends View { if (creating) { mSurfaceSession = new SurfaceSession(viewRoot.mSurface); + mDeferredDestroySurfaceControl = mSurfaceControl; mSurfaceControl = new SurfaceControl(mSurfaceSession, "SurfaceView - " + viewRoot.getTitle().toString(), mSurfaceWidth, mSurfaceHeight, mFormat, @@ -676,6 +680,12 @@ public class SurfaceView extends View { Log.i(TAG, System.identityHashCode(this) + " " + "finishedDrawing"); } + + if (mDeferredDestroySurfaceControl != null) { + mDeferredDestroySurfaceControl.destroy(); + mDeferredDestroySurfaceControl = null; + } + mHandler.sendEmptyMessage(DRAW_FINISHED_MSG); } |