Only run layout if we didn't have content

Otherwise we really don't have to do it as showing the window will
not change whether we have content or not.

Test: Reopen app, ensure less layout runs
Test: Launch activity on virtual display.

Bug: 115577618
Bug: 112824998
Bug: 10154780

Change-Id: Id3bea85c93ead5e59f0456a2901378dd2c4a836f
Merged-In: Id3bea85c93ead5e59f0456a2901378dd2c4a836f
This commit is contained in:
Jorim Jaggi
2018-09-10 11:58:13 +02:00
parent 98d747e7f3
commit 83d6a5ed8b
2 changed files with 23 additions and 10 deletions

View File

@@ -400,6 +400,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
private MagnificationSpec mMagnificationSpec;
/** Caches the value whether told display manager that we have content. */
private boolean mLastHasContent;
private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
WindowStateAnimator winAnimator = w.mWinAnimator;
final AppWindowToken atoken = w.mAppToken;
@@ -2916,8 +2919,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
forAllWindows(mApplySurfaceChangesTransaction, true /* traverseTopToBottom */);
prepareSurfaces();
mLastHasContent = mTmpApplySurfaceChangesTransactionState.displayHasContent;
mService.mDisplayManagerInternal.setDisplayProperties(mDisplayId,
mTmpApplySurfaceChangesTransactionState.displayHasContent,
mLastHasContent,
mTmpApplySurfaceChangesTransactionState.preferredRefreshRate,
mTmpApplySurfaceChangesTransactionState.preferredModeId,
true /* inTraversal, must call performTraversalInTrans... below */);
@@ -4052,4 +4056,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
private boolean canUpdateImeTarget() {
return mDeferUpdateImeTargetCount == 0;
}
/**
* @return Cached value whether we told display manager that we have content.
*/
boolean getLastHasContent() {
return mLastHasContent;
}
}

View File

@@ -1185,15 +1185,17 @@ class WindowStateAnimator {
if (mIsWallpaper) {
w.dispatchWallpaperVisibility(true);
}
// This draw means the difference between unique content and mirroring.
// Run another pass through performLayout to set mHasContent in the
// LogicalDisplay.
mAnimator.setPendingLayoutChanges(w.getDisplayId(),
FINISH_LAYOUT_REDO_ANIM);
if (DEBUG_LAYOUT_REPEATS) {
mService.mWindowPlacerLocked.debugLayoutRepeats(
"showSurfaceRobustlyLocked " + w,
mAnimator.getPendingLayoutChanges(w.getDisplayId()));
if (!w.getDisplayContent().getLastHasContent()) {
// This draw means the difference between unique content and mirroring.
// Run another pass through performLayout to set mHasContent in the
// LogicalDisplay.
mAnimator.setPendingLayoutChanges(w.getDisplayId(),
FINISH_LAYOUT_REDO_ANIM);
if (DEBUG_LAYOUT_REPEATS) {
mService.mWindowPlacerLocked.debugLayoutRepeats(
"showSurfaceRobustlyLocked " + w,
mAnimator.getPendingLayoutChanges(w.getDisplayId()));
}
}
} else {
w.setOrientationChanging(false);