Lock free app animations (1/n): Get rid of mAllAppWindowAnimators

Test: go/wm-smoke
Bug: 64674361
Change-Id: If3d888184c99f9c43dd0dcb5455158e1dbca81c2
This commit is contained in:
Jorim Jaggi
2017-10-24 18:05:26 +02:00
parent 44643c1a50
commit 94c38c5671
3 changed files with 9 additions and 43 deletions

View File

@@ -100,9 +100,6 @@ public class AppWindowAnimator {
private int mTransit;
private int mTransitFlags;
/** WindowStateAnimator from mAppAnimator.allAppWindows as of last performLayout */
ArrayList<WindowStateAnimator> mAllAppWinAnimators = new ArrayList<>();
/** True if the current animation was transferred from another AppWindowAnimator.
* See {@link #transferCurrentAnimation}*/
boolean usingTransferredAnimation = false;
@@ -239,8 +236,6 @@ public class AppWindowAnimator {
toAppAnimator.mTransit = mTransit;
}
if (transferWinAnimator != null) {
mAllAppWinAnimators.remove(transferWinAnimator);
toAppAnimator.mAllAppWinAnimators.add(transferWinAnimator);
toAppAnimator.hasTransformation = transferWinAnimator.mAppAnimator.hasTransformation;
if (toAppAnimator.hasTransformation) {
toAppAnimator.transformation.set(transferWinAnimator.mAppAnimator.transformation);
@@ -417,25 +412,17 @@ public class AppWindowAnimator {
transformation.clear();
final int numAllAppWinAnimators = mAllAppWinAnimators.size();
for (int i = 0; i < numAllAppWinAnimators; i++) {
mAllAppWinAnimators.get(i).mWin.onExitAnimationDone();
}
mAppToken.forAllWindows(WindowState::onExitAnimationDone, false /* traverseTopToBottom */);
mService.mAppTransition.notifyAppTransitionFinishedLocked(mAppToken.token);
return false;
}
// This must be called while inside a transaction.
boolean showAllWindowsLocked() {
boolean isAnimating = false;
final int NW = mAllAppWinAnimators.size();
for (int i=0; i<NW; i++) {
WindowStateAnimator winAnimator = mAllAppWinAnimators.get(i);
if (DEBUG_VISIBILITY) Slog.v(TAG, "performing show on: " + winAnimator);
winAnimator.mWin.performShowLocked();
isAnimating |= winAnimator.isAnimationSet();
}
return isAnimating;
void showAllWindowsLocked() {
mAppToken.forAllWindows(windowState -> {
if (DEBUG_VISIBILITY) Slog.v(TAG, "performing show on: " + windowState);
windowState.performShowLocked();
}, false /* traverseTopToBottom */);
}
void dump(PrintWriter pw, String prefix) {
@@ -466,11 +453,6 @@ public class AppWindowAnimator {
pw.print(prefix); pw.print("thumbnailTransformation=");
pw.println(thumbnailTransformation.toShortString());
}
for (int i=0; i<mAllAppWinAnimators.size(); i++) {
WindowStateAnimator wanim = mAllAppWinAnimators.get(i);
pw.print(prefix); pw.print("App Win Anim #"); pw.print(i);
pw.print(": "); pw.println(wanim);
}
}
void startProlongAnimation(int prolongType) {

View File

@@ -1160,16 +1160,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
return mChildren.size() == 1 && mChildren.get(0) == win;
}
void setAllAppWinAnimators() {
final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators;
allAppWinAnimators.clear();
final int windowsCount = mChildren.size();
for (int j = 0; j < windowsCount; j++) {
(mChildren.get(j)).addWinAnimatorToList(allAppWinAnimators);
}
}
@Override
void onAppTransitionDone() {
sendingToBottom = false;
@@ -1230,7 +1220,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
// We can now show all of the drawn windows!
if (!mService.mOpeningApps.contains(this)) {
mService.mAnimator.orAnimating(mAppAnimator.showAllWindowsLocked());
mAppAnimator.showAllWindowsLocked();
}
}
}

View File

@@ -421,13 +421,12 @@ class WindowSurfacePlacer {
}
wtoken.updateReportedVisibilityLocked();
wtoken.waitingToShow = false;
wtoken.setAllAppWinAnimators();
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
">>> OPEN TRANSACTION handleAppTransitionReadyLocked()");
mService.openSurfaceTransaction();
try {
mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked());
appAnimator.showAllWindowsLocked();
} finally {
mService.closeSurfaceTransaction("handleAppTransitionReadyLocked");
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
@@ -462,12 +461,8 @@ class WindowSurfacePlacer {
appAnimator.setNullAnimation();
// TODO: Do we need to add to mNoAnimationNotifyOnTransitionFinished like above if not
// animating?
wtoken.setAllAppWinAnimators();
wtoken.setVisibility(animLp, false, transit, false, voiceInteraction);
wtoken.updateReportedVisibilityLocked();
// setAllAppWinAnimators so the windows get onExitAnimationDone once the animation is
// done.
wtoken.setAllAppWinAnimators();
// Force the allDrawn flag, because we want to start
// this guy's animations regardless of whether it's
// gotten drawn.
@@ -673,9 +668,8 @@ class WindowSurfacePlacer {
appAnimator.setNullAnimation();
mService.updateTokenInPlaceLocked(wtoken, transit);
wtoken.updateReportedVisibilityLocked();
wtoken.setAllAppWinAnimators();
mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating();
mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked());
appAnimator.showAllWindowsLocked();
}
}
}