Merge "Reduce computing unused ChangeInfo in Transition" into tm-qpr-dev am: 3696021485

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20562400

Change-Id: Ide3519188537ac7be4f021dcf11083672d19a307
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Riddle Hsu
2022-11-30 17:25:12 +00:00
committed by Automerger Merge Worker
6 changed files with 34 additions and 27 deletions

View File

@@ -343,7 +343,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
if (childArea == null) { if (childArea == null) {
continue; continue;
} }
pw.println(prefix + "* " + childArea.getName()); pw.print(prefix + "* " + childArea.getName());
if (childArea.isOrganized()) {
pw.print(" (organized)");
}
pw.println();
if (childArea.isTaskDisplayArea()) { if (childArea.isTaskDisplayArea()) {
// TaskDisplayArea can only contain task. And it is already printed by display. // TaskDisplayArea can only contain task. And it is already printed by display.
continue; continue;

View File

@@ -3458,9 +3458,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
@Override @Override
public void dump(PrintWriter pw, String prefix, boolean dumpAll) { public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
super.dump(pw, prefix, dumpAll);
pw.print(prefix); pw.print(prefix);
pw.println("Display: mDisplayId=" + mDisplayId + " rootTasks=" + getRootTaskCount()); pw.println("Display: mDisplayId=" + mDisplayId + (isOrganized() ? " (organized)" : ""));
final String subPrefix = " " + prefix; final String subPrefix = " " + prefix;
pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x"); pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity); 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(" mTouchExcludeRegion=" + mTouchExcludeRegion);
pw.println(); pw.println();
super.dump(pw, prefix, dumpAll);
pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq); pw.print(prefix); pw.print("mLayoutSeq="); pw.println(mLayoutSeq);
pw.print(" mCurrentFocus="); pw.println(mCurrentFocus); pw.print(" mCurrentFocus="); pw.println(mCurrentFocus);
@@ -3582,6 +3582,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
pw.println(); pw.println();
mInsetsStateController.dump(prefix, pw); mInsetsStateController.dump(prefix, pw);
mDwpcHelper.dump(prefix, pw); mDwpcHelper.dump(prefix, pw);
pw.println();
} }
@Override @Override

View File

@@ -3457,7 +3457,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
final DisplayContent display = getChildAt(i); final DisplayContent display = getChildAt(i);
display.dump(pw, prefix, dumpAll); display.dump(pw, prefix, dumpAll);
} }
pw.println();
} }
/** /**

View File

@@ -167,9 +167,9 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
private SurfaceControl.Transaction mFinishTransaction = null; private SurfaceControl.Transaction mFinishTransaction = null;
/** /**
* Contains change infos for both participants and all ancestors. We have to track ancestors * Contains change infos for both participants and all remote-animatable ancestors. The
* because they are all promotion candidates and thus we need their start-states * ancestors can be the promotion candidates so their start-states need to be captured.
* to be captured. * @see #getAnimatableParent
*/ */
final ArrayMap<WindowContainer, ChangeInfo> mChanges = new ArrayMap<>(); final ArrayMap<WindowContainer, ChangeInfo> mChanges = new ArrayMap<>();
@@ -417,8 +417,9 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
mSyncId, wc); mSyncId, wc);
// "snapshot" all parents (as potential promotion targets). Do this before checking // "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. // if this is already a participant in case it has since been re-parented.
for (WindowContainer curr = wc.getParent(); curr != null && !mChanges.containsKey(curr); for (WindowContainer<?> curr = getAnimatableParent(wc);
curr = curr.getParent()) { curr != null && !mChanges.containsKey(curr);
curr = getAnimatableParent(curr)) {
mChanges.put(curr, new ChangeInfo(curr)); mChanges.put(curr, new ChangeInfo(curr));
if (isReadyGroup(curr)) { if (isReadyGroup(curr)) {
mReadyTracker.addGroup(curr); mReadyTracker.addGroup(curr);
@@ -1299,6 +1300,16 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
return sb.toString(); 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) { private static boolean reportIfNotTop(WindowContainer wc) {
// Organized tasks need to be reported anyways because Core won't show() their surfaces // 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. // and we can't rely on onTaskAppeared because it isn't in sync.
@@ -1522,7 +1533,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
intermediates.clear(); intermediates.clear();
boolean foundParentInTargets = false; boolean foundParentInTargets = false;
// Collect the intermediate parents between target and top changed parent. // 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); final ChangeInfo parentChange = changes.get(p);
if (parentChange == null || !parentChange.hasChanged(p)) break; if (parentChange == null || !parentChange.hasChanged(p)) break;
if (p.mRemoteToken == null) { if (p.mRemoteToken == null) {

View File

@@ -113,12 +113,6 @@ class WallpaperController {
private boolean mShouldUpdateZoom; private boolean mShouldUpdateZoom;
/**
* Temporary storage for taking a screenshot of the wallpaper.
* @see #screenshotWallpaperLocked()
*/
private WindowState mTmpTopWallpaper;
@Nullable private Point mLargestDisplaySize = null; @Nullable private Point mLargestDisplaySize = null;
private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult(); private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult();
@@ -962,21 +956,16 @@ class WallpaperController {
} }
WindowState getTopVisibleWallpaper() { WindowState getTopVisibleWallpaper() {
mTmpTopWallpaper = null;
for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) { for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx); final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
token.forAllWindows(w -> { for (int i = token.getChildCount() - 1; i >= 0; i--) {
final WindowStateAnimator winAnim = w.mWinAnimator; final WindowState w = token.getChildAt(i);
if (winAnim != null && winAnim.getShown() && winAnim.mLastAlpha > 0f) { if (w.mWinAnimator.getShown() && w.mWinAnimator.mLastAlpha > 0f) {
mTmpTopWallpaper = w; return w;
return true;
} }
return false; }
}, true /* traverseTopToBottom */);
} }
return null;
return mTmpTopWallpaper;
} }
/** /**

View File

@@ -476,6 +476,8 @@ public class TransitionTests extends WindowTestsBase {
wallpaperWindow.mHasSurface = true; wallpaperWindow.mHasSurface = true;
doReturn(true).when(mDisplayContent).isAttached(); doReturn(true).when(mDisplayContent).isAttached();
transition.collect(mDisplayContent); transition.collect(mDisplayContent);
assertFalse("The change of non-interesting window container should be skipped",
transition.mChanges.containsKey(mDisplayContent.getParent()));
mDisplayContent.getWindowConfiguration().setRotation( mDisplayContent.getWindowConfiguration().setRotation(
(mDisplayContent.getWindowConfiguration().getRotation() + 1) % 4); (mDisplayContent.getWindowConfiguration().getRotation() + 1) % 4);