Reduce computing unused ChangeInfo in Transition
Originally, if the window container can not be animated or controlled by remote, the intermediate ChangeInfo are just ignored during calculating TransitionInfo. So they can be skipped earlier at creation. For example when launching an activity in a task, there may be 10 ChangeInfo: 2 activities + Task + TaskDisplayArea + Display + 5 DisplayArea. With this change, the 5 DisplayArea will be ignored (if their organizers are not active): Root, WindowedMagnification, HideDisplayCutout, OneHanded, and FullscreenMagnification. Then in collect(), it no longer needs to traverse 30+ DisplayArea for creating the intermediate parent ChangeInfo. That would also speed up calculateTargets and calculateTransitionInfo because less ChangeInfo to look up. Also simplify getTopVisibleWallpaper (called in collect()) a bit by eliminating unnecessary overhead of forAllWindows. Bug: 260059642 Test: atest TransitionTests Change-Id: I15f3ccd5af2fe70f71c88d6d8676661c312aef2e
This commit is contained in:
@@ -341,7 +341,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
||||
if (childArea == null) {
|
||||
continue;
|
||||
}
|
||||
pw.println(prefix + "* " + childArea.getName());
|
||||
pw.print(prefix + "* " + childArea.getName());
|
||||
if (childArea.isOrganized()) {
|
||||
pw.print(" (organized)");
|
||||
}
|
||||
pw.println();
|
||||
if (childArea.isTaskDisplayArea()) {
|
||||
// TaskDisplayArea can only contain task. And it is already printed by display.
|
||||
continue;
|
||||
|
||||
@@ -3458,9 +3458,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
|
||||
super.dump(pw, prefix, dumpAll);
|
||||
pw.print(prefix);
|
||||
pw.println("Display: mDisplayId=" + mDisplayId + " rootTasks=" + getRootTaskCount());
|
||||
pw.println("Display: mDisplayId=" + mDisplayId + (isOrganized() ? " (organized)" : ""));
|
||||
final String subPrefix = " " + prefix;
|
||||
pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
|
||||
pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
|
||||
@@ -3491,6 +3490,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
pw.println(" mTouchExcludeRegion=" + mTouchExcludeRegion);
|
||||
|
||||
pw.println();
|
||||
super.dump(pw, prefix, dumpAll);
|
||||
pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq);
|
||||
|
||||
pw.print(" mCurrentFocus="); pw.println(mCurrentFocus);
|
||||
@@ -3582,6 +3582,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
pw.println();
|
||||
mInsetsStateController.dump(prefix, pw);
|
||||
mDwpcHelper.dump(prefix, pw);
|
||||
pw.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3457,7 +3457,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
||||
final DisplayContent display = getChildAt(i);
|
||||
display.dump(pw, prefix, dumpAll);
|
||||
}
|
||||
pw.println();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,9 +165,9 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
private SurfaceControl.Transaction mFinishTransaction = null;
|
||||
|
||||
/**
|
||||
* Contains change infos for both participants and all ancestors. We have to track ancestors
|
||||
* because they are all promotion candidates and thus we need their start-states
|
||||
* to be captured.
|
||||
* Contains change infos for both participants and all remote-animatable ancestors. The
|
||||
* ancestors can be the promotion candidates so their start-states need to be captured.
|
||||
* @see #getAnimatableParent
|
||||
*/
|
||||
final ArrayMap<WindowContainer, ChangeInfo> mChanges = new ArrayMap<>();
|
||||
|
||||
@@ -399,8 +399,9 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
mSyncId, wc);
|
||||
// "snapshot" all parents (as potential promotion targets). Do this before checking
|
||||
// if this is already a participant in case it has since been re-parented.
|
||||
for (WindowContainer curr = wc.getParent(); curr != null && !mChanges.containsKey(curr);
|
||||
curr = curr.getParent()) {
|
||||
for (WindowContainer<?> curr = getAnimatableParent(wc);
|
||||
curr != null && !mChanges.containsKey(curr);
|
||||
curr = getAnimatableParent(curr)) {
|
||||
mChanges.put(curr, new ChangeInfo(curr));
|
||||
if (isReadyGroup(curr)) {
|
||||
mReadyTracker.addGroup(curr);
|
||||
@@ -1269,6 +1270,16 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Returns the parent that the remote animator can animate or control. */
|
||||
private static WindowContainer<?> getAnimatableParent(WindowContainer<?> wc) {
|
||||
WindowContainer<?> parent = wc.getParent();
|
||||
while (parent != null
|
||||
&& (!parent.canCreateRemoteAnimationTarget() && !parent.isOrganized())) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
private static boolean reportIfNotTop(WindowContainer wc) {
|
||||
// Organized tasks need to be reported anyways because Core won't show() their surfaces
|
||||
// and we can't rely on onTaskAppeared because it isn't in sync.
|
||||
@@ -1492,7 +1503,8 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
intermediates.clear();
|
||||
boolean foundParentInTargets = false;
|
||||
// Collect the intermediate parents between target and top changed parent.
|
||||
for (WindowContainer<?> p = wc.getParent(); p != null; p = p.getParent()) {
|
||||
for (WindowContainer<?> p = getAnimatableParent(wc); p != null;
|
||||
p = getAnimatableParent(p)) {
|
||||
final ChangeInfo parentChange = changes.get(p);
|
||||
if (parentChange == null || !parentChange.hasChanged(p)) break;
|
||||
if (p.mRemoteToken == null) {
|
||||
|
||||
@@ -113,12 +113,6 @@ class WallpaperController {
|
||||
|
||||
private boolean mShouldUpdateZoom;
|
||||
|
||||
/**
|
||||
* Temporary storage for taking a screenshot of the wallpaper.
|
||||
* @see #screenshotWallpaperLocked()
|
||||
*/
|
||||
private WindowState mTmpTopWallpaper;
|
||||
|
||||
@Nullable private Point mLargestDisplaySize = null;
|
||||
|
||||
private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult();
|
||||
@@ -962,21 +956,16 @@ class WallpaperController {
|
||||
}
|
||||
|
||||
WindowState getTopVisibleWallpaper() {
|
||||
mTmpTopWallpaper = null;
|
||||
|
||||
for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
|
||||
final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
|
||||
token.forAllWindows(w -> {
|
||||
final WindowStateAnimator winAnim = w.mWinAnimator;
|
||||
if (winAnim != null && winAnim.getShown() && winAnim.mLastAlpha > 0f) {
|
||||
mTmpTopWallpaper = w;
|
||||
return true;
|
||||
for (int i = token.getChildCount() - 1; i >= 0; i--) {
|
||||
final WindowState w = token.getChildAt(i);
|
||||
if (w.mWinAnimator.getShown() && w.mWinAnimator.mLastAlpha > 0f) {
|
||||
return w;
|
||||
}
|
||||
return false;
|
||||
}, true /* traverseTopToBottom */);
|
||||
}
|
||||
}
|
||||
|
||||
return mTmpTopWallpaper;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -476,6 +476,8 @@ public class TransitionTests extends WindowTestsBase {
|
||||
wallpaperWindow.mHasSurface = true;
|
||||
doReturn(true).when(mDisplayContent).isAttached();
|
||||
transition.collect(mDisplayContent);
|
||||
assertFalse("The change of non-interesting window container should be skipped",
|
||||
transition.mChanges.containsKey(mDisplayContent.getParent()));
|
||||
mDisplayContent.getWindowConfiguration().setRotation(
|
||||
(mDisplayContent.getWindowConfiguration().getRotation() + 1) % 4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user