blob: 2e3833249d04a0814251f3f4143b83783e80e2f4 [file] [log] [blame]
Craig Mautnera2c77052012-03-26 12:14:43 -07001// Copyright 2012 Google Inc. All Rights Reserved.
2
3package com.android.server.wm;
4
Craig Mautnerc2f9be02012-03-27 17:32:29 -07005import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
6import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
7
Craig Mautnerd09cc4b2012-04-04 10:23:31 -07008import static com.android.server.wm.WindowManagerService.LayoutFields.CLEAR_ORIENTATION_CHANGE_COMPLETE;
Craig Mautner7d8df392012-04-06 15:26:23 -07009import static com.android.server.wm.WindowManagerService.LayoutFields.SET_TURN_ON_SCREEN;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070010
Craig Mautnerc2f9be02012-03-27 17:32:29 -070011import android.content.Context;
12import android.graphics.Matrix;
13import android.graphics.PixelFormat;
Craig Mautner7358fbf2012-04-12 21:06:33 -070014import android.graphics.Point;
15import android.graphics.PointF;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070016import android.graphics.Rect;
Craig Mautner48ba1e72012-04-02 13:18:16 -070017import android.graphics.Region;
Craig Mautnera51a9562012-04-17 17:05:26 -070018import android.os.Debug;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070019import android.os.RemoteException;
Craig Mautnera2c77052012-03-26 12:14:43 -070020import android.util.Slog;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070021import android.view.Surface;
Craig Mautner7358fbf2012-04-12 21:06:33 -070022import android.view.SurfaceSession;
Craig Mautnera2c77052012-03-26 12:14:43 -070023import android.view.WindowManager;
24import android.view.WindowManagerPolicy;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070025import android.view.WindowManager.LayoutParams;
Craig Mautnera2c77052012-03-26 12:14:43 -070026import android.view.animation.Animation;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070027import android.view.animation.AnimationUtils;
Craig Mautnera2c77052012-03-26 12:14:43 -070028import android.view.animation.Transformation;
29
30import com.android.server.wm.WindowManagerService.H;
31
32import java.io.PrintWriter;
Craig Mautner7358fbf2012-04-12 21:06:33 -070033import java.util.ArrayList;
Craig Mautnera2c77052012-03-26 12:14:43 -070034
35/**
Craig Mautnerc2f9be02012-03-27 17:32:29 -070036 * Keep track of animations and surface operations for a single WindowState.
37 **/
Craig Mautnera2c77052012-03-26 12:14:43 -070038class WindowStateAnimator {
Craig Mautnerc2f9be02012-03-27 17:32:29 -070039 static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY;
40 static final boolean DEBUG_ANIM = WindowManagerService.DEBUG_ANIM;
41 static final boolean DEBUG_LAYERS = WindowManagerService.DEBUG_LAYERS;
42 static final boolean DEBUG_STARTING_WINDOW = WindowManagerService.DEBUG_STARTING_WINDOW;
43 static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS;
44 static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS;
45 static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC;
46 static final boolean localLOGV = WindowManagerService.localLOGV;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -070047 static final boolean DEBUG_ORIENTATION = WindowManagerService.DEBUG_ORIENTATION;
Craig Mautner7358fbf2012-04-12 21:06:33 -070048 static final boolean DEBUG_SURFACE_TRACE = WindowManagerService.DEBUG_SURFACE_TRACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070049
50 static final String TAG = "WindowStateAnimator";
Craig Mautnera2c77052012-03-26 12:14:43 -070051
52 final WindowManagerService mService;
53 final WindowState mWin;
54 final WindowState mAttachedWindow;
Craig Mautnere7ae2502012-03-26 17:11:19 -070055 final WindowAnimator mAnimator;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070056 final Session mSession;
57 final WindowManagerPolicy mPolicy;
58 final Context mContext;
Craig Mautnera2c77052012-03-26 12:14:43 -070059
60 // Currently running animation.
61 boolean mAnimating;
62 boolean mLocalAnimating;
63 Animation mAnimation;
64 boolean mAnimationIsEntrance;
65 boolean mHasTransformation;
66 boolean mHasLocalTransformation;
67 final Transformation mTransformation = new Transformation();
68 boolean mWasAnimating; // Were we animating going into the most recent animation step?
Craig Mautnerc2f9be02012-03-27 17:32:29 -070069 int mAnimLayer;
70 int mLastLayer;
71
72 Surface mSurface;
73 Surface mPendingDestroySurface;
74 boolean mReportDestroySurface;
75 boolean mSurfacePendingDestroy;
76
77 /**
78 * Set when we have changed the size of the surface, to know that
79 * we must tell them application to resize (and thus redraw itself).
80 */
81 boolean mSurfaceResized;
82
83 /**
84 * Set if the client has asked that the destroy of its surface be delayed
85 * until it explicitly says it is okay.
86 */
87 boolean mSurfaceDestroyDeferred;
88
Craig Mautner7d8df392012-04-06 15:26:23 -070089 float mShownAlpha = 0;
90 float mAlpha = 0;
91 float mLastAlpha = 0;
Craig Mautnerc2f9be02012-03-27 17:32:29 -070092
93 // Used to save animation distances between the time they are calculated and when they are
94 // used.
95 int mAnimDw;
96 int mAnimDh;
97 float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1;
98 float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1;
99
100 boolean mHaveMatrix;
101
102 // For debugging, this is the last information given to the surface flinger.
103 boolean mSurfaceShown;
104 float mSurfaceX, mSurfaceY, mSurfaceW, mSurfaceH;
105 int mSurfaceLayer;
106 float mSurfaceAlpha;
107
108 // Set to true if, when the window gets displayed, it should perform
109 // an enter animation.
110 boolean mEnterAnimationPending;
Craig Mautnera2c77052012-03-26 12:14:43 -0700111
Craig Mautner749a7bb2012-04-02 13:49:53 -0700112 /** This is set when there is no Surface */
113 static final int NO_SURFACE = 0;
114 /** This is set after the Surface has been created but before the window has been drawn. During
115 * this time the surface is hidden. */
116 static final int DRAW_PENDING = 1;
117 /** This is set after the window has finished drawing for the first time but before its surface
118 * is shown. The surface will be displayed when the next layout is run. */
119 static final int COMMIT_DRAW_PENDING = 2;
120 /** This is set during the time after the window's drawing has been committed, and before its
121 * surface is actually shown. It is used to delay showing the surface until all windows in a
122 * token are ready to be shown. */
123 static final int READY_TO_SHOW = 3;
124 /** Set when the window has been shown in the screen the first time. */
125 static final int HAS_DRAWN = 4;
126 int mDrawState;
Craig Mautnera608b882012-03-30 13:03:49 -0700127
Craig Mautner749a7bb2012-04-02 13:49:53 -0700128 /** Was this window last hidden? */
129 boolean mLastHidden;
Craig Mautnera608b882012-03-30 13:03:49 -0700130
Craig Mautnerbec53f72012-04-05 11:49:05 -0700131 int mAttrFlags;
132 int mAttrType;
133
Craig Mautnera2c77052012-03-26 12:14:43 -0700134 public WindowStateAnimator(final WindowManagerService service, final WindowState win,
135 final WindowState attachedWindow) {
136 mService = service;
137 mWin = win;
138 mAttachedWindow = attachedWindow;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700139 mAnimator = mService.mAnimator;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700140 mSession = win.mSession;
141 mPolicy = mService.mPolicy;
142 mContext = mService.mContext;
Craig Mautnerbec53f72012-04-05 11:49:05 -0700143 mAttrFlags = win.mAttrs.flags;
144 mAttrType = win.mAttrs.type;
Craig Mautnera2c77052012-03-26 12:14:43 -0700145 }
146
147 public void setAnimation(Animation anim) {
Craig Mautnerbec53f72012-04-05 11:49:05 -0700148 if (localLOGV) Slog.v(TAG, "Setting animation in " + this + ": " + anim);
Craig Mautnera2c77052012-03-26 12:14:43 -0700149 mAnimating = false;
150 mLocalAnimating = false;
151 mAnimation = anim;
152 mAnimation.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION);
153 mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale);
154 // Start out animation gone if window is gone, or visible if window is visible.
155 mTransformation.clear();
Craig Mautner749a7bb2012-04-02 13:49:53 -0700156 mTransformation.setAlpha(mLastHidden ? 0 : 1);
Craig Mautnera2c77052012-03-26 12:14:43 -0700157 mHasLocalTransformation = true;
158 }
159
160 public void clearAnimation() {
161 if (mAnimation != null) {
162 mAnimating = true;
163 mLocalAnimating = false;
164 mAnimation.cancel();
165 mAnimation = null;
166 }
167 }
168
169 /** Is the window or its container currently animating? */
170 boolean isAnimating() {
171 final WindowState attached = mAttachedWindow;
172 final AppWindowToken atoken = mWin.mAppToken;
173 return mAnimation != null
174 || (attached != null && attached.mWinAnimator.mAnimation != null)
175 || (atoken != null &&
Craig Mautner59431632012-04-04 11:56:44 -0700176 (atoken.mAppAnimator.animation != null
Craig Mautnera2c77052012-03-26 12:14:43 -0700177 || atoken.inPendingTransaction));
178 }
179
180 /** Is this window currently animating? */
181 boolean isWindowAnimating() {
182 return mAnimation != null;
183 }
184
Craig Mautnera2c77052012-03-26 12:14:43 -0700185 void cancelExitAnimationForNextAnimationLocked() {
Craig Mautnera2c77052012-03-26 12:14:43 -0700186 if (mAnimation != null) {
187 mAnimation.cancel();
188 mAnimation = null;
Craig Mautner4d7349b2012-04-20 14:52:47 -0700189 mLocalAnimating = false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700190 destroySurfaceLocked();
Craig Mautnera2c77052012-03-26 12:14:43 -0700191 }
Craig Mautnera2c77052012-03-26 12:14:43 -0700192 }
193
194 private boolean stepAnimation(long currentTime) {
195 if ((mAnimation == null) || !mLocalAnimating) {
196 return false;
197 }
198 mTransformation.clear();
199 final boolean more = mAnimation.getTransformation(currentTime, mTransformation);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700200 if (DEBUG_ANIM) Slog.v(
201 TAG, "Stepped animation in " + this +
Craig Mautnera2c77052012-03-26 12:14:43 -0700202 ": more=" + more + ", xform=" + mTransformation);
203 return more;
204 }
205
206 // This must be called while inside a transaction. Returns true if
207 // there is more animation to run.
208 boolean stepAnimationLocked(long currentTime) {
209 // Save the animation state as it was before this step so WindowManagerService can tell if
210 // we just started or just stopped animating by comparing mWasAnimating with isAnimating().
211 mWasAnimating = mAnimating;
212 if (mService.okToDisplay()) {
213 // We will run animations as long as the display isn't frozen.
214
215 if (mWin.isDrawnLw() && mAnimation != null) {
216 mHasTransformation = true;
217 mHasLocalTransformation = true;
218 if (!mLocalAnimating) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700219 if (DEBUG_ANIM) Slog.v(
220 TAG, "Starting animation in " + this +
Craig Mautnera2c77052012-03-26 12:14:43 -0700221 " @ " + currentTime + ": ww=" + mWin.mFrame.width() +
222 " wh=" + mWin.mFrame.height() +
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700223 " dw=" + mAnimDw + " dh=" + mAnimDh +
Craig Mautnera2c77052012-03-26 12:14:43 -0700224 " scale=" + mService.mWindowAnimationScale);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700225 mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(),
226 mAnimDw, mAnimDh);
Craig Mautnera2c77052012-03-26 12:14:43 -0700227 mAnimation.setStartTime(currentTime);
228 mLocalAnimating = true;
229 mAnimating = true;
230 }
231 if ((mAnimation != null) && mLocalAnimating) {
232 if (stepAnimation(currentTime)) {
233 return true;
234 }
235 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700236 if (DEBUG_ANIM) Slog.v(
237 TAG, "Finished animation in " + this +
Craig Mautnera2c77052012-03-26 12:14:43 -0700238 " @ " + currentTime);
239 //WindowManagerService.this.dump();
240 }
241 mHasLocalTransformation = false;
242 if ((!mLocalAnimating || mAnimationIsEntrance) && mWin.mAppToken != null
Craig Mautner59431632012-04-04 11:56:44 -0700243 && mWin.mAppToken.mAppAnimator.animation != null) {
Craig Mautnera2c77052012-03-26 12:14:43 -0700244 // When our app token is animating, we kind-of pretend like
245 // we are as well. Note the mLocalAnimating mAnimationIsEntrance
246 // part of this check means that we will only do this if
247 // our window is not currently exiting, or it is not
248 // locally animating itself. The idea being that one that
249 // is exiting and doing a local animation should be removed
250 // once that animation is done.
251 mAnimating = true;
252 mHasTransformation = true;
253 mTransformation.clear();
254 return false;
255 } else if (mHasTransformation) {
256 // Little trick to get through the path below to act like
257 // we have finished an animation.
258 mAnimating = true;
259 } else if (isAnimating()) {
260 mAnimating = true;
261 }
262 } else if (mAnimation != null) {
263 // If the display is frozen, and there is a pending animation,
264 // clear it and make sure we run the cleanup code.
265 mAnimating = true;
Craig Mautnera2c77052012-03-26 12:14:43 -0700266 }
267
268 if (!mAnimating && !mLocalAnimating) {
269 return false;
270 }
271
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700272 // Done animating, clean up.
273 if (DEBUG_ANIM) Slog.v(
274 TAG, "Animation done in " + this + ": exiting=" + mWin.mExiting
Craig Mautnera2c77052012-03-26 12:14:43 -0700275 + ", reportedVisible="
276 + (mWin.mAppToken != null ? mWin.mAppToken.reportedVisible : false));
277
278 mAnimating = false;
279 mLocalAnimating = false;
280 if (mAnimation != null) {
281 mAnimation.cancel();
282 mAnimation = null;
283 }
Craig Mautnere7ae2502012-03-26 17:11:19 -0700284 if (mAnimator.mWindowDetachedWallpaper == mWin) {
285 mAnimator.mWindowDetachedWallpaper = null;
Craig Mautnera2c77052012-03-26 12:14:43 -0700286 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700287 mAnimLayer = mWin.mLayer;
Craig Mautnera2c77052012-03-26 12:14:43 -0700288 if (mWin.mIsImWindow) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700289 mAnimLayer += mService.mInputMethodAnimLayerAdjustment;
Craig Mautnera2c77052012-03-26 12:14:43 -0700290 } else if (mWin.mIsWallpaper) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700291 mAnimLayer += mService.mWallpaperAnimLayerAdjustment;
Craig Mautnera2c77052012-03-26 12:14:43 -0700292 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700293 if (DEBUG_LAYERS) Slog.v(TAG, "Stepping win " + this
294 + " anim layer: " + mAnimLayer);
Craig Mautnera2c77052012-03-26 12:14:43 -0700295 mHasTransformation = false;
296 mHasLocalTransformation = false;
297 if (mWin.mPolicyVisibility != mWin.mPolicyVisibilityAfterAnim) {
298 if (WindowState.DEBUG_VISIBILITY) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700299 Slog.v(TAG, "Policy visibility changing after anim in " + this + ": "
Craig Mautnera2c77052012-03-26 12:14:43 -0700300 + mWin.mPolicyVisibilityAfterAnim);
301 }
302 mWin.mPolicyVisibility = mWin.mPolicyVisibilityAfterAnim;
303 mService.mLayoutNeeded = true;
304 if (!mWin.mPolicyVisibility) {
305 if (mService.mCurrentFocus == mWin) {
306 mService.mFocusMayChange = true;
307 }
308 // Window is no longer visible -- make sure if we were waiting
309 // for it to be displayed before enabling the display, that
310 // we allow the display to be enabled now.
311 mService.enableScreenIfNeededLocked();
312 }
313 }
314 mTransformation.clear();
Craig Mautner749a7bb2012-04-02 13:49:53 -0700315 if (mDrawState == HAS_DRAWN
Craig Mautnera2c77052012-03-26 12:14:43 -0700316 && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
317 && mWin.mAppToken != null
318 && mWin.mAppToken.firstWindowDrawn
319 && mWin.mAppToken.startingData != null) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700320 if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Finish starting "
Craig Mautnera2c77052012-03-26 12:14:43 -0700321 + mWin.mToken + ": first real window done animating");
322 mService.mFinishedStarting.add(mWin.mAppToken);
323 mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
324 }
325
326 finishExit();
Craig Mautnerd09cc4b2012-04-04 10:23:31 -0700327 mAnimator.mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
328 if (WindowManagerService.DEBUG_LAYOUT_REPEATS) mService.debugLayoutRepeats(
329 "WindowStateAnimator", mAnimator.mPendingLayoutChanges);
Craig Mautnera2c77052012-03-26 12:14:43 -0700330
331 if (mWin.mAppToken != null) {
332 mWin.mAppToken.updateReportedVisibilityLocked();
333 }
334
335 return false;
336 }
337
338 void finishExit() {
339 if (WindowManagerService.DEBUG_ANIM) Slog.v(
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700340 TAG, "finishExit in " + this
Craig Mautnera2c77052012-03-26 12:14:43 -0700341 + ": exiting=" + mWin.mExiting
342 + " remove=" + mWin.mRemoveOnExit
343 + " windowAnimating=" + isWindowAnimating());
344
345 final int N = mWin.mChildWindows.size();
346 for (int i=0; i<N; i++) {
347 mWin.mChildWindows.get(i).mWinAnimator.finishExit();
348 }
349
350 if (!mWin.mExiting) {
351 return;
352 }
353
354 if (isWindowAnimating()) {
355 return;
356 }
357
358 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700359 TAG, "Exit animation finished in " + this
Craig Mautnera2c77052012-03-26 12:14:43 -0700360 + ": remove=" + mWin.mRemoveOnExit);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700361 if (mSurface != null) {
Craig Mautnera2c77052012-03-26 12:14:43 -0700362 mService.mDestroySurface.add(mWin);
363 mWin.mDestroying = true;
364 if (WindowState.SHOW_TRANSACTIONS) WindowManagerService.logSurface(
365 mWin, "HIDE (finishExit)", null);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700366 mSurfaceShown = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700367 try {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700368 mSurface.hide();
Craig Mautnera2c77052012-03-26 12:14:43 -0700369 } catch (RuntimeException e) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700370 Slog.w(TAG, "Error hiding surface in " + this, e);
Craig Mautnera2c77052012-03-26 12:14:43 -0700371 }
Craig Mautner749a7bb2012-04-02 13:49:53 -0700372 mLastHidden = true;
Craig Mautnera2c77052012-03-26 12:14:43 -0700373 }
374 mWin.mExiting = false;
375 if (mWin.mRemoveOnExit) {
376 mService.mPendingRemove.add(mWin);
377 mWin.mRemoveOnExit = false;
378 }
379 }
380
Craig Mautnera608b882012-03-30 13:03:49 -0700381 boolean finishDrawingLocked() {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700382 if (mDrawState == DRAW_PENDING) {
Craig Mautner83339b42012-05-01 22:13:23 -0700383 if (DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
384 TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in "
385 + mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700386 mDrawState = COMMIT_DRAW_PENDING;
Craig Mautnera608b882012-03-30 13:03:49 -0700387 return true;
388 }
389 return false;
390 }
391
392 // This must be called while inside a transaction.
393 boolean commitFinishDrawingLocked(long currentTime) {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700394 if (mDrawState != COMMIT_DRAW_PENDING) {
Craig Mautnera608b882012-03-30 13:03:49 -0700395 return false;
396 }
Craig Mautner83339b42012-05-01 22:13:23 -0700397 if (DEBUG_ANIM)
398 Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700399 mDrawState = READY_TO_SHOW;
Craig Mautnera608b882012-03-30 13:03:49 -0700400 final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
401 final AppWindowToken atoken = mWin.mAppToken;
402 if (atoken == null || atoken.allDrawn || starting) {
403 performShowLocked();
404 }
405 return true;
406 }
407
Craig Mautner7d8df392012-04-06 15:26:23 -0700408 static class SurfaceTrace extends Surface {
409 private final static String SURFACE_TAG = "SurfaceTrace";
410 final static ArrayList<SurfaceTrace> sSurfaces = new ArrayList<SurfaceTrace>();
Craig Mautner7358fbf2012-04-12 21:06:33 -0700411
Craig Mautner7d8df392012-04-06 15:26:23 -0700412 private float mSurfaceTraceAlpha = 0;
Craig Mautner7358fbf2012-04-12 21:06:33 -0700413 private int mLayer;
414 private PointF mPosition = new PointF();
Craig Mautner7d8df392012-04-06 15:26:23 -0700415 private Point mSize;
Craig Mautner7358fbf2012-04-12 21:06:33 -0700416 private boolean mShown = false;
417 private String mName = "Not named";
418
Craig Mautner7d8df392012-04-06 15:26:23 -0700419 public SurfaceTrace(SurfaceSession s,
Craig Mautner7358fbf2012-04-12 21:06:33 -0700420 int pid, int display, int w, int h, int format, int flags) throws
421 OutOfResourcesException {
422 super(s, pid, display, w, h, format, flags);
423 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700424 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700425 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700426 }
427
Craig Mautner7d8df392012-04-06 15:26:23 -0700428 public SurfaceTrace(SurfaceSession s,
Craig Mautner7358fbf2012-04-12 21:06:33 -0700429 int pid, String name, int display, int w, int h, int format, int flags)
430 throws OutOfResourcesException {
431 super(s, pid, name, display, w, h, format, flags);
432 mName = name;
433 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700434 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700435 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700436 }
437
438 @Override
439 public void setAlpha(float alpha) {
440 super.setAlpha(alpha);
Craig Mautner7d8df392012-04-06 15:26:23 -0700441 mSurfaceTraceAlpha = alpha;
442 Slog.v(SURFACE_TAG, "setAlpha: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700443 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700444 }
445
446 @Override
447 public void setLayer(int zorder) {
448 super.setLayer(zorder);
449 mLayer = zorder;
Craig Mautner7d8df392012-04-06 15:26:23 -0700450 Slog.v(SURFACE_TAG, "setLayer: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700451 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700452
453 sSurfaces.remove(this);
454 int i;
455 for (i = sSurfaces.size() - 1; i >= 0; i--) {
Craig Mautner7d8df392012-04-06 15:26:23 -0700456 SurfaceTrace s = sSurfaces.get(i);
Craig Mautner7358fbf2012-04-12 21:06:33 -0700457 if (s.mLayer < zorder) {
458 break;
459 }
460 }
461 sSurfaces.add(i + 1, this);
462 }
463
464 @Override
465 public void setPosition(float x, float y) {
466 super.setPosition(x, y);
467 mPosition = new PointF(x, y);
Craig Mautner7d8df392012-04-06 15:26:23 -0700468 Slog.v(SURFACE_TAG, "setPosition: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700469 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700470 }
471
472 @Override
473 public void setSize(int w, int h) {
474 super.setSize(w, h);
475 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700476 Slog.v(SURFACE_TAG, "setSize: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700477 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700478 }
479
480 @Override
481 public void hide() {
482 super.hide();
483 mShown = false;
Craig Mautner7d8df392012-04-06 15:26:23 -0700484 Slog.v(SURFACE_TAG, "hide: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700485 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700486 }
487 @Override
488 public void show() {
489 super.show();
490 mShown = true;
Craig Mautner7d8df392012-04-06 15:26:23 -0700491 Slog.v(SURFACE_TAG, "show: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700492 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700493 }
494
495 @Override
496 public void destroy() {
497 super.destroy();
Craig Mautner7d8df392012-04-06 15:26:23 -0700498 Slog.v(SURFACE_TAG, "destroy: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700499 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700500 sSurfaces.remove(this);
501 }
502
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700503 @Override
504 public void release() {
505 super.release();
506 Slog.v(SURFACE_TAG, "release: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700507 + Debug.getCallers(3));
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700508 sSurfaces.remove(this);
509 }
510
Craig Mautner7358fbf2012-04-12 21:06:33 -0700511 static void dumpAllSurfaces() {
512 final int N = sSurfaces.size();
513 for (int i = 0; i < N; i++) {
514 Slog.i(TAG, "SurfaceDump: " + sSurfaces.get(i));
515 }
516 }
517
518 @Override
519 public String toString() {
Craig Mautnerfbf378c2012-04-23 17:24:21 -0700520 return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " "
521 + mName + ": shown=" + mShown + " layer=" + mLayer
Craig Mautner7d8df392012-04-06 15:26:23 -0700522 + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y
Craig Mautner7358fbf2012-04-12 21:06:33 -0700523 + " " + mSize.x + "x" + mSize.y;
524 }
525 }
526
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700527 Surface createSurfaceLocked() {
528 if (mSurface == null) {
529 mReportDestroySurface = false;
530 mSurfacePendingDestroy = false;
Craig Mautner83339b42012-05-01 22:13:23 -0700531 if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG,
532 "createSurface " + this + ": mDrawState=DRAW_PENDING");
Craig Mautner749a7bb2012-04-02 13:49:53 -0700533 mDrawState = DRAW_PENDING;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700534 if (mWin.mAppToken != null) {
535 mWin.mAppToken.allDrawn = false;
536 }
537
538 mService.makeWindowFreezingScreenIfNeededLocked(mWin);
539
540 int flags = 0;
541 final WindowManager.LayoutParams attrs = mWin.mAttrs;
542
543 if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
544 flags |= Surface.SECURE;
545 }
546 if (WindowState.DEBUG_VISIBILITY) Slog.v(
547 TAG, "Creating surface in session "
548 + mSession.mSurfaceSession + " window " + this
549 + " w=" + mWin.mCompatFrame.width()
550 + " h=" + mWin.mCompatFrame.height() + " format="
551 + attrs.format + " flags=" + flags);
552
553 int w = mWin.mCompatFrame.width();
554 int h = mWin.mCompatFrame.height();
555 if ((attrs.flags & LayoutParams.FLAG_SCALED) != 0) {
556 // for a scaled surface, we always want the requested
557 // size.
558 w = mWin.mRequestedWidth;
559 h = mWin.mRequestedHeight;
560 }
561
562 // Something is wrong and SurfaceFlinger will not like this,
563 // try to revert to sane values
564 if (w <= 0) w = 1;
565 if (h <= 0) h = 1;
566
567 mSurfaceShown = false;
568 mSurfaceLayer = 0;
Craig Mautner7d8df392012-04-06 15:26:23 -0700569 mSurfaceAlpha = 0;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700570 mSurfaceX = 0;
571 mSurfaceY = 0;
572 mSurfaceW = w;
573 mSurfaceH = h;
574 try {
575 final boolean isHwAccelerated = (attrs.flags &
576 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
577 final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
578 if (!PixelFormat.formatHasAlpha(attrs.format)) {
579 flags |= Surface.OPAQUE;
580 }
Craig Mautner7358fbf2012-04-12 21:06:33 -0700581 if (DEBUG_SURFACE_TRACE) {
Craig Mautner7d8df392012-04-06 15:26:23 -0700582 mSurface = new SurfaceTrace(
Craig Mautner7358fbf2012-04-12 21:06:33 -0700583 mSession.mSurfaceSession, mSession.mPid,
584 attrs.getTitle().toString(),
585 0, w, h, format, flags);
586 } else {
587 mSurface = new Surface(
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700588 mSession.mSurfaceSession, mSession.mPid,
589 attrs.getTitle().toString(),
590 0, w, h, format, flags);
Craig Mautner7358fbf2012-04-12 21:06:33 -0700591 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700592 mWin.mHasSurface = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700593 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG,
594 " CREATE SURFACE "
595 + mSurface + " IN SESSION "
596 + mSession.mSurfaceSession
597 + ": pid=" + mSession.mPid + " format="
598 + attrs.format + " flags=0x"
599 + Integer.toHexString(flags)
600 + " / " + this);
601 } catch (Surface.OutOfResourcesException e) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700602 mWin.mHasSurface = false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700603 Slog.w(TAG, "OutOfResourcesException creating surface");
604 mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700605 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700606 return null;
607 } catch (Exception e) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700608 mWin.mHasSurface = false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700609 Slog.e(TAG, "Exception creating surface", e);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700610 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700611 return null;
612 }
613
614 if (WindowManagerService.localLOGV) Slog.v(
615 TAG, "Got surface: " + mSurface
616 + ", set left=" + mWin.mFrame.left + " top=" + mWin.mFrame.top
617 + ", animLayer=" + mAnimLayer);
618 if (SHOW_LIGHT_TRANSACTIONS) {
619 Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked");
620 WindowManagerService.logSurface(mWin, "CREATE pos=("
621 + mWin.mFrame.left + "," + mWin.mFrame.top + ") ("
622 + mWin.mCompatFrame.width() + "x" + mWin.mCompatFrame.height()
623 + "), layer=" + mAnimLayer + " HIDE", null);
624 }
625 Surface.openTransaction();
626 try {
627 try {
628 mSurfaceX = mWin.mFrame.left + mWin.mXOffset;
629 mSurfaceY = mWin.mFrame.top + mWin.mYOffset;
630 mSurface.setPosition(mSurfaceX, mSurfaceY);
631 mSurfaceLayer = mAnimLayer;
632 mSurface.setLayer(mAnimLayer);
Craig Mautner7d8df392012-04-06 15:26:23 -0700633 mSurface.setAlpha(0);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700634 mSurfaceShown = false;
635 mSurface.hide();
636 if ((mWin.mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) {
637 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "DITHER", null);
638 mSurface.setFlags(Surface.SURFACE_DITHER, Surface.SURFACE_DITHER);
639 }
640 } catch (RuntimeException e) {
641 Slog.w(TAG, "Error creating surface in " + w, e);
642 mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true);
643 }
Craig Mautner749a7bb2012-04-02 13:49:53 -0700644 mLastHidden = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700645 } finally {
646 Surface.closeTransaction();
647 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
648 "<<< CLOSE TRANSACTION createSurfaceLocked");
649 }
650 if (WindowManagerService.localLOGV) Slog.v(
651 TAG, "Created surface " + this);
652 }
653 return mSurface;
654 }
655
656 void destroySurfaceLocked() {
657 if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) {
658 mWin.mAppToken.startingDisplayed = false;
659 }
660
Craig Mautner749a7bb2012-04-02 13:49:53 -0700661 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700662 if (mSurface != null) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700663
664 int i = mWin.mChildWindows.size();
665 while (i > 0) {
666 i--;
667 WindowState c = mWin.mChildWindows.get(i);
668 c.mAttachedHidden = true;
669 }
670
671 if (mReportDestroySurface) {
672 mReportDestroySurface = false;
673 mSurfacePendingDestroy = true;
674 try {
675 mWin.mClient.dispatchGetNewSurface();
676 // We'll really destroy on the next time around.
677 return;
678 } catch (RemoteException e) {
679 }
680 }
681
682 try {
683 if (DEBUG_VISIBILITY) {
684 RuntimeException e = null;
685 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
686 e = new RuntimeException();
687 e.fillInStackTrace();
688 }
689 Slog.w(TAG, "Window " + this + " destroying surface "
690 + mSurface + ", session " + mSession, e);
691 }
692 if (mSurfaceDestroyDeferred) {
693 if (mSurface != null && mPendingDestroySurface != mSurface) {
694 if (mPendingDestroySurface != null) {
695 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
696 RuntimeException e = null;
697 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
698 e = new RuntimeException();
699 e.fillInStackTrace();
700 }
701 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e);
702 }
703 mPendingDestroySurface.destroy();
704 }
705 mPendingDestroySurface = mSurface;
706 }
707 } else {
708 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
709 RuntimeException e = null;
710 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
711 e = new RuntimeException();
712 e.fillInStackTrace();
713 }
714 WindowManagerService.logSurface(mWin, "DESTROY", e);
715 }
716 mSurface.destroy();
717 }
718 } catch (RuntimeException e) {
719 Slog.w(TAG, "Exception thrown when destroying Window " + this
720 + " surface " + mSurface + " session " + mSession
721 + ": " + e.toString());
722 }
723
724 mSurfaceShown = false;
725 mSurface = null;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700726 mWin.mHasSurface =false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700727 }
728 }
729
730 void destroyDeferredSurfaceLocked() {
731 try {
732 if (mPendingDestroySurface != null) {
733 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
734 RuntimeException e = null;
735 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
736 e = new RuntimeException();
737 e.fillInStackTrace();
738 }
739 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e);
740 }
741 mPendingDestroySurface.destroy();
742 }
743 } catch (RuntimeException e) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700744 Slog.w(TAG, "Exception thrown when destroying Window "
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700745 + this + " surface " + mPendingDestroySurface
746 + " session " + mSession + ": " + e.toString());
747 }
748 mSurfaceDestroyDeferred = false;
749 mPendingDestroySurface = null;
750 }
751
752 void computeShownFrameLocked() {
753 final boolean selfTransformation = mHasLocalTransformation;
754 Transformation attachedTransformation =
755 (mAttachedWindow != null && mAttachedWindow.mWinAnimator.mHasLocalTransformation)
756 ? mAttachedWindow.mWinAnimator.mTransformation : null;
Craig Mautner59431632012-04-04 11:56:44 -0700757 final AppWindowAnimator appAnimator =
758 mWin.mAppToken == null ? null : mWin.mAppToken.mAppAnimator;
759 Transformation appTransformation = (appAnimator != null && appAnimator.hasTransformation)
760 ? appAnimator.transformation : null;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700761
762 // Wallpapers are animated based on the "real" window they
763 // are currently targeting.
764 if (mWin.mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null
765 && mService.mWallpaperTarget != null) {
766 if (mService.mWallpaperTarget.mWinAnimator.mHasLocalTransformation &&
767 mService.mWallpaperTarget.mWinAnimator.mAnimation != null &&
768 !mService.mWallpaperTarget.mWinAnimator.mAnimation.getDetachWallpaper()) {
769 attachedTransformation = mService.mWallpaperTarget.mWinAnimator.mTransformation;
770 if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) {
771 Slog.v(TAG, "WP target attached xform: " + attachedTransformation);
772 }
773 }
Craig Mautner59431632012-04-04 11:56:44 -0700774 final AppWindowAnimator wpAppAnimator = mService.mWallpaperTarget.mAppToken == null
775 ? null : mService.mWallpaperTarget.mAppToken.mAppAnimator;
776 if (wpAppAnimator != null &&
777 wpAppAnimator.hasTransformation &&
778 wpAppAnimator.animation != null &&
779 !wpAppAnimator.animation.getDetachWallpaper()) {
780 appTransformation = wpAppAnimator.transformation;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700781 if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) {
782 Slog.v(TAG, "WP target app xform: " + appTransformation);
783 }
784 }
785 }
786
787 final boolean screenAnimation = mService.mAnimator.mScreenRotationAnimation != null
788 && mService.mAnimator.mScreenRotationAnimation.isAnimating();
789 if (selfTransformation || attachedTransformation != null
790 || appTransformation != null || screenAnimation) {
791 // cache often used attributes locally
792 final Rect frame = mWin.mFrame;
793 final float tmpFloats[] = mService.mTmpFloats;
794 final Matrix tmpMatrix = mWin.mTmpMatrix;
795
796 // Compute the desired transformation.
797 if (screenAnimation) {
798 // If we are doing a screen animation, the global rotation
799 // applied to windows can result in windows that are carefully
800 // aligned with each other to slightly separate, allowing you
801 // to see what is behind them. An unsightly mess. This...
802 // thing... magically makes it call good: scale each window
803 // slightly (two pixels larger in each dimension, from the
804 // window's center).
805 final float w = frame.width();
806 final float h = frame.height();
807 if (w>=1 && h>=1) {
808 tmpMatrix.setScale(1 + 2/w, 1 + 2/h, w/2, h/2);
809 } else {
810 tmpMatrix.reset();
811 }
812 } else {
813 tmpMatrix.reset();
814 }
815 tmpMatrix.postScale(mWin.mGlobalScale, mWin.mGlobalScale);
816 if (selfTransformation) {
817 tmpMatrix.postConcat(mTransformation.getMatrix());
818 }
819 tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset);
820 if (attachedTransformation != null) {
821 tmpMatrix.postConcat(attachedTransformation.getMatrix());
822 }
823 if (appTransformation != null) {
824 tmpMatrix.postConcat(appTransformation.getMatrix());
825 }
826 if (screenAnimation) {
827 tmpMatrix.postConcat(
828 mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getMatrix());
829 }
830
831 // "convert" it into SurfaceFlinger's format
832 // (a 2x2 matrix + an offset)
833 // Here we must not transform the position of the surface
834 // since it is already included in the transformation.
835 //Slog.i(TAG, "Transform: " + matrix);
836
837 mHaveMatrix = true;
838 tmpMatrix.getValues(tmpFloats);
839 mDsDx = tmpFloats[Matrix.MSCALE_X];
840 mDtDx = tmpFloats[Matrix.MSKEW_Y];
841 mDsDy = tmpFloats[Matrix.MSKEW_X];
842 mDtDy = tmpFloats[Matrix.MSCALE_Y];
843 float x = tmpFloats[Matrix.MTRANS_X];
844 float y = tmpFloats[Matrix.MTRANS_Y];
845 int w = frame.width();
846 int h = frame.height();
847 mWin.mShownFrame.set(x, y, x+w, y+h);
848
849 // Now set the alpha... but because our current hardware
850 // can't do alpha transformation on a non-opaque surface,
851 // turn it off if we are running an animation that is also
852 // transforming since it is more important to have that
853 // animation be smooth.
854 mShownAlpha = mAlpha;
855 if (!mService.mLimitedAlphaCompositing
856 || (!PixelFormat.formatHasAlpha(mWin.mAttrs.format)
857 || (mWin.isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy)
858 && x == frame.left && y == frame.top))) {
859 //Slog.i(TAG, "Applying alpha transform");
860 if (selfTransformation) {
861 mShownAlpha *= mTransformation.getAlpha();
862 }
863 if (attachedTransformation != null) {
864 mShownAlpha *= attachedTransformation.getAlpha();
865 }
866 if (appTransformation != null) {
867 mShownAlpha *= appTransformation.getAlpha();
868 }
869 if (screenAnimation) {
870 mShownAlpha *=
871 mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getAlpha();
872 }
873 } else {
874 //Slog.i(TAG, "Not applying alpha transform");
875 }
876
877 if (WindowManagerService.localLOGV) Slog.v(
878 TAG, "computeShownFrameLocked: Animating " + this +
879 ": " + mWin.mShownFrame +
880 ", alpha=" + mTransformation.getAlpha() + ", mShownAlpha=" + mShownAlpha);
881 return;
Craig Mautner4d7349b2012-04-20 14:52:47 -0700882 } else if (mWin.mIsWallpaper &&
883 (mAnimator.mPendingActions & WindowAnimator.WALLPAPER_ACTION_PENDING) != 0) {
884 return;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700885 }
886
887 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautner4d7349b2012-04-20 14:52:47 -0700888 TAG, "computeShownFrameLocked: " + this +
889 " not attached, mAlpha=" + mAlpha);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700890 mWin.mShownFrame.set(mWin.mFrame);
891 if (mWin.mXOffset != 0 || mWin.mYOffset != 0) {
892 mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset);
893 }
894 mShownAlpha = mAlpha;
895 mHaveMatrix = false;
896 mDsDx = mWin.mGlobalScale;
897 mDtDx = 0;
898 mDsDy = 0;
899 mDtDy = mWin.mGlobalScale;
900 }
Craig Mautnerd87946b2012-03-29 18:00:19 -0700901
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700902 void setSurfaceBoundaries(final boolean recoveringMemory) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700903 final WindowState w = mWin;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700904 int width, height;
905 if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
906 // for a scaled surface, we just want to use
907 // the requested size.
908 width = w.mRequestedWidth;
909 height = w.mRequestedHeight;
910 } else {
911 width = w.mCompatFrame.width();
912 height = w.mCompatFrame.height();
913 }
914
915 if (width < 1) {
916 width = 1;
917 }
918 if (height < 1) {
919 height = 1;
920 }
921 final boolean surfaceResized = mSurfaceW != width || mSurfaceH != height;
922 if (surfaceResized) {
923 mSurfaceW = width;
924 mSurfaceH = height;
925 }
926
Craig Mautner4d7349b2012-04-20 14:52:47 -0700927 final float left = w.mShownFrame.left;
928 final float top = w.mShownFrame.top;
929 if (mSurfaceX != left || mSurfaceY != top) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700930 try {
931 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
Craig Mautner4d7349b2012-04-20 14:52:47 -0700932 "POS " + left + ", " + top, null);
933 mSurfaceX = left;
934 mSurfaceY = top;
935 mSurface.setPosition(left, top);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700936 } catch (RuntimeException e) {
937 Slog.w(TAG, "Error positioning surface of " + w
Craig Mautner4d7349b2012-04-20 14:52:47 -0700938 + " pos=(" + left
939 + "," + top + ")", e);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700940 if (!recoveringMemory) {
941 mService.reclaimSomeSurfaceMemoryLocked(this, "position", true);
942 }
943 }
944 }
945
946 if (surfaceResized) {
947 try {
948 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
949 "SIZE " + width + "x" + height, null);
950 mSurfaceResized = true;
951 mSurface.setSize(width, height);
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700952 mAnimator.mPendingLayoutChanges |=
953 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700954 } catch (RuntimeException e) {
955 // If something goes wrong with the surface (such
956 // as running out of memory), don't take down the
957 // entire system.
958 Slog.e(TAG, "Error resizing surface of " + w
959 + " size=(" + width + "x" + height + ")", e);
960 if (!recoveringMemory) {
961 mService.reclaimSomeSurfaceMemoryLocked(this, "size", true);
962 }
963 }
964 }
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700965 }
966
967 public void prepareSurfaceLocked(final boolean recoveringMemory) {
968 final WindowState w = mWin;
969 if (mSurface == null) {
970 if (w.mOrientationChanging) {
971 if (DEBUG_ORIENTATION) {
972 Slog.v(TAG, "Orientation change skips hidden " + w);
973 }
974 w.mOrientationChanging = false;
975 }
976 return;
977 }
978
979 boolean displayed = false;
980
981 computeShownFrameLocked();
982
983 setSurfaceBoundaries(recoveringMemory);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700984
Craig Mautnerde6198e2012-04-19 09:59:31 -0700985 if (w.mAttachedHidden || !w.isReadyForDisplay()) {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700986 if (!mLastHidden) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700987 //dump();
Craig Mautner749a7bb2012-04-02 13:49:53 -0700988 mLastHidden = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700989 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
990 "HIDE (performLayout)", null);
991 if (mSurface != null) {
992 mSurfaceShown = false;
993 try {
994 mSurface.hide();
995 } catch (RuntimeException e) {
996 Slog.w(TAG, "Exception hiding surface in " + w);
997 }
998 }
999 }
1000 // If we are waiting for this window to handle an
1001 // orientation change, well, it is hidden, so
1002 // doesn't really matter. Note that this does
1003 // introduce a potential glitch if the window
1004 // becomes unhidden before it has drawn for the
1005 // new orientation.
1006 if (w.mOrientationChanging) {
1007 w.mOrientationChanging = false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001008 if (DEBUG_ORIENTATION) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001009 "Orientation change skips hidden " + w);
1010 }
1011 } else if (mLastLayer != mAnimLayer
1012 || mLastAlpha != mShownAlpha
1013 || mLastDsDx != mDsDx
1014 || mLastDtDx != mDtDx
1015 || mLastDsDy != mDsDy
1016 || mLastDtDy != mDtDy
1017 || w.mLastHScale != w.mHScale
1018 || w.mLastVScale != w.mVScale
Craig Mautner749a7bb2012-04-02 13:49:53 -07001019 || mLastHidden) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001020 displayed = true;
1021 mLastAlpha = mShownAlpha;
1022 mLastLayer = mAnimLayer;
1023 mLastDsDx = mDsDx;
1024 mLastDtDx = mDtDx;
1025 mLastDsDy = mDsDy;
1026 mLastDtDy = mDtDy;
1027 w.mLastHScale = w.mHScale;
1028 w.mLastVScale = w.mVScale;
1029 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
1030 "alpha=" + mShownAlpha + " layer=" + mAnimLayer
1031 + " matrix=[" + (mDsDx*w.mHScale)
1032 + "," + (mDtDx*w.mVScale)
1033 + "][" + (mDsDy*w.mHScale)
1034 + "," + (mDtDy*w.mVScale) + "]", null);
1035 if (mSurface != null) {
1036 try {
1037 mSurfaceAlpha = mShownAlpha;
1038 mSurface.setAlpha(mShownAlpha);
1039 mSurfaceLayer = w.mWinAnimator.mAnimLayer;
1040 mSurface.setLayer(w.mWinAnimator.mAnimLayer);
1041 mSurface.setMatrix(
1042 mDsDx*w.mHScale, mDtDx*w.mVScale,
1043 mDsDy*w.mHScale, mDtDy*w.mVScale);
Craig Mautner749a7bb2012-04-02 13:49:53 -07001044
1045 if (mLastHidden && mDrawState == HAS_DRAWN) {
1046 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
1047 "SHOW (performLayout)", null);
1048 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w
1049 + " during relayout");
1050 if (showSurfaceRobustlyLocked()) {
1051 mLastHidden = false;
1052 } else {
1053 w.mOrientationChanging = false;
1054 }
1055 }
1056 if (mSurface != null) {
1057 w.mToken.hasVisible = true;
1058 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001059 } catch (RuntimeException e) {
1060 Slog.w(TAG, "Error updating surface in " + w, e);
1061 if (!recoveringMemory) {
1062 mService.reclaimSomeSurfaceMemoryLocked(this, "update", true);
1063 }
1064 }
1065 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001066 } else {
Craig Mautner83339b42012-05-01 22:13:23 -07001067 if (DEBUG_ANIM) {
1068 Slog.v(TAG, "prepareSurface: No changes in animation for " + mWin);
1069 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001070 displayed = true;
1071 }
1072
1073 if (displayed) {
1074 if (w.mOrientationChanging) {
1075 if (!w.isDrawnLw()) {
Craig Mautnerd09cc4b2012-04-04 10:23:31 -07001076 mAnimator.mBulkUpdateParams |= CLEAR_ORIENTATION_CHANGE_COMPLETE;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001077 if (DEBUG_ORIENTATION) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001078 "Orientation continue waiting for draw in " + w);
1079 } else {
1080 w.mOrientationChanging = false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001081 if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001082 }
1083 }
1084 w.mToken.hasVisible = true;
1085 }
1086 }
1087
Craig Mautner48ba1e72012-04-02 13:18:16 -07001088 void setTransparentRegionHint(final Region region) {
Craig Mautner1f4e0cc2012-04-10 14:24:38 -07001089 if (mSurface == null) {
1090 Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true");
1091 return;
1092 }
Craig Mautner48ba1e72012-04-02 13:18:16 -07001093 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
1094 ">>> OPEN TRANSACTION setTransparentRegion");
1095 Surface.openTransaction();
1096 try {
1097 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
1098 "transparentRegionHint=" + region, null);
1099 mSurface.setTransparentRegionHint(region);
1100 } finally {
1101 Surface.closeTransaction();
1102 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
1103 "<<< CLOSE TRANSACTION setTransparentRegion");
1104 }
1105 }
1106
1107 void setWallpaperOffset(int left, int top) {
1108 Surface.openTransaction();
1109 try {
1110 mSurfaceX = left;
1111 mSurfaceY = top;
1112 mSurface.setPosition(left, top);
1113 } catch (RuntimeException e) {
1114 Slog.w(TAG, "Error positioning surface of " + mWin
1115 + " pos=(" + left + "," + top + ")", e);
1116 }
1117 Surface.closeTransaction();
1118 }
1119
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001120 // This must be called while inside a transaction.
1121 boolean performShowLocked() {
1122 if (DEBUG_VISIBILITY) {
1123 RuntimeException e = null;
1124 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
1125 e = new RuntimeException();
1126 e.fillInStackTrace();
1127 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001128 Slog.v(TAG, "performShow on " + this
Craig Mautner749a7bb2012-04-02 13:49:53 -07001129 + ": mDrawState=" + mDrawState + " readyForDisplay="
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001130 + mWin.isReadyForDisplay()
1131 + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING), e);
1132 }
Craig Mautner749a7bb2012-04-02 13:49:53 -07001133 if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplay()) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001134 if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001135 WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null);
Craig Mautnerd87946b2012-03-29 18:00:19 -07001136 if (DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + this
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001137 + " during animation: policyVis=" + mWin.mPolicyVisibility
1138 + " attHidden=" + mWin.mAttachedHidden
1139 + " tok.hiddenRequested="
1140 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false)
1141 + " tok.hidden="
1142 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false)
1143 + " animating=" + mAnimating
1144 + " tok animating="
Craig Mautner59431632012-04-04 11:56:44 -07001145 + (mWin.mAppToken != null ? mWin.mAppToken.mAppAnimator.animating : false));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001146
1147 mService.enableScreenIfNeededLocked();
1148
1149 applyEnterAnimationLocked();
1150
Craig Mautnerde6198e2012-04-19 09:59:31 -07001151 // Force the show in the next prepareSurfaceLocked() call.
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001152 mLastAlpha = -1;
Craig Mautner83339b42012-05-01 22:13:23 -07001153 if (DEBUG_ANIM) Slog.v(TAG, "performShowLocked: mDrawState=HAS_DRAWN");
Craig Mautner749a7bb2012-04-02 13:49:53 -07001154 mDrawState = HAS_DRAWN;
Craig Mautnerde6198e2012-04-19 09:59:31 -07001155 mService.scheduleAnimationLocked();
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001156
1157 int i = mWin.mChildWindows.size();
1158 while (i > 0) {
1159 i--;
1160 WindowState c = mWin.mChildWindows.get(i);
1161 if (c.mAttachedHidden) {
1162 c.mAttachedHidden = false;
1163 if (c.mWinAnimator.mSurface != null) {
1164 c.mWinAnimator.performShowLocked();
1165 // It hadn't been shown, which means layout not
1166 // performed on it, so now we want to make sure to
1167 // do a layout. If called from within the transaction
1168 // loop, this will cause it to restart with a new
1169 // layout.
1170 mService.mLayoutNeeded = true;
1171 }
1172 }
1173 }
1174
1175 if (mWin.mAttrs.type != TYPE_APPLICATION_STARTING
1176 && mWin.mAppToken != null) {
1177 mWin.mAppToken.firstWindowDrawn = true;
1178
1179 if (mWin.mAppToken.startingData != null) {
1180 if (WindowManagerService.DEBUG_STARTING_WINDOW ||
Craig Mautnerd87946b2012-03-29 18:00:19 -07001181 WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001182 "Finish starting " + mWin.mToken
1183 + ": first real window is shown, no animation");
1184 // If this initial window is animating, stop it -- we
1185 // will do an animation to reveal it from behind the
1186 // starting window, so there is no need for it to also
1187 // be doing its own stuff.
Craig Mautner4d7349b2012-04-20 14:52:47 -07001188 clearAnimation();
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001189 mService.mFinishedStarting.add(mWin.mAppToken);
1190 mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
1191 }
1192 mWin.mAppToken.updateReportedVisibilityLocked();
1193 }
1194
1195 return true;
1196 }
1197
1198 return false;
1199 }
1200
1201 /**
1202 * Have the surface flinger show a surface, robustly dealing with
1203 * error conditions. In particular, if there is not enough memory
1204 * to show the surface, then we will try to get rid of other surfaces
1205 * in order to succeed.
1206 *
1207 * @return Returns true if the surface was successfully shown.
1208 */
1209 boolean showSurfaceRobustlyLocked() {
1210 try {
1211 if (mSurface != null) {
1212 mSurfaceShown = true;
1213 mSurface.show();
1214 if (mWin.mTurnOnScreen) {
1215 if (DEBUG_VISIBILITY) Slog.v(TAG,
1216 "Show surface turning screen on: " + mWin);
1217 mWin.mTurnOnScreen = false;
Craig Mautner7d8df392012-04-06 15:26:23 -07001218 mAnimator.mBulkUpdateParams |= SET_TURN_ON_SCREEN;
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001219 }
1220 }
1221 return true;
1222 } catch (RuntimeException e) {
1223 Slog.w(TAG, "Failure showing surface " + mSurface + " in " + mWin, e);
1224 }
1225
1226 mService.reclaimSomeSurfaceMemoryLocked(this, "show", true);
1227
1228 return false;
1229 }
1230
1231 void applyEnterAnimationLocked() {
1232 final int transit;
1233 if (mEnterAnimationPending) {
1234 mEnterAnimationPending = false;
1235 transit = WindowManagerPolicy.TRANSIT_ENTER;
1236 } else {
1237 transit = WindowManagerPolicy.TRANSIT_SHOW;
1238 }
1239
1240 applyAnimationLocked(transit, true);
1241 }
1242
Craig Mautner48ba1e72012-04-02 13:18:16 -07001243 // TODO(cmautner): Move back to WindowState?
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001244 /**
1245 * Choose the correct animation and set it to the passed WindowState.
1246 * @param transit If WindowManagerPolicy.TRANSIT_PREVIEW_DONE and the app window has been drawn
1247 * then the animation will be app_starting_exit. Any other value loads the animation from
1248 * the switch statement below.
1249 * @param isEntrance The animation type the last time this was called. Used to keep from
1250 * loading the same animation twice.
1251 * @return true if an animation has been loaded.
1252 */
1253 boolean applyAnimationLocked(int transit, boolean isEntrance) {
1254 if (mLocalAnimating && mAnimationIsEntrance == isEntrance) {
1255 // If we are trying to apply an animation, but already running
1256 // an animation of the same type, then just leave that one alone.
1257 return true;
1258 }
1259
1260 // Only apply an animation if the display isn't frozen. If it is
1261 // frozen, there is no reason to animate and it can cause strange
1262 // artifacts when we unfreeze the display if some different animation
1263 // is running.
1264 if (mService.okToDisplay()) {
1265 int anim = mPolicy.selectAnimationLw(mWin, transit);
1266 int attr = -1;
1267 Animation a = null;
1268 if (anim != 0) {
1269 a = AnimationUtils.loadAnimation(mContext, anim);
1270 } else {
1271 switch (transit) {
1272 case WindowManagerPolicy.TRANSIT_ENTER:
1273 attr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation;
1274 break;
1275 case WindowManagerPolicy.TRANSIT_EXIT:
1276 attr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation;
1277 break;
1278 case WindowManagerPolicy.TRANSIT_SHOW:
1279 attr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation;
1280 break;
1281 case WindowManagerPolicy.TRANSIT_HIDE:
1282 attr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation;
1283 break;
1284 }
1285 if (attr >= 0) {
1286 a = mService.loadAnimation(mWin.mAttrs, attr);
1287 }
1288 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001289 if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001290 "applyAnimation: win=" + this
1291 + " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
Craig Mautner4d7349b2012-04-20 14:52:47 -07001292 + " a=" + a
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001293 + " mAnimation=" + mAnimation
Craig Mautner83339b42012-05-01 22:13:23 -07001294 + " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001295 if (a != null) {
1296 if (WindowManagerService.DEBUG_ANIM) {
1297 RuntimeException e = null;
1298 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
1299 e = new RuntimeException();
1300 e.fillInStackTrace();
1301 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001302 Slog.v(TAG, "Loaded animation " + a + " for " + this, e);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001303 }
1304 setAnimation(a);
1305 mAnimationIsEntrance = isEntrance;
1306 }
1307 } else {
1308 clearAnimation();
1309 }
1310
1311 return mAnimation != null;
1312 }
1313
Craig Mautnera2c77052012-03-26 12:14:43 -07001314 public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
1315 if (mAnimating || mLocalAnimating || mAnimationIsEntrance
1316 || mAnimation != null) {
1317 pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating);
1318 pw.print(" mLocalAnimating="); pw.print(mLocalAnimating);
1319 pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance);
1320 pw.print(" mAnimation="); pw.println(mAnimation);
1321 }
1322 if (mHasTransformation || mHasLocalTransformation) {
1323 pw.print(prefix); pw.print("XForm: has=");
1324 pw.print(mHasTransformation);
1325 pw.print(" hasLocal="); pw.print(mHasLocalTransformation);
1326 pw.print(" "); mTransformation.printShortString(pw);
1327 pw.println();
1328 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001329 if (mSurface != null) {
1330 if (dumpAll) {
1331 pw.print(prefix); pw.print("mSurface="); pw.println(mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -07001332 pw.print(prefix); pw.print("mDrawState="); pw.print(mDrawState);
1333 pw.print(" mLastHidden="); pw.println(mLastHidden);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001334 }
1335 pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown);
1336 pw.print(" layer="); pw.print(mSurfaceLayer);
1337 pw.print(" alpha="); pw.print(mSurfaceAlpha);
1338 pw.print(" rect=("); pw.print(mSurfaceX);
1339 pw.print(","); pw.print(mSurfaceY);
1340 pw.print(") "); pw.print(mSurfaceW);
1341 pw.print(" x "); pw.println(mSurfaceH);
1342 }
1343 if (mPendingDestroySurface != null) {
1344 pw.print(prefix); pw.print("mPendingDestroySurface=");
1345 pw.println(mPendingDestroySurface);
1346 }
1347 if (mSurfaceResized || mSurfaceDestroyDeferred) {
1348 pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized);
1349 pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred);
1350 }
1351 if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) {
1352 pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha);
1353 pw.print(" mAlpha="); pw.print(mAlpha);
1354 pw.print(" mLastAlpha="); pw.println(mLastAlpha);
1355 }
1356 if (mHaveMatrix || mWin.mGlobalScale != 1) {
1357 pw.print(prefix); pw.print("mGlobalScale="); pw.print(mWin.mGlobalScale);
1358 pw.print(" mDsDx="); pw.print(mDsDx);
1359 pw.print(" mDtDx="); pw.print(mDtDx);
1360 pw.print(" mDsDy="); pw.print(mDsDy);
1361 pw.print(" mDtDy="); pw.println(mDtDy);
1362 }
Craig Mautnera2c77052012-03-26 12:14:43 -07001363 }
1364
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001365 @Override
1366 public String toString() {
1367 StringBuffer sb = new StringBuffer("WindowStateAnimator (");
1368 sb.append(mWin.mLastTitle + "): ");
1369 sb.append("mSurface " + mSurface);
1370 sb.append(", mAnimation " + mAnimation);
1371 return sb.toString();
1372 }
Craig Mautnera2c77052012-03-26 12:14:43 -07001373}