diff options
author | Craig Mautner <cmautner@google.com> | 2012-04-17 11:45:25 -0700 |
---|---|---|
committer | Craig Mautner <cmautner@google.com> | 2012-04-17 11:55:00 -0700 |
commit | acaf9cca865902e6f1823e771f4234bfda53cfd1 (patch) | |
tree | c8cdd65aee8e7ad38b1842ab69a259c7ffeec1c2 | |
parent | 3255a28b6a18bb97f0e533dc1673c5e28837b4f2 (diff) | |
download | frameworks_base-acaf9cca865902e6f1823e771f4234bfda53cfd1.zip frameworks_base-acaf9cca865902e6f1823e771f4234bfda53cfd1.tar.gz frameworks_base-acaf9cca865902e6f1823e771f4234bfda53cfd1.tar.bz2 |
Move Surface operations into existing transaction.
Several Surface operations - notably setPosition, setSize, and show -
had been moved outside of a Surface.openTransaction/closeTransaction
window. This corrects that problem.
In addition, before animations were separated from layout the Surface
frame was computed prior to returning from relayoutWindow(). After
separation the frame was being computed during animation. This checkin
restores the frame calculation in layout.
Fixes bug 6343291.
Change-Id: I4752bdf1fed0f2b46c5eb9508825c9b1b0fd702f
-rw-r--r-- | services/java/com/android/server/wm/WindowManagerService.java | 134 | ||||
-rw-r--r-- | services/java/com/android/server/wm/WindowStateAnimator.java | 45 |
2 files changed, 96 insertions, 83 deletions
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index c712bc9..b8fca61 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -7959,7 +7959,7 @@ public class WindowManagerService extends IWindowManager.Stub Slog.v(TAG, "Resize reasons: " + " contentInsetsChanged=" + w.mContentInsetsChanged + " visibleInsetsChanged=" + w.mVisibleInsetsChanged - + " surfaceResized=" + w.mWinAnimator.mSurfaceResized + + " surfaceResized=" + winAnimator.mSurfaceResized + " configChanged=" + configChanged); } @@ -7974,7 +7974,7 @@ public class WindowManagerService extends IWindowManager.Stub if (w.mOrientationChanging) { if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation start waiting for draw in " - + w + ", surface " + w.mWinAnimator.mSurface); + + w + ", surface " + winAnimator.mSurface); winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING; if (w.mAppToken != null) { w.mAppToken.allDrawn = false; @@ -7982,15 +7982,15 @@ public class WindowManagerService extends IWindowManager.Stub } if (!mResizingWindows.contains(w)) { if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, - "Resizing window " + w + " to " + w.mWinAnimator.mSurfaceW - + "x" + w.mWinAnimator.mSurfaceH); + "Resizing window " + w + " to " + winAnimator.mSurfaceW + + "x" + winAnimator.mSurfaceH); mResizingWindows.add(w); } } else if (w.mOrientationChanging) { if (w.isDrawnLw()) { if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation not waiting for draw in " - + w + ", surface " + w.mWinAnimator.mSurface); + + w + ", surface " + winAnimator.mSurface); w.mOrientationChanging = false; } } @@ -8083,7 +8083,7 @@ public class WindowManagerService extends IWindowManager.Stub updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); } - + // Initialize state of exiting tokens. for (i=mExitingTokens.size()-1; i>=0; i--) { mExitingTokens.get(i).hasVisible = false; @@ -8112,7 +8112,7 @@ public class WindowManagerService extends IWindowManager.Stub try { int repeats = 0; - + do { repeats++; if (repeats > 6) { @@ -8172,7 +8172,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mObscured = false; mInnerFields.mDimming = false; mInnerFields.mSyswin = false; - + boolean focusDisplayed = false; final int N = mWindows.size(); for (i=N-1; i>=0; i--) { @@ -8196,7 +8196,52 @@ public class WindowManagerService extends IWindowManager.Stub // has been updated accordingly. updateWallpaperVisibilityLocked(); } + + final WindowStateAnimator winAnimator = w.mWinAnimator; + + // If the window has moved due to its containing + // content frame changing, then we'd like to animate + // it. + if (w.mHasSurface && w.shouldAnimateMove()) { + // Frame has moved, containing content frame + // has also moved, and we're not currently animating... + // let's do something. + Animation a = AnimationUtils.loadAnimation(mContext, + com.android.internal.R.anim.window_move_from_decor); + winAnimator.setAnimation(a); + winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left; + winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top; + } else { + winAnimator.mAnimDw = innerDw; + winAnimator.mAnimDh = innerDh; + } + + //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing"); + w.mContentChanged = false; + + // Moved from updateWindowsAndWallpaperLocked(). + if (w.mHasSurface) { + // Take care of the window being ready to display. + if (winAnimator.commitFinishDrawingLocked(currentTime)) { + if ((w.mAttrs.flags + & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) { + if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG, + "First draw done in potential wallpaper target " + w); + mInnerFields.mWallpaperMayChange = true; + mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; + if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { + debugLayoutRepeats("updateWindowsAndWallpaperLocked 1", + mPendingLayoutChanges); + } + } + } + + winAnimator.setSurfaceBoundaries(recoveringMemory); + } + + updateResizingWindows(w); } + if (focusDisplayed) { mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS); } @@ -8278,68 +8323,10 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded", mPendingLayoutChanges); } - final int N = mWindows.size(); - for (i=N-1; i>=0; i--) { - final WindowState w = mWindows.get(i); - final WindowStateAnimator winAnimator = w.mWinAnimator; - - // If the window has moved due to its containing - // content frame changing, then we'd like to animate - // it. - if (w.mHasSurface && w.shouldAnimateMove()) { - // Frame has moved, containing content frame - // has also moved, and we're not currently animating... - // let's do something. - Animation a = AnimationUtils.loadAnimation(mContext, - com.android.internal.R.anim.window_move_from_decor); - winAnimator.setAnimation(a); - winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left; - winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top; - } else { - winAnimator.mAnimDw = innerDw; - winAnimator.mAnimDh = innerDh; - } - - //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing"); - w.mContentChanged = false; - - // TODO(cmautner): Can this move up to the loop at the end of try/catch above? - updateResizingWindows(w); - - // Moved from updateWindowsAndWallpaperLocked(). - if (w.mHasSurface) { - // Take care of the window being ready to display. - if (winAnimator.commitFinishDrawingLocked(currentTime)) { - if ((w.mAttrs.flags - & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) { - if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG, - "First draw done in potential wallpaper target " + w); - mInnerFields.mWallpaperMayChange = true; - mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; - if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { - debugLayoutRepeats("updateWindowsAndWallpaperLocked 1", - mPendingLayoutChanges); - } - } - } - } - } - - if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG, - "With display frozen, orientationChangeComplete=" - + mInnerFields.mOrientationChangeComplete); - if (mInnerFields.mOrientationChangeComplete) { - if (mWindowsFreezingScreen) { - mWindowsFreezingScreen = false; - mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT); - } - stopFreezingDisplayLocked(); - } - if (!mResizingWindows.isEmpty()) { for (i = mResizingWindows.size() - 1; i >= 0; i--) { WindowState win = mResizingWindows.get(i); - final WindowStateAnimator winAnimator = win.mWinAnimator; + final WindowStateAnimator winAnimator = win.mWinAnimator; try { if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + win + ": " + win.mCompatFrame); @@ -8358,7 +8345,7 @@ public class WindowManagerService extends IWindowManager.Stub win.mConfiguration = mCurConfiguration; if (DEBUG_ORIENTATION && winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i( - TAG, "Resizing " + win + " WITH DRAW PENDING"); + TAG, "Resizing " + win + " WITH DRAW PENDING"); win.mClient.resized((int)winAnimator.mSurfaceW, (int)winAnimator.mSurfaceH, win.mLastContentInsets, win.mLastVisibleInsets, @@ -8374,6 +8361,17 @@ public class WindowManagerService extends IWindowManager.Stub mResizingWindows.clear(); } + if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG, + "With display frozen, orientationChangeComplete=" + + mInnerFields.mOrientationChangeComplete); + if (mInnerFields.mOrientationChangeComplete) { + if (mWindowsFreezingScreen) { + mWindowsFreezingScreen = false; + mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT); + } + stopFreezingDisplayLocked(); + } + // Destroy the surface of any windows that are no longer visible. boolean wallpaperDestroyed = false; i = mDestroySurface.size(); diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 90b63a6..b61ccbf 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -499,6 +499,14 @@ class WindowStateAnimator { sSurfaces.remove(this); } + @Override + public void release() { + super.release(); + Slog.v(SURFACE_TAG, "release: " + this + ". Called by " + + WindowManagerService.getCallers(3)); + sSurfaces.remove(this); + } + static void dumpAllSurfaces() { final int N = sSurfaces.size(); for (int i = 0; i < N; i++) { @@ -886,22 +894,8 @@ class WindowStateAnimator { mDtDy = mWin.mGlobalScale; } - public void prepareSurfaceLocked(final boolean recoveringMemory) { + void setSurfaceBoundaries(final boolean recoveringMemory) { final WindowState w = mWin; - if (mSurface == null) { - if (w.mOrientationChanging) { - if (DEBUG_ORIENTATION) { - Slog.v(TAG, "Orientation change skips hidden " + w); - } - w.mOrientationChanging = false; - } - return; - } - - boolean displayed = false; - - computeShownFrameLocked(); - int width, height; if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { // for a scaled surface, we just want to use @@ -950,6 +944,8 @@ class WindowStateAnimator { "SIZE " + width + "x" + height, null); mSurfaceResized = true; mSurface.setSize(width, height); + mAnimator.mPendingLayoutChanges |= + WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; } catch (RuntimeException e) { // If something goes wrong with the surface (such // as running out of memory), don't take down the @@ -961,6 +957,25 @@ class WindowStateAnimator { } } } + } + + public void prepareSurfaceLocked(final boolean recoveringMemory) { + final WindowState w = mWin; + if (mSurface == null) { + if (w.mOrientationChanging) { + if (DEBUG_ORIENTATION) { + Slog.v(TAG, "Orientation change skips hidden " + w); + } + w.mOrientationChanging = false; + } + return; + } + + boolean displayed = false; + + computeShownFrameLocked(); + + setSurfaceBoundaries(recoveringMemory); if (w.mAttachedHidden || !w.isReadyForDisplay()) { if (!mLastHidden) { |