Skip to content

Commit d5f2374

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Reset layout needed at each animation step."
2 parents 9321ad6 + bb1449b commit d5f2374

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,11 @@ public void onTasksLoaded(ArrayList<TaskDescription> tasks) {
616616
if (!mFirstScreenful && tasks.size() == 0) {
617617
return;
618618
}
619-
mNumItemsWaitingForThumbnailsAndIcons =
620-
mFirstScreenful ? tasks.size() : mRecentTaskDescriptions.size();
619+
mNumItemsWaitingForThumbnailsAndIcons = mFirstScreenful
620+
? tasks.size() : mRecentTaskDescriptions == null
621+
? 0 : mRecentTaskDescriptions.size();
621622
if (mRecentTaskDescriptions == null) {
622-
mRecentTaskDescriptions = new ArrayList(tasks);
623+
mRecentTaskDescriptions = new ArrayList<TaskDescription>(tasks);
623624
} else {
624625
mRecentTaskDescriptions.addAll(tasks);
625626
}

services/java/com/android/server/wm/WindowAnimator.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* on behalf of WindowManagerService.
2424
*/
2525
public class WindowAnimator {
26-
private static final String TAG = "WindowAnimations";
26+
private static final String TAG = "WindowAnimator";
2727

2828
final WindowManagerService mService;
2929
final Context mContext;
@@ -67,8 +67,24 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
6767
final int NAT = mService.mAppTokens.size();
6868
for (i=0; i<NAT; i++) {
6969
final AppWindowToken appToken = mService.mAppTokens.get(i);
70+
final boolean wasAnimating = appToken.animation != null;
7071
if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
7172
mAnimating = true;
73+
} else if (wasAnimating) {
74+
// stopped animating, do one more pass through the layout
75+
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
76+
}
77+
}
78+
79+
final int NEAT = mService.mExitingAppTokens.size();
80+
for (i=0; i<NEAT; i++) {
81+
final AppWindowToken appToken = mService.mExitingAppTokens.get(i);
82+
final boolean wasAnimating = appToken.animation != null;
83+
if (appToken.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
84+
mAnimating = true;
85+
} else if (wasAnimating) {
86+
// stopped animating, do one more pass through the layout
87+
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
7288
}
7389
}
7490

@@ -526,6 +542,7 @@ public void prepareSurfaceLocked(final WindowState w, final boolean recoveringMe
526542
}
527543

528544
void animate() {
545+
mPendingLayoutChanges = 0;
529546
mCurrentTime = SystemClock.uptimeMillis();
530547

531548
// Update animations of all applications, including those

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ class LayoutAndSurfaceFields {
608608
}
609609
LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields();
610610

611+
/** Only do a maximum of 6 repeated layouts. After that quit */
612+
private int mLayoutRepeatCount;
613+
611614
private final class AnimationRunnable implements Runnable {
612615
@Override
613616
public void run() {
@@ -1917,7 +1920,7 @@ boolean updateWallpaperOffsetLocked(WindowState wallpaperWin, int dw, int dh,
19171920
rawChanged = true;
19181921
}
19191922

1920-
if (rawChanged && (wallpaperWin.getAttrs().privateFlags &
1923+
if (rawChanged && (wallpaperWin.mAttrs.privateFlags &
19211924
WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) != 0) {
19221925
try {
19231926
if (DEBUG_WALLPAPER) Slog.v(TAG, "Report new wp offset "
@@ -2316,7 +2319,7 @@ public void removeWindowLocked(Session session, WindowState win) {
23162319
if (wasVisible) {
23172320

23182321
int transit = WindowManagerPolicy.TRANSIT_EXIT;
2319-
if (win.getAttrs().type == TYPE_APPLICATION_STARTING) {
2322+
if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
23202323
transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
23212324
}
23222325
// Try starting an animation.
@@ -2790,7 +2793,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27902793
// Try starting an animation; if there isn't one, we
27912794
// can destroy the surface right away.
27922795
int transit = WindowManagerPolicy.TRANSIT_EXIT;
2793-
if (win.getAttrs().type == TYPE_APPLICATION_STARTING) {
2796+
if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
27942797
transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
27952798
}
27962799
if (!win.mSurfacePendingDestroy && win.isWinVisibleLw() &&
@@ -7575,10 +7578,25 @@ private final void performLayoutAndPlaceSurfacesLocked() {
75757578

75767579
} else {
75777580
mInLayout = false;
7578-
if (mLayoutNeeded) {
7581+
}
7582+
7583+
if (mLayoutNeeded) {
7584+
if (++mLayoutRepeatCount < 6) {
75797585
requestTraversalLocked();
7586+
} else {
7587+
Slog.e(TAG, "Performed 6 layouts in a row. Skipping");
7588+
mLayoutRepeatCount = 0;
75807589
}
7590+
} else {
7591+
mLayoutRepeatCount = 0;
7592+
}
7593+
7594+
if (mAnimator.mAnimating) {
7595+
// Do this even if requestTraversalLocked was called above so we get a frame drawn
7596+
// at the proper time as well as the one drawn early.
7597+
scheduleAnimationLocked();
75817598
}
7599+
75827600
if (mWindowsChanged && !mWindowChangeListeners.isEmpty()) {
75837601
mH.removeMessages(H.REPORT_WINDOWS_CHANGE);
75847602
mH.sendMessage(mH.obtainMessage(H.REPORT_WINDOWS_CHANGE));
@@ -8366,13 +8384,15 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
83668384
mLayoutNeeded = true;
83678385
}
83688386
}
8387+
83698388
if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
83708389
if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
83718390
if (updateOrientationFromAppTokensLocked(true)) {
83728391
mLayoutNeeded = true;
83738392
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
83748393
}
83758394
}
8395+
83768396
if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
83778397
mLayoutNeeded = true;
83788398
}
@@ -8584,8 +8604,6 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
85848604
}
85858605
}
85868606

8587-
boolean needRelayout = false;
8588-
85898607
if (!mAnimator.mAnimating && mAppTransitionRunning) {
85908608
// We have finished the animation of an app transition. To do
85918609
// this, we have delayed a lot of operations like showing and
@@ -8594,7 +8612,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
85948612
// be out of sync with it. So here we will just rebuild the
85958613
// entire app window list. Fun!
85968614
mAppTransitionRunning = false;
8597-
needRelayout = true;
8615+
mLayoutNeeded = true;
85988616
rebuildAppWindowListLocked();
85998617
assignLayersLocked();
86008618
// Clear information about apps that were moving.
@@ -8605,19 +8623,10 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86058623
mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
86068624
}
86078625
if (wallpaperDestroyed) {
8608-
needRelayout = adjustWallpaperWindowsLocked() != 0;
8609-
}
8610-
if ((mPendingLayoutChanges & (
8611-
WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER |
8612-
ADJUST_WALLPAPER_LAYERS_CHANGED |
8613-
WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG |
8614-
WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT)) != 0) {
8615-
needRelayout = true;
8626+
mLayoutNeeded |= adjustWallpaperWindowsLocked() != 0;
86168627
}
8617-
if (needRelayout) {
8618-
requestTraversalLocked();
8619-
} else if (mAnimator.mAnimating) {
8620-
scheduleAnimationLocked();
8628+
if (mPendingLayoutChanges != 0) {
8629+
mLayoutNeeded = true;
86218630
}
86228631

86238632
// Finally update all input windows now that the window changes have stabilized.
@@ -8660,7 +8669,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86608669
}
86618670
}
86628671

8663-
if (mInnerFields.mOrientationChangeComplete && !needRelayout &&
8672+
if (mInnerFields.mOrientationChangeComplete && !mLayoutNeeded &&
86648673
!mInnerFields.mUpdateRotation) {
86658674
checkDrawnWindowsLocked();
86668675
}

0 commit comments

Comments
 (0)