blob: 9147a10626901deb95d2fd90411f4ab33162b815 [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 Mautner48ba1e72012-04-02 13:18:16 -0700383 if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
Craig Mautnera608b882012-03-30 13:03:49 -0700384 TAG, "finishDrawingLocked: " + this + " in " + mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700385 mDrawState = COMMIT_DRAW_PENDING;
Craig Mautnera608b882012-03-30 13:03:49 -0700386 return true;
387 }
388 return false;
389 }
390
391 // This must be called while inside a transaction.
392 boolean commitFinishDrawingLocked(long currentTime) {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700393 if (mDrawState != COMMIT_DRAW_PENDING) {
Craig Mautnera608b882012-03-30 13:03:49 -0700394 return false;
395 }
Craig Mautnerfbf378c2012-04-23 17:24:21 -0700396 //Slog.i(TAG, "commitFinishDrawingLocked: Draw pending. " + mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700397 mDrawState = READY_TO_SHOW;
Craig Mautnera608b882012-03-30 13:03:49 -0700398 final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
399 final AppWindowToken atoken = mWin.mAppToken;
400 if (atoken == null || atoken.allDrawn || starting) {
401 performShowLocked();
402 }
403 return true;
404 }
405
Craig Mautner7d8df392012-04-06 15:26:23 -0700406 static class SurfaceTrace extends Surface {
407 private final static String SURFACE_TAG = "SurfaceTrace";
408 final static ArrayList<SurfaceTrace> sSurfaces = new ArrayList<SurfaceTrace>();
Craig Mautner7358fbf2012-04-12 21:06:33 -0700409
Craig Mautner7d8df392012-04-06 15:26:23 -0700410 private float mSurfaceTraceAlpha = 0;
Craig Mautner7358fbf2012-04-12 21:06:33 -0700411 private int mLayer;
412 private PointF mPosition = new PointF();
Craig Mautner7d8df392012-04-06 15:26:23 -0700413 private Point mSize;
Craig Mautner7358fbf2012-04-12 21:06:33 -0700414 private boolean mShown = false;
415 private String mName = "Not named";
416
Craig Mautner7d8df392012-04-06 15:26:23 -0700417 public SurfaceTrace(SurfaceSession s,
Craig Mautner7358fbf2012-04-12 21:06:33 -0700418 int pid, int display, int w, int h, int format, int flags) throws
419 OutOfResourcesException {
420 super(s, pid, display, w, h, format, flags);
421 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700422 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700423 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700424 }
425
Craig Mautner7d8df392012-04-06 15:26:23 -0700426 public SurfaceTrace(SurfaceSession s,
Craig Mautner7358fbf2012-04-12 21:06:33 -0700427 int pid, String name, int display, int w, int h, int format, int flags)
428 throws OutOfResourcesException {
429 super(s, pid, name, display, w, h, format, flags);
430 mName = name;
431 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700432 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700433 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700434 }
435
436 @Override
437 public void setAlpha(float alpha) {
438 super.setAlpha(alpha);
Craig Mautner7d8df392012-04-06 15:26:23 -0700439 mSurfaceTraceAlpha = alpha;
440 Slog.v(SURFACE_TAG, "setAlpha: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700441 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700442 }
443
444 @Override
445 public void setLayer(int zorder) {
446 super.setLayer(zorder);
447 mLayer = zorder;
Craig Mautner7d8df392012-04-06 15:26:23 -0700448 Slog.v(SURFACE_TAG, "setLayer: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700449 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700450
451 sSurfaces.remove(this);
452 int i;
453 for (i = sSurfaces.size() - 1; i >= 0; i--) {
Craig Mautner7d8df392012-04-06 15:26:23 -0700454 SurfaceTrace s = sSurfaces.get(i);
Craig Mautner7358fbf2012-04-12 21:06:33 -0700455 if (s.mLayer < zorder) {
456 break;
457 }
458 }
459 sSurfaces.add(i + 1, this);
460 }
461
462 @Override
463 public void setPosition(float x, float y) {
464 super.setPosition(x, y);
465 mPosition = new PointF(x, y);
Craig Mautner7d8df392012-04-06 15:26:23 -0700466 Slog.v(SURFACE_TAG, "setPosition: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700467 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700468 }
469
470 @Override
471 public void setSize(int w, int h) {
472 super.setSize(w, h);
473 mSize = new Point(w, h);
Craig Mautner7d8df392012-04-06 15:26:23 -0700474 Slog.v(SURFACE_TAG, "setSize: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700475 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700476 }
477
478 @Override
479 public void hide() {
480 super.hide();
481 mShown = false;
Craig Mautner7d8df392012-04-06 15:26:23 -0700482 Slog.v(SURFACE_TAG, "hide: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700483 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700484 }
485 @Override
486 public void show() {
487 super.show();
488 mShown = true;
Craig Mautner7d8df392012-04-06 15:26:23 -0700489 Slog.v(SURFACE_TAG, "show: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700490 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700491 }
492
493 @Override
494 public void destroy() {
495 super.destroy();
Craig Mautner7d8df392012-04-06 15:26:23 -0700496 Slog.v(SURFACE_TAG, "destroy: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700497 + Debug.getCallers(3));
Craig Mautner7358fbf2012-04-12 21:06:33 -0700498 sSurfaces.remove(this);
499 }
500
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700501 @Override
502 public void release() {
503 super.release();
504 Slog.v(SURFACE_TAG, "release: " + this + ". Called by "
Craig Mautnera51a9562012-04-17 17:05:26 -0700505 + Debug.getCallers(3));
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700506 sSurfaces.remove(this);
507 }
508
Craig Mautner7358fbf2012-04-12 21:06:33 -0700509 static void dumpAllSurfaces() {
510 final int N = sSurfaces.size();
511 for (int i = 0; i < N; i++) {
512 Slog.i(TAG, "SurfaceDump: " + sSurfaces.get(i));
513 }
514 }
515
516 @Override
517 public String toString() {
Craig Mautnerfbf378c2012-04-23 17:24:21 -0700518 return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " "
519 + mName + ": shown=" + mShown + " layer=" + mLayer
Craig Mautner7d8df392012-04-06 15:26:23 -0700520 + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y
Craig Mautner7358fbf2012-04-12 21:06:33 -0700521 + " " + mSize.x + "x" + mSize.y;
522 }
523 }
524
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700525 Surface createSurfaceLocked() {
526 if (mSurface == null) {
527 mReportDestroySurface = false;
528 mSurfacePendingDestroy = false;
Craig Mautner48ba1e72012-04-02 13:18:16 -0700529 if (DEBUG_ORIENTATION) Slog.i(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700530 "createSurface " + this + ": DRAW NOW PENDING");
Craig Mautner749a7bb2012-04-02 13:49:53 -0700531 mDrawState = DRAW_PENDING;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700532 if (mWin.mAppToken != null) {
533 mWin.mAppToken.allDrawn = false;
534 }
535
536 mService.makeWindowFreezingScreenIfNeededLocked(mWin);
537
538 int flags = 0;
539 final WindowManager.LayoutParams attrs = mWin.mAttrs;
540
541 if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) {
542 flags |= Surface.SECURE;
543 }
544 if (WindowState.DEBUG_VISIBILITY) Slog.v(
545 TAG, "Creating surface in session "
546 + mSession.mSurfaceSession + " window " + this
547 + " w=" + mWin.mCompatFrame.width()
548 + " h=" + mWin.mCompatFrame.height() + " format="
549 + attrs.format + " flags=" + flags);
550
551 int w = mWin.mCompatFrame.width();
552 int h = mWin.mCompatFrame.height();
553 if ((attrs.flags & LayoutParams.FLAG_SCALED) != 0) {
554 // for a scaled surface, we always want the requested
555 // size.
556 w = mWin.mRequestedWidth;
557 h = mWin.mRequestedHeight;
558 }
559
560 // Something is wrong and SurfaceFlinger will not like this,
561 // try to revert to sane values
562 if (w <= 0) w = 1;
563 if (h <= 0) h = 1;
564
565 mSurfaceShown = false;
566 mSurfaceLayer = 0;
Craig Mautner7d8df392012-04-06 15:26:23 -0700567 mSurfaceAlpha = 0;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700568 mSurfaceX = 0;
569 mSurfaceY = 0;
570 mSurfaceW = w;
571 mSurfaceH = h;
572 try {
573 final boolean isHwAccelerated = (attrs.flags &
574 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
575 final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
576 if (!PixelFormat.formatHasAlpha(attrs.format)) {
577 flags |= Surface.OPAQUE;
578 }
Craig Mautner7358fbf2012-04-12 21:06:33 -0700579 if (DEBUG_SURFACE_TRACE) {
Craig Mautner7d8df392012-04-06 15:26:23 -0700580 mSurface = new SurfaceTrace(
Craig Mautner7358fbf2012-04-12 21:06:33 -0700581 mSession.mSurfaceSession, mSession.mPid,
582 attrs.getTitle().toString(),
583 0, w, h, format, flags);
584 } else {
585 mSurface = new Surface(
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700586 mSession.mSurfaceSession, mSession.mPid,
587 attrs.getTitle().toString(),
588 0, w, h, format, flags);
Craig Mautner7358fbf2012-04-12 21:06:33 -0700589 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700590 mWin.mHasSurface = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700591 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG,
592 " CREATE SURFACE "
593 + mSurface + " IN SESSION "
594 + mSession.mSurfaceSession
595 + ": pid=" + mSession.mPid + " format="
596 + attrs.format + " flags=0x"
597 + Integer.toHexString(flags)
598 + " / " + this);
599 } catch (Surface.OutOfResourcesException e) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700600 mWin.mHasSurface = false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700601 Slog.w(TAG, "OutOfResourcesException creating surface");
602 mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700603 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700604 return null;
605 } catch (Exception e) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700606 mWin.mHasSurface = false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700607 Slog.e(TAG, "Exception creating surface", e);
Craig Mautner749a7bb2012-04-02 13:49:53 -0700608 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700609 return null;
610 }
611
612 if (WindowManagerService.localLOGV) Slog.v(
613 TAG, "Got surface: " + mSurface
614 + ", set left=" + mWin.mFrame.left + " top=" + mWin.mFrame.top
615 + ", animLayer=" + mAnimLayer);
616 if (SHOW_LIGHT_TRANSACTIONS) {
617 Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked");
618 WindowManagerService.logSurface(mWin, "CREATE pos=("
619 + mWin.mFrame.left + "," + mWin.mFrame.top + ") ("
620 + mWin.mCompatFrame.width() + "x" + mWin.mCompatFrame.height()
621 + "), layer=" + mAnimLayer + " HIDE", null);
622 }
623 Surface.openTransaction();
624 try {
625 try {
626 mSurfaceX = mWin.mFrame.left + mWin.mXOffset;
627 mSurfaceY = mWin.mFrame.top + mWin.mYOffset;
628 mSurface.setPosition(mSurfaceX, mSurfaceY);
629 mSurfaceLayer = mAnimLayer;
630 mSurface.setLayer(mAnimLayer);
Craig Mautner7d8df392012-04-06 15:26:23 -0700631 mSurface.setAlpha(0);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700632 mSurfaceShown = false;
633 mSurface.hide();
634 if ((mWin.mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) {
635 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "DITHER", null);
636 mSurface.setFlags(Surface.SURFACE_DITHER, Surface.SURFACE_DITHER);
637 }
638 } catch (RuntimeException e) {
639 Slog.w(TAG, "Error creating surface in " + w, e);
640 mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true);
641 }
Craig Mautner749a7bb2012-04-02 13:49:53 -0700642 mLastHidden = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700643 } finally {
644 Surface.closeTransaction();
645 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
646 "<<< CLOSE TRANSACTION createSurfaceLocked");
647 }
648 if (WindowManagerService.localLOGV) Slog.v(
649 TAG, "Created surface " + this);
650 }
651 return mSurface;
652 }
653
654 void destroySurfaceLocked() {
655 if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) {
656 mWin.mAppToken.startingDisplayed = false;
657 }
658
Craig Mautner749a7bb2012-04-02 13:49:53 -0700659 mDrawState = NO_SURFACE;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700660 if (mSurface != null) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700661
662 int i = mWin.mChildWindows.size();
663 while (i > 0) {
664 i--;
665 WindowState c = mWin.mChildWindows.get(i);
666 c.mAttachedHidden = true;
667 }
668
669 if (mReportDestroySurface) {
670 mReportDestroySurface = false;
671 mSurfacePendingDestroy = true;
672 try {
673 mWin.mClient.dispatchGetNewSurface();
674 // We'll really destroy on the next time around.
675 return;
676 } catch (RemoteException e) {
677 }
678 }
679
680 try {
681 if (DEBUG_VISIBILITY) {
682 RuntimeException e = null;
683 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
684 e = new RuntimeException();
685 e.fillInStackTrace();
686 }
687 Slog.w(TAG, "Window " + this + " destroying surface "
688 + mSurface + ", session " + mSession, e);
689 }
690 if (mSurfaceDestroyDeferred) {
691 if (mSurface != null && mPendingDestroySurface != mSurface) {
692 if (mPendingDestroySurface != null) {
693 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
694 RuntimeException e = null;
695 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
696 e = new RuntimeException();
697 e.fillInStackTrace();
698 }
699 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e);
700 }
701 mPendingDestroySurface.destroy();
702 }
703 mPendingDestroySurface = mSurface;
704 }
705 } else {
706 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
707 RuntimeException e = null;
708 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
709 e = new RuntimeException();
710 e.fillInStackTrace();
711 }
712 WindowManagerService.logSurface(mWin, "DESTROY", e);
713 }
714 mSurface.destroy();
715 }
716 } catch (RuntimeException e) {
717 Slog.w(TAG, "Exception thrown when destroying Window " + this
718 + " surface " + mSurface + " session " + mSession
719 + ": " + e.toString());
720 }
721
722 mSurfaceShown = false;
723 mSurface = null;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700724 mWin.mHasSurface =false;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700725 }
726 }
727
728 void destroyDeferredSurfaceLocked() {
729 try {
730 if (mPendingDestroySurface != null) {
731 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
732 RuntimeException e = null;
733 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
734 e = new RuntimeException();
735 e.fillInStackTrace();
736 }
737 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e);
738 }
739 mPendingDestroySurface.destroy();
740 }
741 } catch (RuntimeException e) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700742 Slog.w(TAG, "Exception thrown when destroying Window "
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700743 + this + " surface " + mPendingDestroySurface
744 + " session " + mSession + ": " + e.toString());
745 }
746 mSurfaceDestroyDeferred = false;
747 mPendingDestroySurface = null;
748 }
749
750 void computeShownFrameLocked() {
751 final boolean selfTransformation = mHasLocalTransformation;
752 Transformation attachedTransformation =
753 (mAttachedWindow != null && mAttachedWindow.mWinAnimator.mHasLocalTransformation)
754 ? mAttachedWindow.mWinAnimator.mTransformation : null;
Craig Mautner59431632012-04-04 11:56:44 -0700755 final AppWindowAnimator appAnimator =
756 mWin.mAppToken == null ? null : mWin.mAppToken.mAppAnimator;
757 Transformation appTransformation = (appAnimator != null && appAnimator.hasTransformation)
758 ? appAnimator.transformation : null;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700759
760 // Wallpapers are animated based on the "real" window they
761 // are currently targeting.
762 if (mWin.mAttrs.type == TYPE_WALLPAPER && mService.mLowerWallpaperTarget == null
763 && mService.mWallpaperTarget != null) {
764 if (mService.mWallpaperTarget.mWinAnimator.mHasLocalTransformation &&
765 mService.mWallpaperTarget.mWinAnimator.mAnimation != null &&
766 !mService.mWallpaperTarget.mWinAnimator.mAnimation.getDetachWallpaper()) {
767 attachedTransformation = mService.mWallpaperTarget.mWinAnimator.mTransformation;
768 if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) {
769 Slog.v(TAG, "WP target attached xform: " + attachedTransformation);
770 }
771 }
Craig Mautner59431632012-04-04 11:56:44 -0700772 final AppWindowAnimator wpAppAnimator = mService.mWallpaperTarget.mAppToken == null
773 ? null : mService.mWallpaperTarget.mAppToken.mAppAnimator;
774 if (wpAppAnimator != null &&
775 wpAppAnimator.hasTransformation &&
776 wpAppAnimator.animation != null &&
777 !wpAppAnimator.animation.getDetachWallpaper()) {
778 appTransformation = wpAppAnimator.transformation;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700779 if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) {
780 Slog.v(TAG, "WP target app xform: " + appTransformation);
781 }
782 }
783 }
784
785 final boolean screenAnimation = mService.mAnimator.mScreenRotationAnimation != null
786 && mService.mAnimator.mScreenRotationAnimation.isAnimating();
787 if (selfTransformation || attachedTransformation != null
788 || appTransformation != null || screenAnimation) {
789 // cache often used attributes locally
790 final Rect frame = mWin.mFrame;
791 final float tmpFloats[] = mService.mTmpFloats;
792 final Matrix tmpMatrix = mWin.mTmpMatrix;
793
794 // Compute the desired transformation.
795 if (screenAnimation) {
796 // If we are doing a screen animation, the global rotation
797 // applied to windows can result in windows that are carefully
798 // aligned with each other to slightly separate, allowing you
799 // to see what is behind them. An unsightly mess. This...
800 // thing... magically makes it call good: scale each window
801 // slightly (two pixels larger in each dimension, from the
802 // window's center).
803 final float w = frame.width();
804 final float h = frame.height();
805 if (w>=1 && h>=1) {
806 tmpMatrix.setScale(1 + 2/w, 1 + 2/h, w/2, h/2);
807 } else {
808 tmpMatrix.reset();
809 }
810 } else {
811 tmpMatrix.reset();
812 }
813 tmpMatrix.postScale(mWin.mGlobalScale, mWin.mGlobalScale);
814 if (selfTransformation) {
815 tmpMatrix.postConcat(mTransformation.getMatrix());
816 }
817 tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset);
818 if (attachedTransformation != null) {
819 tmpMatrix.postConcat(attachedTransformation.getMatrix());
820 }
821 if (appTransformation != null) {
822 tmpMatrix.postConcat(appTransformation.getMatrix());
823 }
824 if (screenAnimation) {
825 tmpMatrix.postConcat(
826 mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getMatrix());
827 }
828
829 // "convert" it into SurfaceFlinger's format
830 // (a 2x2 matrix + an offset)
831 // Here we must not transform the position of the surface
832 // since it is already included in the transformation.
833 //Slog.i(TAG, "Transform: " + matrix);
834
835 mHaveMatrix = true;
836 tmpMatrix.getValues(tmpFloats);
837 mDsDx = tmpFloats[Matrix.MSCALE_X];
838 mDtDx = tmpFloats[Matrix.MSKEW_Y];
839 mDsDy = tmpFloats[Matrix.MSKEW_X];
840 mDtDy = tmpFloats[Matrix.MSCALE_Y];
841 float x = tmpFloats[Matrix.MTRANS_X];
842 float y = tmpFloats[Matrix.MTRANS_Y];
843 int w = frame.width();
844 int h = frame.height();
845 mWin.mShownFrame.set(x, y, x+w, y+h);
846
847 // Now set the alpha... but because our current hardware
848 // can't do alpha transformation on a non-opaque surface,
849 // turn it off if we are running an animation that is also
850 // transforming since it is more important to have that
851 // animation be smooth.
852 mShownAlpha = mAlpha;
853 if (!mService.mLimitedAlphaCompositing
854 || (!PixelFormat.formatHasAlpha(mWin.mAttrs.format)
855 || (mWin.isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy)
856 && x == frame.left && y == frame.top))) {
857 //Slog.i(TAG, "Applying alpha transform");
858 if (selfTransformation) {
859 mShownAlpha *= mTransformation.getAlpha();
860 }
861 if (attachedTransformation != null) {
862 mShownAlpha *= attachedTransformation.getAlpha();
863 }
864 if (appTransformation != null) {
865 mShownAlpha *= appTransformation.getAlpha();
866 }
867 if (screenAnimation) {
868 mShownAlpha *=
869 mService.mAnimator.mScreenRotationAnimation.getEnterTransformation().getAlpha();
870 }
871 } else {
872 //Slog.i(TAG, "Not applying alpha transform");
873 }
874
875 if (WindowManagerService.localLOGV) Slog.v(
876 TAG, "computeShownFrameLocked: Animating " + this +
877 ": " + mWin.mShownFrame +
878 ", alpha=" + mTransformation.getAlpha() + ", mShownAlpha=" + mShownAlpha);
879 return;
Craig Mautner4d7349b2012-04-20 14:52:47 -0700880 } else if (mWin.mIsWallpaper &&
881 (mAnimator.mPendingActions & WindowAnimator.WALLPAPER_ACTION_PENDING) != 0) {
882 return;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700883 }
884
885 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautner4d7349b2012-04-20 14:52:47 -0700886 TAG, "computeShownFrameLocked: " + this +
887 " not attached, mAlpha=" + mAlpha);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700888 mWin.mShownFrame.set(mWin.mFrame);
889 if (mWin.mXOffset != 0 || mWin.mYOffset != 0) {
890 mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset);
891 }
892 mShownAlpha = mAlpha;
893 mHaveMatrix = false;
894 mDsDx = mWin.mGlobalScale;
895 mDtDx = 0;
896 mDsDy = 0;
897 mDtDy = mWin.mGlobalScale;
898 }
Craig Mautnerd87946b2012-03-29 18:00:19 -0700899
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700900 void setSurfaceBoundaries(final boolean recoveringMemory) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700901 final WindowState w = mWin;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700902 int width, height;
903 if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
904 // for a scaled surface, we just want to use
905 // the requested size.
906 width = w.mRequestedWidth;
907 height = w.mRequestedHeight;
908 } else {
909 width = w.mCompatFrame.width();
910 height = w.mCompatFrame.height();
911 }
912
913 if (width < 1) {
914 width = 1;
915 }
916 if (height < 1) {
917 height = 1;
918 }
919 final boolean surfaceResized = mSurfaceW != width || mSurfaceH != height;
920 if (surfaceResized) {
921 mSurfaceW = width;
922 mSurfaceH = height;
923 }
924
Craig Mautner4d7349b2012-04-20 14:52:47 -0700925 final float left = w.mShownFrame.left;
926 final float top = w.mShownFrame.top;
927 if (mSurfaceX != left || mSurfaceY != top) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700928 try {
929 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
Craig Mautner4d7349b2012-04-20 14:52:47 -0700930 "POS " + left + ", " + top, null);
931 mSurfaceX = left;
932 mSurfaceY = top;
933 mSurface.setPosition(left, top);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700934 } catch (RuntimeException e) {
935 Slog.w(TAG, "Error positioning surface of " + w
Craig Mautner4d7349b2012-04-20 14:52:47 -0700936 + " pos=(" + left
937 + "," + top + ")", e);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700938 if (!recoveringMemory) {
939 mService.reclaimSomeSurfaceMemoryLocked(this, "position", true);
940 }
941 }
942 }
943
944 if (surfaceResized) {
945 try {
946 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
947 "SIZE " + width + "x" + height, null);
948 mSurfaceResized = true;
949 mSurface.setSize(width, height);
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700950 mAnimator.mPendingLayoutChanges |=
951 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700952 } catch (RuntimeException e) {
953 // If something goes wrong with the surface (such
954 // as running out of memory), don't take down the
955 // entire system.
956 Slog.e(TAG, "Error resizing surface of " + w
957 + " size=(" + width + "x" + height + ")", e);
958 if (!recoveringMemory) {
959 mService.reclaimSomeSurfaceMemoryLocked(this, "size", true);
960 }
961 }
962 }
Craig Mautneracaf9cc2012-04-17 11:45:25 -0700963 }
964
965 public void prepareSurfaceLocked(final boolean recoveringMemory) {
966 final WindowState w = mWin;
967 if (mSurface == null) {
968 if (w.mOrientationChanging) {
969 if (DEBUG_ORIENTATION) {
970 Slog.v(TAG, "Orientation change skips hidden " + w);
971 }
972 w.mOrientationChanging = false;
973 }
974 return;
975 }
976
977 boolean displayed = false;
978
979 computeShownFrameLocked();
980
981 setSurfaceBoundaries(recoveringMemory);
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700982
Craig Mautnerde6198e2012-04-19 09:59:31 -0700983 if (w.mAttachedHidden || !w.isReadyForDisplay()) {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700984 if (!mLastHidden) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700985 //dump();
Craig Mautner749a7bb2012-04-02 13:49:53 -0700986 mLastHidden = true;
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700987 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
988 "HIDE (performLayout)", null);
989 if (mSurface != null) {
990 mSurfaceShown = false;
991 try {
992 mSurface.hide();
993 } catch (RuntimeException e) {
994 Slog.w(TAG, "Exception hiding surface in " + w);
995 }
996 }
997 }
998 // If we are waiting for this window to handle an
999 // orientation change, well, it is hidden, so
1000 // doesn't really matter. Note that this does
1001 // introduce a potential glitch if the window
1002 // becomes unhidden before it has drawn for the
1003 // new orientation.
1004 if (w.mOrientationChanging) {
1005 w.mOrientationChanging = false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001006 if (DEBUG_ORIENTATION) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001007 "Orientation change skips hidden " + w);
1008 }
1009 } else if (mLastLayer != mAnimLayer
1010 || mLastAlpha != mShownAlpha
1011 || mLastDsDx != mDsDx
1012 || mLastDtDx != mDtDx
1013 || mLastDsDy != mDsDy
1014 || mLastDtDy != mDtDy
1015 || w.mLastHScale != w.mHScale
1016 || w.mLastVScale != w.mVScale
Craig Mautner749a7bb2012-04-02 13:49:53 -07001017 || mLastHidden) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001018 displayed = true;
1019 mLastAlpha = mShownAlpha;
1020 mLastLayer = mAnimLayer;
1021 mLastDsDx = mDsDx;
1022 mLastDtDx = mDtDx;
1023 mLastDsDy = mDsDy;
1024 mLastDtDy = mDtDy;
1025 w.mLastHScale = w.mHScale;
1026 w.mLastVScale = w.mVScale;
1027 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
1028 "alpha=" + mShownAlpha + " layer=" + mAnimLayer
1029 + " matrix=[" + (mDsDx*w.mHScale)
1030 + "," + (mDtDx*w.mVScale)
1031 + "][" + (mDsDy*w.mHScale)
1032 + "," + (mDtDy*w.mVScale) + "]", null);
1033 if (mSurface != null) {
1034 try {
1035 mSurfaceAlpha = mShownAlpha;
1036 mSurface.setAlpha(mShownAlpha);
1037 mSurfaceLayer = w.mWinAnimator.mAnimLayer;
1038 mSurface.setLayer(w.mWinAnimator.mAnimLayer);
1039 mSurface.setMatrix(
1040 mDsDx*w.mHScale, mDtDx*w.mVScale,
1041 mDsDy*w.mHScale, mDtDy*w.mVScale);
Craig Mautner749a7bb2012-04-02 13:49:53 -07001042
1043 if (mLastHidden && mDrawState == HAS_DRAWN) {
1044 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
1045 "SHOW (performLayout)", null);
1046 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w
1047 + " during relayout");
1048 if (showSurfaceRobustlyLocked()) {
1049 mLastHidden = false;
1050 } else {
1051 w.mOrientationChanging = false;
1052 }
1053 }
1054 if (mSurface != null) {
1055 w.mToken.hasVisible = true;
1056 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001057 } catch (RuntimeException e) {
1058 Slog.w(TAG, "Error updating surface in " + w, e);
1059 if (!recoveringMemory) {
1060 mService.reclaimSomeSurfaceMemoryLocked(this, "update", true);
1061 }
1062 }
1063 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001064 } else {
1065 displayed = true;
1066 }
1067
1068 if (displayed) {
1069 if (w.mOrientationChanging) {
1070 if (!w.isDrawnLw()) {
Craig Mautnerd09cc4b2012-04-04 10:23:31 -07001071 mAnimator.mBulkUpdateParams |= CLEAR_ORIENTATION_CHANGE_COMPLETE;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001072 if (DEBUG_ORIENTATION) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001073 "Orientation continue waiting for draw in " + w);
1074 } else {
1075 w.mOrientationChanging = false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001076 if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001077 }
1078 }
1079 w.mToken.hasVisible = true;
1080 }
1081 }
1082
Craig Mautner48ba1e72012-04-02 13:18:16 -07001083 void setTransparentRegionHint(final Region region) {
Craig Mautner1f4e0cc2012-04-10 14:24:38 -07001084 if (mSurface == null) {
1085 Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true");
1086 return;
1087 }
Craig Mautner48ba1e72012-04-02 13:18:16 -07001088 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
1089 ">>> OPEN TRANSACTION setTransparentRegion");
1090 Surface.openTransaction();
1091 try {
1092 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
1093 "transparentRegionHint=" + region, null);
1094 mSurface.setTransparentRegionHint(region);
1095 } finally {
1096 Surface.closeTransaction();
1097 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
1098 "<<< CLOSE TRANSACTION setTransparentRegion");
1099 }
1100 }
1101
1102 void setWallpaperOffset(int left, int top) {
1103 Surface.openTransaction();
1104 try {
1105 mSurfaceX = left;
1106 mSurfaceY = top;
1107 mSurface.setPosition(left, top);
1108 } catch (RuntimeException e) {
1109 Slog.w(TAG, "Error positioning surface of " + mWin
1110 + " pos=(" + left + "," + top + ")", e);
1111 }
1112 Surface.closeTransaction();
1113 }
1114
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001115 // This must be called while inside a transaction.
1116 boolean performShowLocked() {
1117 if (DEBUG_VISIBILITY) {
1118 RuntimeException e = null;
1119 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
1120 e = new RuntimeException();
1121 e.fillInStackTrace();
1122 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001123 Slog.v(TAG, "performShow on " + this
Craig Mautner749a7bb2012-04-02 13:49:53 -07001124 + ": mDrawState=" + mDrawState + " readyForDisplay="
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001125 + mWin.isReadyForDisplay()
1126 + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING), e);
1127 }
Craig Mautner749a7bb2012-04-02 13:49:53 -07001128 if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplay()) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001129 if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001130 WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null);
Craig Mautnerd87946b2012-03-29 18:00:19 -07001131 if (DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + this
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001132 + " during animation: policyVis=" + mWin.mPolicyVisibility
1133 + " attHidden=" + mWin.mAttachedHidden
1134 + " tok.hiddenRequested="
1135 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false)
1136 + " tok.hidden="
1137 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false)
1138 + " animating=" + mAnimating
1139 + " tok animating="
Craig Mautner59431632012-04-04 11:56:44 -07001140 + (mWin.mAppToken != null ? mWin.mAppToken.mAppAnimator.animating : false));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001141
1142 mService.enableScreenIfNeededLocked();
1143
1144 applyEnterAnimationLocked();
1145
Craig Mautnerde6198e2012-04-19 09:59:31 -07001146 // Force the show in the next prepareSurfaceLocked() call.
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001147 mLastAlpha = -1;
Craig Mautner749a7bb2012-04-02 13:49:53 -07001148 mDrawState = HAS_DRAWN;
Craig Mautnerde6198e2012-04-19 09:59:31 -07001149 mService.scheduleAnimationLocked();
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001150
1151 int i = mWin.mChildWindows.size();
1152 while (i > 0) {
1153 i--;
1154 WindowState c = mWin.mChildWindows.get(i);
1155 if (c.mAttachedHidden) {
1156 c.mAttachedHidden = false;
1157 if (c.mWinAnimator.mSurface != null) {
1158 c.mWinAnimator.performShowLocked();
1159 // It hadn't been shown, which means layout not
1160 // performed on it, so now we want to make sure to
1161 // do a layout. If called from within the transaction
1162 // loop, this will cause it to restart with a new
1163 // layout.
1164 mService.mLayoutNeeded = true;
1165 }
1166 }
1167 }
1168
1169 if (mWin.mAttrs.type != TYPE_APPLICATION_STARTING
1170 && mWin.mAppToken != null) {
1171 mWin.mAppToken.firstWindowDrawn = true;
1172
1173 if (mWin.mAppToken.startingData != null) {
1174 if (WindowManagerService.DEBUG_STARTING_WINDOW ||
Craig Mautnerd87946b2012-03-29 18:00:19 -07001175 WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001176 "Finish starting " + mWin.mToken
1177 + ": first real window is shown, no animation");
1178 // If this initial window is animating, stop it -- we
1179 // will do an animation to reveal it from behind the
1180 // starting window, so there is no need for it to also
1181 // be doing its own stuff.
Craig Mautner4d7349b2012-04-20 14:52:47 -07001182 clearAnimation();
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001183 mService.mFinishedStarting.add(mWin.mAppToken);
1184 mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
1185 }
1186 mWin.mAppToken.updateReportedVisibilityLocked();
1187 }
1188
1189 return true;
1190 }
1191
1192 return false;
1193 }
1194
1195 /**
1196 * Have the surface flinger show a surface, robustly dealing with
1197 * error conditions. In particular, if there is not enough memory
1198 * to show the surface, then we will try to get rid of other surfaces
1199 * in order to succeed.
1200 *
1201 * @return Returns true if the surface was successfully shown.
1202 */
1203 boolean showSurfaceRobustlyLocked() {
1204 try {
1205 if (mSurface != null) {
1206 mSurfaceShown = true;
1207 mSurface.show();
1208 if (mWin.mTurnOnScreen) {
1209 if (DEBUG_VISIBILITY) Slog.v(TAG,
1210 "Show surface turning screen on: " + mWin);
1211 mWin.mTurnOnScreen = false;
Craig Mautner7d8df392012-04-06 15:26:23 -07001212 mAnimator.mBulkUpdateParams |= SET_TURN_ON_SCREEN;
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001213 }
1214 }
1215 return true;
1216 } catch (RuntimeException e) {
1217 Slog.w(TAG, "Failure showing surface " + mSurface + " in " + mWin, e);
1218 }
1219
1220 mService.reclaimSomeSurfaceMemoryLocked(this, "show", true);
1221
1222 return false;
1223 }
1224
1225 void applyEnterAnimationLocked() {
1226 final int transit;
1227 if (mEnterAnimationPending) {
1228 mEnterAnimationPending = false;
1229 transit = WindowManagerPolicy.TRANSIT_ENTER;
1230 } else {
1231 transit = WindowManagerPolicy.TRANSIT_SHOW;
1232 }
1233
1234 applyAnimationLocked(transit, true);
1235 }
1236
Craig Mautner48ba1e72012-04-02 13:18:16 -07001237 // TODO(cmautner): Move back to WindowState?
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001238 /**
1239 * Choose the correct animation and set it to the passed WindowState.
1240 * @param transit If WindowManagerPolicy.TRANSIT_PREVIEW_DONE and the app window has been drawn
1241 * then the animation will be app_starting_exit. Any other value loads the animation from
1242 * the switch statement below.
1243 * @param isEntrance The animation type the last time this was called. Used to keep from
1244 * loading the same animation twice.
1245 * @return true if an animation has been loaded.
1246 */
1247 boolean applyAnimationLocked(int transit, boolean isEntrance) {
1248 if (mLocalAnimating && mAnimationIsEntrance == isEntrance) {
1249 // If we are trying to apply an animation, but already running
1250 // an animation of the same type, then just leave that one alone.
1251 return true;
1252 }
1253
1254 // Only apply an animation if the display isn't frozen. If it is
1255 // frozen, there is no reason to animate and it can cause strange
1256 // artifacts when we unfreeze the display if some different animation
1257 // is running.
1258 if (mService.okToDisplay()) {
1259 int anim = mPolicy.selectAnimationLw(mWin, transit);
1260 int attr = -1;
1261 Animation a = null;
1262 if (anim != 0) {
1263 a = AnimationUtils.loadAnimation(mContext, anim);
1264 } else {
1265 switch (transit) {
1266 case WindowManagerPolicy.TRANSIT_ENTER:
1267 attr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation;
1268 break;
1269 case WindowManagerPolicy.TRANSIT_EXIT:
1270 attr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation;
1271 break;
1272 case WindowManagerPolicy.TRANSIT_SHOW:
1273 attr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation;
1274 break;
1275 case WindowManagerPolicy.TRANSIT_HIDE:
1276 attr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation;
1277 break;
1278 }
1279 if (attr >= 0) {
1280 a = mService.loadAnimation(mWin.mAttrs, attr);
1281 }
1282 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001283 if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001284 "applyAnimation: win=" + this
1285 + " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
Craig Mautner4d7349b2012-04-20 14:52:47 -07001286 + " a=" + a
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001287 + " mAnimation=" + mAnimation
1288 + " isEntrance=" + isEntrance);
1289 if (a != null) {
1290 if (WindowManagerService.DEBUG_ANIM) {
1291 RuntimeException e = null;
1292 if (!WindowManagerService.HIDE_STACK_CRAWLS) {
1293 e = new RuntimeException();
1294 e.fillInStackTrace();
1295 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001296 Slog.v(TAG, "Loaded animation " + a + " for " + this, e);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001297 }
1298 setAnimation(a);
1299 mAnimationIsEntrance = isEntrance;
1300 }
1301 } else {
1302 clearAnimation();
1303 }
1304
1305 return mAnimation != null;
1306 }
1307
Craig Mautnera2c77052012-03-26 12:14:43 -07001308 public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
1309 if (mAnimating || mLocalAnimating || mAnimationIsEntrance
1310 || mAnimation != null) {
1311 pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating);
1312 pw.print(" mLocalAnimating="); pw.print(mLocalAnimating);
1313 pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance);
1314 pw.print(" mAnimation="); pw.println(mAnimation);
1315 }
1316 if (mHasTransformation || mHasLocalTransformation) {
1317 pw.print(prefix); pw.print("XForm: has=");
1318 pw.print(mHasTransformation);
1319 pw.print(" hasLocal="); pw.print(mHasLocalTransformation);
1320 pw.print(" "); mTransformation.printShortString(pw);
1321 pw.println();
1322 }
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001323 if (mSurface != null) {
1324 if (dumpAll) {
1325 pw.print(prefix); pw.print("mSurface="); pw.println(mSurface);
Craig Mautner749a7bb2012-04-02 13:49:53 -07001326 pw.print(prefix); pw.print("mDrawState="); pw.print(mDrawState);
1327 pw.print(" mLastHidden="); pw.println(mLastHidden);
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001328 }
1329 pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown);
1330 pw.print(" layer="); pw.print(mSurfaceLayer);
1331 pw.print(" alpha="); pw.print(mSurfaceAlpha);
1332 pw.print(" rect=("); pw.print(mSurfaceX);
1333 pw.print(","); pw.print(mSurfaceY);
1334 pw.print(") "); pw.print(mSurfaceW);
1335 pw.print(" x "); pw.println(mSurfaceH);
1336 }
1337 if (mPendingDestroySurface != null) {
1338 pw.print(prefix); pw.print("mPendingDestroySurface=");
1339 pw.println(mPendingDestroySurface);
1340 }
1341 if (mSurfaceResized || mSurfaceDestroyDeferred) {
1342 pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized);
1343 pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred);
1344 }
1345 if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) {
1346 pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha);
1347 pw.print(" mAlpha="); pw.print(mAlpha);
1348 pw.print(" mLastAlpha="); pw.println(mLastAlpha);
1349 }
1350 if (mHaveMatrix || mWin.mGlobalScale != 1) {
1351 pw.print(prefix); pw.print("mGlobalScale="); pw.print(mWin.mGlobalScale);
1352 pw.print(" mDsDx="); pw.print(mDsDx);
1353 pw.print(" mDtDx="); pw.print(mDtDx);
1354 pw.print(" mDsDy="); pw.print(mDsDy);
1355 pw.print(" mDtDy="); pw.println(mDtDy);
1356 }
Craig Mautnera2c77052012-03-26 12:14:43 -07001357 }
1358
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001359 @Override
1360 public String toString() {
1361 StringBuffer sb = new StringBuffer("WindowStateAnimator (");
1362 sb.append(mWin.mLastTitle + "): ");
1363 sb.append("mSurface " + mSurface);
1364 sb.append(", mAnimation " + mAnimation);
1365 return sb.toString();
1366 }
Craig Mautnera2c77052012-03-26 12:14:43 -07001367}