Skip to content

Commit b3cbd0b

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Refactor animation out of WindowState."
2 parents 628e234 + a2c7705 commit b3cbd0b

File tree

6 files changed

+392
-338
lines changed

6 files changed

+392
-338
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class AppWindowToken extends WindowToken {
5151
int groupId = -1;
5252
boolean appFullscreen;
5353
int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
54-
54+
5555
// The input dispatching timeout for this application token in nanoseconds.
5656
long inputDispatchingTimeoutNanos;
5757

@@ -225,7 +225,7 @@ boolean showAllWindowsLocked() {
225225
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
226226
"performing show on: " + w);
227227
w.performShowLocked();
228-
isAnimating |= w.isAnimating();
228+
isAnimating |= w.mWinAnimator.isAnimating();
229229
}
230230
return isAnimating;
231231
}
@@ -243,11 +243,11 @@ private void stepThumbnailAnimation(long currentTime) {
243243
// cache often used attributes locally
244244
final float tmpFloats[] = service.mTmpFloats;
245245
thumbnailTransformation.getMatrix().getValues(tmpFloats);
246-
if (WindowManagerService.SHOW_TRANSACTIONS) service.logSurface(thumbnail,
246+
if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
247247
"thumbnail", "POS " + tmpFloats[Matrix.MTRANS_X]
248248
+ ", " + tmpFloats[Matrix.MTRANS_Y], null);
249249
thumbnail.setPosition(tmpFloats[Matrix.MTRANS_X], tmpFloats[Matrix.MTRANS_Y]);
250-
if (WindowManagerService.SHOW_TRANSACTIONS) service.logSurface(thumbnail,
250+
if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
251251
"thumbnail", "alpha=" + thumbnailTransformation.getAlpha()
252252
+ " layer=" + thumbnailLayer
253253
+ " matrix=[" + tmpFloats[Matrix.MSCALE_X]
@@ -358,7 +358,7 @@ boolean stepAnimationLocked(long currentTime, int dw, int dh) {
358358

359359
final int N = windows.size();
360360
for (int i=0; i<N; i++) {
361-
windows.get(i).finishExit();
361+
windows.get(i).mWinAnimator.finishExit();
362362
}
363363
updateReportedVisibilityLocked();
364364

@@ -388,7 +388,7 @@ void updateReportedVisibilityLocked() {
388388
if (WindowManagerService.DEBUG_VISIBILITY) {
389389
Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn="
390390
+ win.isDrawnLw()
391-
+ ", isAnimating=" + win.isAnimating());
391+
+ ", isAnimating=" + win.mWinAnimator.isAnimating());
392392
if (!win.isDrawnLw()) {
393393
Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mSurface
394394
+ " pv=" + win.mPolicyVisibility
@@ -398,17 +398,17 @@ void updateReportedVisibilityLocked() {
398398
+ " th="
399399
+ (win.mAppToken != null
400400
? win.mAppToken.hiddenRequested : false)
401-
+ " a=" + win.mAnimating);
401+
+ " a=" + win.mWinAnimator.mAnimating);
402402
}
403403
}
404404
numInteresting++;
405405
if (win.isDrawnLw()) {
406406
numDrawn++;
407-
if (!win.isAnimating()) {
407+
if (!win.mWinAnimator.isAnimating()) {
408408
numVisible++;
409409
}
410410
nowGone = false;
411-
} else if (win.isAnimating()) {
411+
} else if (win.mWinAnimator.isAnimating()) {
412412
nowGone = false;
413413
}
414414
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void show(int dw, int dh) {
8282

8383
/**
8484
* Set's the dim surface's layer and update dim parameters that will be used in
85-
* {@link updateSurface} after all windows are examined.
85+
* {@link #updateSurface} after all windows are examined.
8686
*/
8787
void updateParameters(Resources res, WindowState w, long currentTime) {
8888
mDimSurface.setLayer(w.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM);
@@ -94,15 +94,15 @@ void updateParameters(Resources res, WindowState w, long currentTime) {
9494
// If the desired dim level has changed, then
9595
// start an animation to it.
9696
mLastDimAnimTime = currentTime;
97-
long duration = (w.mAnimating && w.mAnimation != null)
98-
? w.mAnimation.computeDurationHint()
97+
long duration = (w.mWinAnimator.mAnimating && w.mWinAnimator.mAnimation != null)
98+
? w.mWinAnimator.mAnimation.computeDurationHint()
9999
: WindowManagerService.DEFAULT_DIM_DURATION;
100100
if (target > mDimTargetAlpha) {
101101
TypedValue tv = new TypedValue();
102102
res.getValue(com.android.internal.R.fraction.config_dimBehindFadeDuration,
103103
tv, true);
104104
if (tv.type == TypedValue.TYPE_FRACTION) {
105-
duration = (long)tv.getFraction((float)duration, (float)duration);
105+
duration = (long)tv.getFraction(duration, duration);
106106
} else if (tv.type >= TypedValue.TYPE_FIRST_INT
107107
&& tv.type <= TypedValue.TYPE_LAST_INT) {
108108
duration = tv.data;

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
7979
}
8080
}
8181
}
82-
82+
8383
final int NEAT = mService.mExitingAppTokens.size();
8484
for (i=0; i<NEAT; i++) {
8585
final AppWindowToken appToken = mService.mExitingAppTokens.get(i);
@@ -115,6 +115,7 @@ private void updateWindowsAndWallpaperLocked() {
115115

116116
for (int i = mService.mWindows.size() - 1; i >= 0; i--) {
117117
WindowState w = mService.mWindows.get(i);
118+
WindowStateAnimator winAnimator = w.mWinAnimator;
118119

119120
final WindowManager.LayoutParams attrs = w.mAttrs;
120121

@@ -143,16 +144,16 @@ private void updateWindowsAndWallpaperLocked() {
143144
// let's do something.
144145
Animation a = AnimationUtils.loadAnimation(mContext,
145146
com.android.internal.R.anim.window_move_from_decor);
146-
w.setAnimation(a);
147+
winAnimator.setAnimation(a);
147148
w.mAnimDw = w.mLastFrame.left - w.mFrame.left;
148149
w.mAnimDh = w.mLastFrame.top - w.mFrame.top;
149150
} else {
150151
w.mAnimDw = mInnerDw;
151152
w.mAnimDh = mInnerDh;
152153
}
153154

154-
final boolean wasAnimating = w.mWasAnimating;
155-
final boolean nowAnimating = w.stepAnimationLocked(mCurrentTime);
155+
final boolean wasAnimating = winAnimator.mWasAnimating;
156+
final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
156157

157158
if (WindowManagerService.DEBUG_WALLPAPER) {
158159
Slog.v(TAG, w + ": wasAnimating=" + wasAnimating +
@@ -163,17 +164,17 @@ private void updateWindowsAndWallpaperLocked() {
163164
// an animating window and take care of a request to run
164165
// a detached wallpaper animation.
165166
if (nowAnimating) {
166-
if (w.mAnimation != null) {
167+
if (winAnimator.mAnimation != null) {
167168
if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0
168-
&& w.mAnimation.getDetachWallpaper()) {
169+
&& winAnimator.mAnimation.getDetachWallpaper()) {
169170
mService.mInnerFields.mDetachedWallpaper = w;
170171
}
171-
if (w.mAnimation.getBackgroundColor() != 0) {
172+
if (winAnimator.mAnimation.getBackgroundColor() != 0) {
172173
if (mWindowAnimationBackground == null
173174
|| (w.mAnimLayer < mWindowAnimationBackground.mAnimLayer)) {
174175
mWindowAnimationBackground = w;
175176
mWindowAnimationBackgroundColor =
176-
w.mAnimation.getBackgroundColor();
177+
winAnimator.mAnimation.getBackgroundColor();
177178
}
178179
}
179180
}
@@ -200,7 +201,7 @@ private void updateWindowsAndWallpaperLocked() {
200201
}
201202
}
202203

203-
if (wasAnimating && !w.mAnimating && mService.mWallpaperTarget == w) {
204+
if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == w) {
204205
mService.mInnerFields.mWallpaperMayChange = true;
205206
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
206207
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
@@ -219,7 +220,7 @@ private void updateWindowsAndWallpaperLocked() {
219220
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3");
220221
}
221222
mService.mFocusMayChange = true;
222-
} else if (w.isReadyForDisplay() && w.mAnimation == null) {
223+
} else if (w.isReadyForDisplay() && winAnimator.mAnimation == null) {
223224
mForceHiding = true;
224225
}
225226
} else if (mPolicy.canBeForceHidden(w, attrs)) {
@@ -241,7 +242,7 @@ private void updateWindowsAndWallpaperLocked() {
241242
// clean up later.
242243
Animation a = mPolicy.createForceHideEnterAnimation();
243244
if (a != null) {
244-
w.setAnimation(a);
245+
winAnimator.setAnimation(a);
245246
}
246247
}
247248
if (mCurrentFocus == null || mCurrentFocus.mLayer < w.mLayer) {
@@ -277,15 +278,15 @@ private void updateWindowsAndWallpaperLocked() {
277278
WindowManagerService.DEBUG_ORIENTATION) {
278279
Slog.v(TAG, "Eval win " + w + ": isDrawn="
279280
+ w.isDrawnLw()
280-
+ ", isAnimating=" + w.isAnimating());
281+
+ ", isAnimating=" + winAnimator.isAnimating());
281282
if (!w.isDrawnLw()) {
282283
Slog.v(TAG, "Not displayed: s=" + w.mSurface
283284
+ " pv=" + w.mPolicyVisibility
284285
+ " dp=" + w.mDrawPending
285286
+ " cdp=" + w.mCommitDrawPending
286287
+ " ah=" + w.mAttachedHidden
287288
+ " th=" + atoken.hiddenRequested
288-
+ " a=" + w.mAnimating);
289+
+ " a=" + winAnimator.mAnimating);
289290
}
290291
}
291292
if (w != atoken.startingWindow) {

0 commit comments

Comments
 (0)