Do not clear AppWindowToken.allDrawn while animating.

Creating new surfaces for applications clears the allDrawn flag in the
AppWindowToken. If the app windows were animating when this happened
the animation would complete immediately resulting in jank. This fix
defers clearing allDrawn until the animation completes.

Bug 7326635 fixed.

Change-Id: I5abe3b9ecfbefb476de6a6c8acc394373cc11751
This commit is contained in:
Craig Mautner
2012-11-16 15:24:11 -08:00
parent dc0b84b129
commit 7636dfbc33
4 changed files with 19 additions and 1 deletions

View File

@@ -100,6 +100,10 @@ public class AppWindowAnimator {
animInitialized = false; animInitialized = false;
} }
clearThumbnail(); clearThumbnail();
if (mAppToken.deferClearAllDrawn) {
mAppToken.allDrawn = false;
mAppToken.deferClearAllDrawn = false;
}
} }
public void clearThumbnail() { public void clearThumbnail() {

View File

@@ -64,6 +64,9 @@ class AppWindowToken extends WindowToken {
int numDrawnWindows; int numDrawnWindows;
boolean inPendingTransaction; boolean inPendingTransaction;
boolean allDrawn; boolean allDrawn;
// Set to true when this app creates a surface while in the middle of an animation. In that
// case do not clear allDrawn until the animation completes.
boolean deferClearAllDrawn;
// Is this token going to be hidden in a little while? If so, it // Is this token going to be hidden in a little while? If so, it
// won't be taken into account for setting the screen orientation. // won't be taken into account for setting the screen orientation.

View File

@@ -4295,6 +4295,7 @@ public class WindowManagerService extends IWindowManager.Stub
// the new one. // the new one.
if (ttoken.allDrawn) { if (ttoken.allDrawn) {
wtoken.allDrawn = true; wtoken.allDrawn = true;
wtoken.deferClearAllDrawn = ttoken.deferClearAllDrawn;
} }
if (ttoken.firstWindowDrawn) { if (ttoken.firstWindowDrawn) {
wtoken.firstWindowDrawn = true; wtoken.firstWindowDrawn = true;
@@ -4602,6 +4603,7 @@ public class WindowManagerService extends IWindowManager.Stub
// its windows to be ready. // its windows to be ready.
if (wtoken.hidden) { if (wtoken.hidden) {
wtoken.allDrawn = false; wtoken.allDrawn = false;
wtoken.deferClearAllDrawn = false;
wtoken.waitingToShow = true; wtoken.waitingToShow = true;
if (wtoken.clientHidden) { if (wtoken.clientHidden) {
@@ -8708,6 +8710,7 @@ public class WindowManagerService extends IWindowManager.Stub
// this guy's animations regardless of whether it's // this guy's animations regardless of whether it's
// gotten drawn. // gotten drawn.
wtoken.allDrawn = true; wtoken.allDrawn = true;
wtoken.deferClearAllDrawn = false;
} }
if (mNextAppTransitionThumbnail != null && topOpeningApp != null if (mNextAppTransitionThumbnail != null && topOpeningApp != null
@@ -8878,6 +8881,7 @@ public class WindowManagerService extends IWindowManager.Stub
winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING; winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
if (w.mAppToken != null) { if (w.mAppToken != null) {
w.mAppToken.allDrawn = false; w.mAppToken.allDrawn = false;
w.mAppToken.deferClearAllDrawn = false;
} }
} }
if (!mResizingWindows.contains(w)) { if (!mResizingWindows.contains(w)) {

View File

@@ -626,7 +626,14 @@ class WindowStateAnimator {
"createSurface " + this + ": mDrawState=DRAW_PENDING"); "createSurface " + this + ": mDrawState=DRAW_PENDING");
mDrawState = DRAW_PENDING; mDrawState = DRAW_PENDING;
if (mWin.mAppToken != null) { if (mWin.mAppToken != null) {
mWin.mAppToken.allDrawn = false; if (mWin.mAppToken.mAppAnimator.animation == null) {
mWin.mAppToken.allDrawn = false;
mWin.mAppToken.deferClearAllDrawn = false;
} else {
// Currently animating, persist current state of allDrawn until animation
// is complete.
mWin.mAppToken.deferClearAllDrawn = true;
}
} }
mService.makeWindowFreezingScreenIfNeededLocked(mWin); mService.makeWindowFreezingScreenIfNeededLocked(mWin);