diff options
Diffstat (limited to 'services/java/com/android/server/wm/WindowState.java')
| -rw-r--r-- | services/java/com/android/server/wm/WindowState.java | 74 |
1 files changed, 66 insertions, 8 deletions
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 23ec2d9..aa7bf2d 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -85,6 +85,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { boolean mPolicyVisibilityAfterAnim = true; boolean mAppFreezing; Surface mSurface; + Surface mPendingDestroySurface; boolean mReportDestroySurface; boolean mSurfacePendingDestroy; boolean mAttachedHidden; // is our parent window hidden? @@ -121,7 +122,13 @@ final class WindowState implements WindowManagerPolicy.WindowState { * we must tell them application to resize (and thus redraw itself). */ boolean mSurfaceResized; - + + /** + * Set if the client has asked that the destroy of its surface be delayed + * until it explicitly says it is okay. + */ + boolean mSurfaceDestroyDeferred; + /** * Insets that determine the actually visible area. These are in the application's * coordinate space (without compatibility scale applied). @@ -764,15 +771,32 @@ final class WindowState implements WindowManagerPolicy.WindowState { Slog.w(WindowManagerService.TAG, "Window " + this + " destroying surface " + mSurface + ", session " + mSession, e); } - if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { - RuntimeException e = null; - if (!WindowManagerService.HIDE_STACK_CRAWLS) { - e = new RuntimeException(); - e.fillInStackTrace(); + if (mSurfaceDestroyDeferred) { + if (mSurface != null && mPendingDestroySurface != mSurface) { + if (mPendingDestroySurface != null) { + if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { + RuntimeException e = null; + if (!WindowManagerService.HIDE_STACK_CRAWLS) { + e = new RuntimeException(); + e.fillInStackTrace(); + } + WindowManagerService.logSurface(this, "DESTROY PENDING", e); + } + mPendingDestroySurface.destroy(); + } + mPendingDestroySurface = mSurface; } - WindowManagerService.logSurface(this, "DESTROY", e); + } else { + if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { + RuntimeException e = null; + if (!WindowManagerService.HIDE_STACK_CRAWLS) { + e = new RuntimeException(); + e.fillInStackTrace(); + } + WindowManagerService.logSurface(this, "DESTROY", e); + } + mSurface.destroy(); } - mSurface.destroy(); } catch (RuntimeException e) { Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window " + this + " surface " + mSurface + " session " + mSession @@ -784,6 +808,28 @@ final class WindowState implements WindowManagerPolicy.WindowState { } } + void destroyDeferredSurfaceLocked() { + try { + if (mPendingDestroySurface != null) { + if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { + RuntimeException e = null; + if (!WindowManagerService.HIDE_STACK_CRAWLS) { + e = new RuntimeException(); + e.fillInStackTrace(); + } + mService.logSurface(this, "DESTROY PENDING", e); + } + mPendingDestroySurface.destroy(); + } + } catch (RuntimeException e) { + Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window " + + this + " surface " + mPendingDestroySurface + + " session " + mSession + ": " + e.toString()); + } + mSurfaceDestroyDeferred = false; + mPendingDestroySurface = null; + } + boolean finishDrawingLocked() { if (mDrawPending) { if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v( @@ -977,6 +1023,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { mAnimation.cancel(); mAnimation = null; } + if (mService.mWindowDetachedWallpaper == this) { + mService.mWindowDetachedWallpaper = null; + } mAnimLayer = mLayer; if (mIsImWindow) { mAnimLayer += mService.mInputMethodAnimLayerAdjustment; @@ -1415,6 +1464,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(WindowManagerService.TAG, "Removing " + this + " from " + mAttachedWindow); mAttachedWindow.mChildWindows.remove(this); } + destroyDeferredSurfaceLocked(); destroySurfaceLocked(); mSession.windowRemovedLocked(); try { @@ -1612,6 +1662,10 @@ final class WindowState implements WindowManagerPolicy.WindowState { pw.print(") "); pw.print(mSurfaceW); pw.print(" x "); pw.println(mSurfaceH); } + if (mPendingDestroySurface != null) { + pw.print(prefix); pw.print("mPendingDestroySurface="); + pw.println(mPendingDestroySurface); + } if (dumpAll) { pw.print(prefix); pw.print("mToken="); pw.println(mToken); pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); @@ -1640,6 +1694,10 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (!mRelayoutCalled) { pw.print(prefix); pw.print("mRelayoutCalled="); pw.println(mRelayoutCalled); } + if (mSurfaceResized || mSurfaceDestroyDeferred) { + pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized); + pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred); + } if (mXOffset != 0 || mYOffset != 0) { pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); pw.print(" y="); pw.println(mYOffset); |
