WindowStateAnimator.java revision 71dd1b63436e9cdd5cbd2d42cd5841d497da8238
1// Copyright 2012 Google Inc. All Rights Reserved. 2 3package com.android.server.wm; 4 5import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; 6import static com.android.server.wm.WindowManagerService.DEBUG_ANIM; 7import static com.android.server.wm.WindowManagerService.DEBUG_LAYERS; 8import static com.android.server.wm.WindowManagerService.DEBUG_ORIENTATION; 9import static com.android.server.wm.WindowManagerService.DEBUG_STARTING_WINDOW; 10import static com.android.server.wm.WindowManagerService.DEBUG_SURFACE_TRACE; 11import static com.android.server.wm.WindowManagerService.SHOW_TRANSACTIONS; 12import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY; 13import static com.android.server.wm.WindowManagerService.SHOW_LIGHT_TRANSACTIONS; 14import static com.android.server.wm.WindowManagerService.SHOW_SURFACE_ALLOC; 15import static com.android.server.wm.WindowManagerService.localLOGV; 16import static com.android.server.wm.WindowManagerService.LayoutFields.SET_ORIENTATION_CHANGE_COMPLETE; 17import static com.android.server.wm.WindowManagerService.LayoutFields.SET_TURN_ON_SCREEN; 18 19import android.content.Context; 20import android.graphics.Matrix; 21import android.graphics.PixelFormat; 22import android.graphics.Point; 23import android.graphics.PointF; 24import android.graphics.Rect; 25import android.graphics.RectF; 26import android.graphics.Region; 27import android.os.Debug; 28import android.util.Slog; 29import android.view.Display; 30import android.view.DisplayInfo; 31import android.view.MagnificationSpec; 32import android.view.Surface.OutOfResourcesException; 33import android.view.SurfaceControl; 34import android.view.SurfaceSession; 35import android.view.WindowManager; 36import android.view.WindowManagerPolicy; 37import android.view.WindowManager.LayoutParams; 38import android.view.animation.Animation; 39import android.view.animation.AnimationUtils; 40import android.view.animation.Transformation; 41 42import com.android.server.wm.WindowManagerService.H; 43 44import java.io.PrintWriter; 45import java.util.ArrayList; 46 47class WinAnimatorList extends ArrayList<WindowStateAnimator> { 48} 49 50/** 51 * Keep track of animations and surface operations for a single WindowState. 52 **/ 53class WindowStateAnimator { 54 static final String TAG = "WindowStateAnimator"; 55 56 // Unchanging local convenience fields. 57 final WindowManagerService mService; 58 final WindowState mWin; 59 final WindowStateAnimator mAttachedWinAnimator; 60 final WindowAnimator mAnimator; 61 AppWindowAnimator mAppAnimator; 62 final Session mSession; 63 final WindowManagerPolicy mPolicy; 64 final Context mContext; 65 final boolean mIsWallpaper; 66 67 // If this is a universe background window, this is the transformation 68 // it is applying to the rest of the universe. 69 final Transformation mUniverseTransform = new Transformation(); 70 71 // Currently running animation. 72 boolean mAnimating; 73 boolean mLocalAnimating; 74 Animation mAnimation; 75 boolean mAnimationIsEntrance; 76 boolean mHasTransformation; 77 boolean mHasLocalTransformation; 78 final Transformation mTransformation = new Transformation(); 79 boolean mWasAnimating; // Were we animating going into the most recent animation step? 80 int mAnimLayer; 81 int mLastLayer; 82 83 SurfaceControl mSurfaceControl; 84 SurfaceControl mPendingDestroySurface; 85 86 /** 87 * Set when we have changed the size of the surface, to know that 88 * we must tell them application to resize (and thus redraw itself). 89 */ 90 boolean mSurfaceResized; 91 92 /** 93 * Set if the client has asked that the destroy of its surface be delayed 94 * until it explicitly says it is okay. 95 */ 96 boolean mSurfaceDestroyDeferred; 97 98 float mShownAlpha = 0; 99 float mAlpha = 0; 100 float mLastAlpha = 0; 101 102 // Used to save animation distances between the time they are calculated and when they are 103 // used. 104 int mAnimDw; 105 int mAnimDh; 106 float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1; 107 float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1; 108 109 boolean mHaveMatrix; 110 111 // For debugging, this is the last information given to the surface flinger. 112 boolean mSurfaceShown; 113 float mSurfaceX, mSurfaceY, mSurfaceW, mSurfaceH; 114 int mSurfaceLayer; 115 float mSurfaceAlpha; 116 117 // Set to true if, when the window gets displayed, it should perform 118 // an enter animation. 119 boolean mEnterAnimationPending; 120 121 /** This is set when there is no Surface */ 122 static final int NO_SURFACE = 0; 123 /** This is set after the Surface has been created but before the window has been drawn. During 124 * this time the surface is hidden. */ 125 static final int DRAW_PENDING = 1; 126 /** This is set after the window has finished drawing for the first time but before its surface 127 * is shown. The surface will be displayed when the next layout is run. */ 128 static final int COMMIT_DRAW_PENDING = 2; 129 /** This is set during the time after the window's drawing has been committed, and before its 130 * surface is actually shown. It is used to delay showing the surface until all windows in a 131 * token are ready to be shown. */ 132 static final int READY_TO_SHOW = 3; 133 /** Set when the window has been shown in the screen the first time. */ 134 static final int HAS_DRAWN = 4; 135 static String drawStateToString(int state) { 136 switch (state) { 137 case NO_SURFACE: return "NO_SURFACE"; 138 case DRAW_PENDING: return "DRAW_PENDING"; 139 case COMMIT_DRAW_PENDING: return "COMMIT_DRAW_PENDING"; 140 case READY_TO_SHOW: return "READY_TO_SHOW"; 141 case HAS_DRAWN: return "HAS_DRAWN"; 142 default: return Integer.toString(state); 143 } 144 } 145 int mDrawState; 146 147 /** Was this window last hidden? */ 148 boolean mLastHidden; 149 150 int mAttrFlags; 151 int mAttrType; 152 153 public WindowStateAnimator(final WindowState win) { 154 final WindowManagerService service = win.mService; 155 156 mService = service; 157 mAnimator = service.mAnimator; 158 mPolicy = service.mPolicy; 159 mContext = service.mContext; 160 final DisplayInfo displayInfo = win.getDisplayContent().getDisplayInfo(); 161 mAnimDw = displayInfo.appWidth; 162 mAnimDh = displayInfo.appHeight; 163 164 mWin = win; 165 mAttachedWinAnimator = win.mAttachedWindow == null 166 ? null : win.mAttachedWindow.mWinAnimator; 167 mAppAnimator = win.mAppToken == null ? null : win.mAppToken.mAppAnimator; 168 mSession = win.mSession; 169 mAttrFlags = win.mAttrs.flags; 170 mAttrType = win.mAttrs.type; 171 mIsWallpaper = win.mIsWallpaper; 172 } 173 174 public void setAnimation(Animation anim) { 175 if (localLOGV) Slog.v(TAG, "Setting animation in " + this + ": " + anim); 176 mAnimating = false; 177 mLocalAnimating = false; 178 mAnimation = anim; 179 mAnimation.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION); 180 mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale); 181 // Start out animation gone if window is gone, or visible if window is visible. 182 mTransformation.clear(); 183 mTransformation.setAlpha(mLastHidden ? 0 : 1); 184 mHasLocalTransformation = true; 185 } 186 187 public void clearAnimation() { 188 if (mAnimation != null) { 189 mAnimating = true; 190 mLocalAnimating = false; 191 mAnimation.cancel(); 192 mAnimation = null; 193 } 194 } 195 196 /** Is the window or its container currently animating? */ 197 boolean isAnimating() { 198 return mAnimation != null 199 || (mAttachedWinAnimator != null && mAttachedWinAnimator.mAnimation != null) 200 || (mAppAnimator != null && 201 (mAppAnimator.animation != null 202 || mAppAnimator.mAppToken.inPendingTransaction)); 203 } 204 205 /** Is the window animating the DummyAnimation? */ 206 boolean isDummyAnimation() { 207 return mAppAnimator != null 208 && mAppAnimator.animation == AppWindowAnimator.sDummyAnimation; 209 } 210 211 /** Is this window currently animating? */ 212 boolean isWindowAnimating() { 213 return mAnimation != null; 214 } 215 216 void cancelExitAnimationForNextAnimationLocked() { 217 if (mAnimation != null) { 218 mAnimation.cancel(); 219 mAnimation = null; 220 mLocalAnimating = false; 221 destroySurfaceLocked(); 222 } 223 } 224 225 private boolean stepAnimation(long currentTime) { 226 if ((mAnimation == null) || !mLocalAnimating) { 227 return false; 228 } 229 mTransformation.clear(); 230 final boolean more = mAnimation.getTransformation(currentTime, mTransformation); 231 if (false && DEBUG_ANIM) Slog.v( 232 TAG, "Stepped animation in " + this + 233 ": more=" + more + ", xform=" + mTransformation); 234 return more; 235 } 236 237 // This must be called while inside a transaction. Returns true if 238 // there is more animation to run. 239 boolean stepAnimationLocked(long currentTime) { 240 // Save the animation state as it was before this step so WindowManagerService can tell if 241 // we just started or just stopped animating by comparing mWasAnimating with isAnimating(). 242 mWasAnimating = mAnimating; 243 final DisplayContent displayContent = mWin.getDisplayContent(); 244 if (displayContent != null && mService.okToDisplay()) { 245 // We will run animations as long as the display isn't frozen. 246 247 if (mWin.isDrawnLw() && mAnimation != null) { 248 mHasTransformation = true; 249 mHasLocalTransformation = true; 250 if (!mLocalAnimating) { 251 if (DEBUG_ANIM) Slog.v( 252 TAG, "Starting animation in " + this + 253 " @ " + currentTime + ": ww=" + mWin.mFrame.width() + 254 " wh=" + mWin.mFrame.height() + 255 " dw=" + mAnimDw + " dh=" + mAnimDh + 256 " scale=" + mService.mWindowAnimationScale); 257 mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), 258 mAnimDw, mAnimDh); 259 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 260 mAnimDw = displayInfo.appWidth; 261 mAnimDh = displayInfo.appHeight; 262 mAnimation.setStartTime(currentTime); 263 mLocalAnimating = true; 264 mAnimating = true; 265 } 266 if ((mAnimation != null) && mLocalAnimating) { 267 if (stepAnimation(currentTime)) { 268 return true; 269 } 270 } 271 if (DEBUG_ANIM) Slog.v( 272 TAG, "Finished animation in " + this + 273 " @ " + currentTime); 274 //WindowManagerService.this.dump(); 275 } 276 mHasLocalTransformation = false; 277 if ((!mLocalAnimating || mAnimationIsEntrance) && mAppAnimator != null 278 && mAppAnimator.animation != null) { 279 // When our app token is animating, we kind-of pretend like 280 // we are as well. Note the mLocalAnimating mAnimationIsEntrance 281 // part of this check means that we will only do this if 282 // our window is not currently exiting, or it is not 283 // locally animating itself. The idea being that one that 284 // is exiting and doing a local animation should be removed 285 // once that animation is done. 286 mAnimating = true; 287 mHasTransformation = true; 288 mTransformation.clear(); 289 return false; 290 } else if (mHasTransformation) { 291 // Little trick to get through the path below to act like 292 // we have finished an animation. 293 mAnimating = true; 294 } else if (isAnimating()) { 295 mAnimating = true; 296 } 297 } else if (mAnimation != null) { 298 // If the display is frozen, and there is a pending animation, 299 // clear it and make sure we run the cleanup code. 300 mAnimating = true; 301 } 302 303 if (!mAnimating && !mLocalAnimating) { 304 return false; 305 } 306 307 // Done animating, clean up. 308 if (DEBUG_ANIM) Slog.v( 309 TAG, "Animation done in " + this + ": exiting=" + mWin.mExiting 310 + ", reportedVisible=" 311 + (mWin.mAppToken != null ? mWin.mAppToken.reportedVisible : false)); 312 313 mAnimating = false; 314 mLocalAnimating = false; 315 if (mAnimation != null) { 316 mAnimation.cancel(); 317 mAnimation = null; 318 } 319 if (mAnimator.mWindowDetachedWallpaper == mWin) { 320 mAnimator.mWindowDetachedWallpaper = null; 321 } 322 mAnimLayer = mWin.mLayer; 323 if (mWin.mIsImWindow) { 324 mAnimLayer += mService.mInputMethodAnimLayerAdjustment; 325 } else if (mIsWallpaper) { 326 mAnimLayer += mService.mWallpaperAnimLayerAdjustment; 327 } 328 if (DEBUG_LAYERS) Slog.v(TAG, "Stepping win " + this 329 + " anim layer: " + mAnimLayer); 330 mHasTransformation = false; 331 mHasLocalTransformation = false; 332 if (mWin.mPolicyVisibility != mWin.mPolicyVisibilityAfterAnim) { 333 if (DEBUG_VISIBILITY) { 334 Slog.v(TAG, "Policy visibility changing after anim in " + this + ": " 335 + mWin.mPolicyVisibilityAfterAnim); 336 } 337 mWin.mPolicyVisibility = mWin.mPolicyVisibilityAfterAnim; 338 if (displayContent != null) { 339 displayContent.layoutNeeded = true; 340 } 341 if (!mWin.mPolicyVisibility) { 342 if (mService.mCurrentFocus == mWin) { 343 if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, 344 "setAnimationLocked: setting mFocusMayChange true"); 345 mService.mFocusMayChange = true; 346 } 347 // Window is no longer visible -- make sure if we were waiting 348 // for it to be displayed before enabling the display, that 349 // we allow the display to be enabled now. 350 mService.enableScreenIfNeededLocked(); 351 } 352 } 353 mTransformation.clear(); 354 if (mDrawState == HAS_DRAWN 355 && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING 356 && mWin.mAppToken != null 357 && mWin.mAppToken.firstWindowDrawn 358 && mWin.mAppToken.startingData != null) { 359 if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Finish starting " 360 + mWin.mToken + ": first real window done animating"); 361 mService.mFinishedStarting.add(mWin.mAppToken); 362 mService.mH.sendEmptyMessage(H.FINISHED_STARTING); 363 } else if (mAttrType == LayoutParams.TYPE_STATUS_BAR && mWin.mPolicyVisibility) { 364 // Upon completion of a not-visible to visible status bar animation a relayout is 365 // required. 366 if (displayContent != null) { 367 displayContent.layoutNeeded = true; 368 } 369 } 370 371 finishExit(); 372 final int displayId = mWin.getDisplayId(); 373 mAnimator.setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM); 374 if (WindowManagerService.DEBUG_LAYOUT_REPEATS) mService.debugLayoutRepeats( 375 "WindowStateAnimator", mAnimator.getPendingLayoutChanges(displayId)); 376 377 if (mWin.mAppToken != null) { 378 mWin.mAppToken.updateReportedVisibilityLocked(); 379 } 380 381 return false; 382 } 383 384 void finishExit() { 385 if (WindowManagerService.DEBUG_ANIM) Slog.v( 386 TAG, "finishExit in " + this 387 + ": exiting=" + mWin.mExiting 388 + " remove=" + mWin.mRemoveOnExit 389 + " windowAnimating=" + isWindowAnimating()); 390 391 final int N = mWin.mChildWindows.size(); 392 for (int i=0; i<N; i++) { 393 mWin.mChildWindows.get(i).mWinAnimator.finishExit(); 394 } 395 396 if (!mWin.mExiting) { 397 return; 398 } 399 400 if (isWindowAnimating()) { 401 return; 402 } 403 404 if (WindowManagerService.localLOGV) Slog.v( 405 TAG, "Exit animation finished in " + this 406 + ": remove=" + mWin.mRemoveOnExit); 407 if (mSurfaceControl != null) { 408 mService.mDestroySurface.add(mWin); 409 mWin.mDestroying = true; 410 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface( 411 mWin, "HIDE (finishExit)", null); 412 hide(); 413 } 414 mWin.mExiting = false; 415 if (mWin.mRemoveOnExit) { 416 mService.mPendingRemove.add(mWin); 417 mWin.mRemoveOnExit = false; 418 } 419 mService.mPendingStacksRemove.add(mWin.getStack()); 420 mAnimator.hideWallpapersLocked(mWin); 421 } 422 423 void hide() { 424 if (!mLastHidden) { 425 //dump(); 426 mLastHidden = true; 427 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 428 "HIDE (performLayout)", null); 429 if (mSurfaceControl != null) { 430 mSurfaceShown = false; 431 try { 432 mSurfaceControl.hide(); 433 } catch (RuntimeException e) { 434 Slog.w(TAG, "Exception hiding surface in " + mWin); 435 } 436 } 437 } 438 } 439 440 boolean finishDrawingLocked() { 441 if (DEBUG_STARTING_WINDOW && 442 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 443 Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState=" 444 + drawStateToString(mDrawState)); 445 } 446 if (mDrawState == DRAW_PENDING) { 447 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) 448 Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in " 449 + mSurfaceControl); 450 if (DEBUG_STARTING_WINDOW && 451 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 452 Slog.v(TAG, "Draw state now committed in " + mWin); 453 } 454 mDrawState = COMMIT_DRAW_PENDING; 455 return true; 456 } 457 return false; 458 } 459 460 // This must be called while inside a transaction. 461 boolean commitFinishDrawingLocked(long currentTime) { 462 if (DEBUG_STARTING_WINDOW && 463 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 464 Slog.i(TAG, "commitFinishDrawingLocked: " + mWin + " cur mDrawState=" 465 + drawStateToString(mDrawState)); 466 } 467 if (mDrawState != COMMIT_DRAW_PENDING) { 468 return false; 469 } 470 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) { 471 Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurfaceControl); 472 } 473 mDrawState = READY_TO_SHOW; 474 final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING; 475 final AppWindowToken atoken = mWin.mAppToken; 476 if (atoken == null || atoken.allDrawn || starting) { 477 performShowLocked(); 478 } 479 return true; 480 } 481 482 static class SurfaceTrace extends SurfaceControl { 483 private final static String SURFACE_TAG = "SurfaceTrace"; 484 final static ArrayList<SurfaceTrace> sSurfaces = new ArrayList<SurfaceTrace>(); 485 486 private float mSurfaceTraceAlpha = 0; 487 private int mLayer; 488 private final PointF mPosition = new PointF(); 489 private final Point mSize = new Point(); 490 private final Rect mWindowCrop = new Rect(); 491 private boolean mShown = false; 492 private int mLayerStack; 493 private boolean mIsOpaque; 494 private final String mName; 495 496 public SurfaceTrace(SurfaceSession s, 497 String name, int w, int h, int format, int flags) 498 throws OutOfResourcesException { 499 super(s, name, w, h, format, flags); 500 mName = name != null ? name : "Not named"; 501 mSize.set(w, h); 502 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by " 503 + Debug.getCallers(3)); 504 } 505 506 @Override 507 public void setAlpha(float alpha) { 508 if (mSurfaceTraceAlpha != alpha) { 509 Slog.v(SURFACE_TAG, "setAlpha(" + alpha + "): OLD:" + this + ". Called by " 510 + Debug.getCallers(3)); 511 mSurfaceTraceAlpha = alpha; 512 } 513 super.setAlpha(alpha); 514 } 515 516 @Override 517 public void setLayer(int zorder) { 518 if (zorder != mLayer) { 519 Slog.v(SURFACE_TAG, "setLayer(" + zorder + "): OLD:" + this + ". Called by " 520 + Debug.getCallers(3)); 521 mLayer = zorder; 522 } 523 super.setLayer(zorder); 524 525 sSurfaces.remove(this); 526 int i; 527 for (i = sSurfaces.size() - 1; i >= 0; i--) { 528 SurfaceTrace s = sSurfaces.get(i); 529 if (s.mLayer < zorder) { 530 break; 531 } 532 } 533 sSurfaces.add(i + 1, this); 534 } 535 536 @Override 537 public void setPosition(float x, float y) { 538 if (x != mPosition.x || y != mPosition.y) { 539 Slog.v(SURFACE_TAG, "setPosition(" + x + "," + y + "): OLD:" + this 540 + ". Called by " + Debug.getCallers(3)); 541 mPosition.set(x, y); 542 } 543 super.setPosition(x, y); 544 } 545 546 @Override 547 public void setSize(int w, int h) { 548 if (w != mSize.x || h != mSize.y) { 549 Slog.v(SURFACE_TAG, "setSize(" + w + "," + h + "): OLD:" + this + ". Called by " 550 + Debug.getCallers(3)); 551 mSize.set(w, h); 552 } 553 super.setSize(w, h); 554 } 555 556 @Override 557 public void setWindowCrop(Rect crop) { 558 if (crop != null) { 559 if (!crop.equals(mWindowCrop)) { 560 Slog.v(SURFACE_TAG, "setWindowCrop(" + crop.toShortString() + "): OLD:" + this 561 + ". Called by " + Debug.getCallers(3)); 562 mWindowCrop.set(crop); 563 } 564 } 565 super.setWindowCrop(crop); 566 } 567 568 @Override 569 public void setLayerStack(int layerStack) { 570 if (layerStack != mLayerStack) { 571 Slog.v(SURFACE_TAG, "setLayerStack(" + layerStack + "): OLD:" + this 572 + ". Called by " + Debug.getCallers(3)); 573 mLayerStack = layerStack; 574 } 575 super.setLayerStack(layerStack); 576 } 577 578 @Override 579 public void setOpaque(boolean isOpaque) { 580 if (isOpaque != mIsOpaque) { 581 Slog.v(SURFACE_TAG, "setOpaque(" + isOpaque + "): OLD:" + this 582 + ". Called by " + Debug.getCallers(3)); 583 mIsOpaque = isOpaque; 584 } 585 super.setOpaque(isOpaque); 586 } 587 588 @Override 589 public void hide() { 590 if (mShown) { 591 Slog.v(SURFACE_TAG, "hide: OLD:" + this + ". Called by " + Debug.getCallers(3)); 592 mShown = false; 593 } 594 super.hide(); 595 } 596 597 @Override 598 public void show() { 599 if (!mShown) { 600 Slog.v(SURFACE_TAG, "show: OLD:" + this + ". Called by " + Debug.getCallers(3)); 601 mShown = true; 602 } 603 super.show(); 604 } 605 606 @Override 607 public void destroy() { 608 super.destroy(); 609 Slog.v(SURFACE_TAG, "destroy: " + this + ". Called by " + Debug.getCallers(3)); 610 sSurfaces.remove(this); 611 } 612 613 @Override 614 public void release() { 615 super.release(); 616 Slog.v(SURFACE_TAG, "release: " + this + ". Called by " 617 + Debug.getCallers(3)); 618 sSurfaces.remove(this); 619 } 620 621 static void dumpAllSurfaces() { 622 final int N = sSurfaces.size(); 623 for (int i = 0; i < N; i++) { 624 Slog.i(TAG, "SurfaceDump: " + sSurfaces.get(i)); 625 } 626 } 627 628 @Override 629 public String toString() { 630 return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " " 631 + mName + " (" + mLayerStack + "): shown=" + mShown + " layer=" + mLayer 632 + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y 633 + " " + mSize.x + "x" + mSize.y 634 + " crop=" + mWindowCrop.toShortString() 635 + " opaque=" + mIsOpaque; 636 } 637 } 638 639 SurfaceControl createSurfaceLocked() { 640 if (mSurfaceControl == null) { 641 if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG, 642 "createSurface " + this + ": mDrawState=DRAW_PENDING"); 643 mDrawState = DRAW_PENDING; 644 if (mWin.mAppToken != null) { 645 if (mWin.mAppToken.mAppAnimator.animation == null) { 646 mWin.mAppToken.allDrawn = false; 647 mWin.mAppToken.deferClearAllDrawn = false; 648 } else { 649 // Currently animating, persist current state of allDrawn until animation 650 // is complete. 651 mWin.mAppToken.deferClearAllDrawn = true; 652 } 653 } 654 655 mService.makeWindowFreezingScreenIfNeededLocked(mWin); 656 657 int flags = SurfaceControl.HIDDEN; 658 final WindowManager.LayoutParams attrs = mWin.mAttrs; 659 660 if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) { 661 flags |= SurfaceControl.SECURE; 662 } 663 if (DEBUG_VISIBILITY) Slog.v( 664 TAG, "Creating surface in session " 665 + mSession.mSurfaceSession + " window " + this 666 + " w=" + mWin.mCompatFrame.width() 667 + " h=" + mWin.mCompatFrame.height() + " format=" 668 + attrs.format + " flags=" + flags); 669 670 int w = mWin.mCompatFrame.width(); 671 int h = mWin.mCompatFrame.height(); 672 if ((attrs.flags & LayoutParams.FLAG_SCALED) != 0) { 673 // for a scaled surface, we always want the requested 674 // size. 675 w = mWin.mRequestedWidth; 676 h = mWin.mRequestedHeight; 677 } 678 679 // Something is wrong and SurfaceFlinger will not like this, 680 // try to revert to sane values 681 if (w <= 0) w = 1; 682 if (h <= 0) h = 1; 683 684 mSurfaceShown = false; 685 mSurfaceLayer = 0; 686 mSurfaceAlpha = 0; 687 mSurfaceX = 0; 688 mSurfaceY = 0; 689 mSurfaceW = w; 690 mSurfaceH = h; 691 mWin.mLastSystemDecorRect.set(0, 0, 0, 0); 692 try { 693 final boolean isHwAccelerated = (attrs.flags & 694 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; 695 final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format; 696 if (!PixelFormat.formatHasAlpha(attrs.format)) { 697 flags |= SurfaceControl.OPAQUE; 698 } 699 if (DEBUG_SURFACE_TRACE) { 700 mSurfaceControl = new SurfaceTrace( 701 mSession.mSurfaceSession, 702 attrs.getTitle().toString(), 703 w, h, format, flags); 704 } else { 705 mSurfaceControl = new SurfaceControl( 706 mSession.mSurfaceSession, 707 attrs.getTitle().toString(), 708 w, h, format, flags); 709 } 710 mWin.mHasSurface = true; 711 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG, 712 " CREATE SURFACE " 713 + mSurfaceControl + " IN SESSION " 714 + mSession.mSurfaceSession 715 + ": pid=" + mSession.mPid + " format=" 716 + attrs.format + " flags=0x" 717 + Integer.toHexString(flags) 718 + " / " + this); 719 } catch (OutOfResourcesException e) { 720 mWin.mHasSurface = false; 721 Slog.w(TAG, "OutOfResourcesException creating surface"); 722 mService.reclaimSomeSurfaceMemoryLocked(this, "create", true); 723 mDrawState = NO_SURFACE; 724 return null; 725 } catch (Exception e) { 726 mWin.mHasSurface = false; 727 Slog.e(TAG, "Exception creating surface", e); 728 mDrawState = NO_SURFACE; 729 return null; 730 } 731 732 if (WindowManagerService.localLOGV) Slog.v( 733 TAG, "Got surface: " + mSurfaceControl 734 + ", set left=" + mWin.mFrame.left + " top=" + mWin.mFrame.top 735 + ", animLayer=" + mAnimLayer); 736 if (SHOW_LIGHT_TRANSACTIONS) { 737 Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked"); 738 WindowManagerService.logSurface(mWin, "CREATE pos=(" 739 + mWin.mFrame.left + "," + mWin.mFrame.top + ") (" 740 + mWin.mCompatFrame.width() + "x" + mWin.mCompatFrame.height() 741 + "), layer=" + mAnimLayer + " HIDE", null); 742 } 743 SurfaceControl.openTransaction(); 744 try { 745 try { 746 mSurfaceX = mWin.mFrame.left + mWin.mXOffset; 747 mSurfaceY = mWin.mFrame.top + mWin.mYOffset; 748 mSurfaceControl.setPosition(mSurfaceX, mSurfaceY); 749 mSurfaceLayer = mAnimLayer; 750 final DisplayContent displayContent = mWin.getDisplayContent(); 751 if (displayContent != null) { 752 mSurfaceControl.setLayerStack(displayContent.getDisplay().getLayerStack()); 753 } 754 mSurfaceControl.setLayer(mAnimLayer); 755 mSurfaceControl.setAlpha(0); 756 mSurfaceShown = false; 757 } catch (RuntimeException e) { 758 Slog.w(TAG, "Error creating surface in " + w, e); 759 mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true); 760 } 761 mLastHidden = true; 762 } finally { 763 SurfaceControl.closeTransaction(); 764 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, 765 "<<< CLOSE TRANSACTION createSurfaceLocked"); 766 } 767 if (WindowManagerService.localLOGV) Slog.v( 768 TAG, "Created surface " + this); 769 } 770 return mSurfaceControl; 771 } 772 773 void destroySurfaceLocked() { 774 if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) { 775 mWin.mAppToken.startingDisplayed = false; 776 } 777 778 if (mSurfaceControl != null) { 779 780 int i = mWin.mChildWindows.size(); 781 while (i > 0) { 782 i--; 783 WindowState c = mWin.mChildWindows.get(i); 784 c.mAttachedHidden = true; 785 } 786 787 try { 788 if (DEBUG_VISIBILITY) { 789 RuntimeException e = null; 790 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 791 e = new RuntimeException(); 792 e.fillInStackTrace(); 793 } 794 Slog.w(TAG, "Window " + this + " destroying surface " 795 + mSurfaceControl + ", session " + mSession, e); 796 } 797 if (mSurfaceDestroyDeferred) { 798 if (mSurfaceControl != null && mPendingDestroySurface != mSurfaceControl) { 799 if (mPendingDestroySurface != null) { 800 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { 801 RuntimeException e = null; 802 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 803 e = new RuntimeException(); 804 e.fillInStackTrace(); 805 } 806 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e); 807 } 808 mPendingDestroySurface.destroy(); 809 } 810 mPendingDestroySurface = mSurfaceControl; 811 } 812 } else { 813 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { 814 RuntimeException e = null; 815 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 816 e = new RuntimeException(); 817 e.fillInStackTrace(); 818 } 819 WindowManagerService.logSurface(mWin, "DESTROY", e); 820 } 821 mSurfaceControl.destroy(); 822 } 823 mAnimator.hideWallpapersLocked(mWin); 824 } catch (RuntimeException e) { 825 Slog.w(TAG, "Exception thrown when destroying Window " + this 826 + " surface " + mSurfaceControl + " session " + mSession 827 + ": " + e.toString()); 828 } 829 830 mSurfaceShown = false; 831 mSurfaceControl = null; 832 mWin.mHasSurface = false; 833 mDrawState = NO_SURFACE; 834 } 835 } 836 837 void destroyDeferredSurfaceLocked() { 838 try { 839 if (mPendingDestroySurface != null) { 840 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) { 841 RuntimeException e = null; 842 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 843 e = new RuntimeException(); 844 e.fillInStackTrace(); 845 } 846 WindowManagerService.logSurface(mWin, "DESTROY PENDING", e); 847 } 848 mPendingDestroySurface.destroy(); 849 mAnimator.hideWallpapersLocked(mWin); 850 } 851 } catch (RuntimeException e) { 852 Slog.w(TAG, "Exception thrown when destroying Window " 853 + this + " surface " + mPendingDestroySurface 854 + " session " + mSession + ": " + e.toString()); 855 } 856 mSurfaceDestroyDeferred = false; 857 mPendingDestroySurface = null; 858 } 859 860 void computeShownFrameLocked() { 861 final boolean selfTransformation = mHasLocalTransformation; 862 Transformation attachedTransformation = 863 (mAttachedWinAnimator != null && mAttachedWinAnimator.mHasLocalTransformation) 864 ? mAttachedWinAnimator.mTransformation : null; 865 Transformation appTransformation = (mAppAnimator != null && mAppAnimator.hasTransformation) 866 ? mAppAnimator.transformation : null; 867 868 // Wallpapers are animated based on the "real" window they 869 // are currently targeting. 870 final WindowState wallpaperTarget = mService.mWallpaperTarget; 871 if (mIsWallpaper && wallpaperTarget != null && mService.mAnimateWallpaperWithTarget) { 872 final WindowStateAnimator wallpaperAnimator = wallpaperTarget.mWinAnimator; 873 if (wallpaperAnimator.mHasLocalTransformation && 874 wallpaperAnimator.mAnimation != null && 875 !wallpaperAnimator.mAnimation.getDetachWallpaper()) { 876 attachedTransformation = wallpaperAnimator.mTransformation; 877 if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) { 878 Slog.v(TAG, "WP target attached xform: " + attachedTransformation); 879 } 880 } 881 final AppWindowAnimator wpAppAnimator = wallpaperTarget.mAppToken == null ? 882 null : wallpaperTarget.mAppToken.mAppAnimator; 883 if (wpAppAnimator != null && wpAppAnimator.hasTransformation 884 && wpAppAnimator.animation != null 885 && !wpAppAnimator.animation.getDetachWallpaper()) { 886 appTransformation = wpAppAnimator.transformation; 887 if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) { 888 Slog.v(TAG, "WP target app xform: " + appTransformation); 889 } 890 } 891 } 892 893 final int displayId = mWin.getDisplayId(); 894 final ScreenRotationAnimation screenRotationAnimation = 895 mAnimator.getScreenRotationAnimationLocked(displayId); 896 final boolean screenAnimation = 897 screenRotationAnimation != null && screenRotationAnimation.isAnimating(); 898 if (selfTransformation || attachedTransformation != null 899 || appTransformation != null || screenAnimation) { 900 // cache often used attributes locally 901 final Rect frame = mWin.mFrame; 902 final float tmpFloats[] = mService.mTmpFloats; 903 final Matrix tmpMatrix = mWin.mTmpMatrix; 904 905 // Compute the desired transformation. 906 if (screenAnimation && screenRotationAnimation.isRotating()) { 907 // If we are doing a screen animation, the global rotation 908 // applied to windows can result in windows that are carefully 909 // aligned with each other to slightly separate, allowing you 910 // to see what is behind them. An unsightly mess. This... 911 // thing... magically makes it call good: scale each window 912 // slightly (two pixels larger in each dimension, from the 913 // window's center). 914 final float w = frame.width(); 915 final float h = frame.height(); 916 if (w>=1 && h>=1) { 917 tmpMatrix.setScale(1 + 2/w, 1 + 2/h, w/2, h/2); 918 } else { 919 tmpMatrix.reset(); 920 } 921 } else { 922 tmpMatrix.reset(); 923 } 924 tmpMatrix.postScale(mWin.mGlobalScale, mWin.mGlobalScale); 925 if (selfTransformation) { 926 tmpMatrix.postConcat(mTransformation.getMatrix()); 927 } 928 tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset); 929 if (attachedTransformation != null) { 930 tmpMatrix.postConcat(attachedTransformation.getMatrix()); 931 } 932 if (appTransformation != null) { 933 tmpMatrix.postConcat(appTransformation.getMatrix()); 934 } 935 if (mAnimator.mUniverseBackground != null) { 936 tmpMatrix.postConcat(mAnimator.mUniverseBackground.mUniverseTransform.getMatrix()); 937 } 938 if (screenAnimation) { 939 tmpMatrix.postConcat(screenRotationAnimation.getEnterTransformation().getMatrix()); 940 } 941 //TODO (multidisplay): Magnification is supported only for the default display. 942 if (mService.mDisplayMagnifier != null && displayId == Display.DEFAULT_DISPLAY) { 943 MagnificationSpec spec = mService.mDisplayMagnifier 944 .getMagnificationSpecForWindowLocked(mWin); 945 if (spec != null && !spec.isNop()) { 946 tmpMatrix.postScale(spec.scale, spec.scale); 947 tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); 948 } 949 } 950 951 // "convert" it into SurfaceFlinger's format 952 // (a 2x2 matrix + an offset) 953 // Here we must not transform the position of the surface 954 // since it is already included in the transformation. 955 //Slog.i(TAG, "Transform: " + matrix); 956 957 mHaveMatrix = true; 958 tmpMatrix.getValues(tmpFloats); 959 mDsDx = tmpFloats[Matrix.MSCALE_X]; 960 mDtDx = tmpFloats[Matrix.MSKEW_Y]; 961 mDsDy = tmpFloats[Matrix.MSKEW_X]; 962 mDtDy = tmpFloats[Matrix.MSCALE_Y]; 963 float x = tmpFloats[Matrix.MTRANS_X]; 964 float y = tmpFloats[Matrix.MTRANS_Y]; 965 int w = frame.width(); 966 int h = frame.height(); 967 mWin.mShownFrame.set(x, y, x+w, y+h); 968 969 // Now set the alpha... but because our current hardware 970 // can't do alpha transformation on a non-opaque surface, 971 // turn it off if we are running an animation that is also 972 // transforming since it is more important to have that 973 // animation be smooth. 974 mShownAlpha = mAlpha; 975 if (!mService.mLimitedAlphaCompositing 976 || (!PixelFormat.formatHasAlpha(mWin.mAttrs.format) 977 || (mWin.isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy) 978 && x == frame.left && y == frame.top))) { 979 //Slog.i(TAG, "Applying alpha transform"); 980 if (selfTransformation) { 981 mShownAlpha *= mTransformation.getAlpha(); 982 } 983 if (attachedTransformation != null) { 984 mShownAlpha *= attachedTransformation.getAlpha(); 985 } 986 if (appTransformation != null) { 987 mShownAlpha *= appTransformation.getAlpha(); 988 } 989 if (mAnimator.mUniverseBackground != null) { 990 mShownAlpha *= mAnimator.mUniverseBackground.mUniverseTransform.getAlpha(); 991 } 992 if (screenAnimation) { 993 mShownAlpha *= screenRotationAnimation.getEnterTransformation().getAlpha(); 994 } 995 } else { 996 //Slog.i(TAG, "Not applying alpha transform"); 997 } 998 999 if ((DEBUG_SURFACE_TRACE || WindowManagerService.localLOGV) 1000 && (mShownAlpha == 1.0 || mShownAlpha == 0.0)) Slog.v( 1001 TAG, "computeShownFrameLocked: Animating " + this + " mAlpha=" + mAlpha 1002 + " self=" + (selfTransformation ? mTransformation.getAlpha() : "null") 1003 + " attached=" + (attachedTransformation == null ? 1004 "null" : attachedTransformation.getAlpha()) 1005 + " app=" + (appTransformation == null ? "null" : appTransformation.getAlpha()) 1006 + " screen=" + (screenAnimation ? 1007 screenRotationAnimation.getEnterTransformation().getAlpha() : "null")); 1008 return; 1009 } else if (mIsWallpaper && mService.mInnerFields.mWallpaperActionPending) { 1010 return; 1011 } 1012 1013 if (WindowManagerService.localLOGV) Slog.v( 1014 TAG, "computeShownFrameLocked: " + this + 1015 " not attached, mAlpha=" + mAlpha); 1016 1017 final boolean applyUniverseTransformation = (mAnimator.mUniverseBackground != null 1018 && mWin.mAttrs.type != WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND 1019 && mWin.mBaseLayer < mAnimator.mAboveUniverseLayer); 1020 MagnificationSpec spec = null; 1021 //TODO (multidisplay): Magnification is supported only for the default display. 1022 if (mService.mDisplayMagnifier != null && displayId == Display.DEFAULT_DISPLAY) { 1023 spec = mService.mDisplayMagnifier.getMagnificationSpecForWindowLocked(mWin); 1024 } 1025 if (applyUniverseTransformation || spec != null) { 1026 final Rect frame = mWin.mFrame; 1027 final float tmpFloats[] = mService.mTmpFloats; 1028 final Matrix tmpMatrix = mWin.mTmpMatrix; 1029 1030 tmpMatrix.setScale(mWin.mGlobalScale, mWin.mGlobalScale); 1031 tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset); 1032 1033 if (applyUniverseTransformation) { 1034 tmpMatrix.postConcat(mAnimator.mUniverseBackground.mUniverseTransform.getMatrix()); 1035 } 1036 1037 if (spec != null && !spec.isNop()) { 1038 tmpMatrix.postScale(spec.scale, spec.scale); 1039 tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); 1040 } 1041 1042 tmpMatrix.getValues(tmpFloats); 1043 1044 mHaveMatrix = true; 1045 mDsDx = tmpFloats[Matrix.MSCALE_X]; 1046 mDtDx = tmpFloats[Matrix.MSKEW_Y]; 1047 mDsDy = tmpFloats[Matrix.MSKEW_X]; 1048 mDtDy = tmpFloats[Matrix.MSCALE_Y]; 1049 float x = tmpFloats[Matrix.MTRANS_X]; 1050 float y = tmpFloats[Matrix.MTRANS_Y]; 1051 int w = frame.width(); 1052 int h = frame.height(); 1053 mWin.mShownFrame.set(x, y, x + w, y + h); 1054 1055 mShownAlpha = mAlpha; 1056 if (applyUniverseTransformation) { 1057 mShownAlpha *= mAnimator.mUniverseBackground.mUniverseTransform.getAlpha(); 1058 } 1059 } else { 1060 mWin.mShownFrame.set(mWin.mFrame); 1061 if (mWin.mXOffset != 0 || mWin.mYOffset != 0) { 1062 mWin.mShownFrame.offset(mWin.mXOffset, mWin.mYOffset); 1063 } 1064 mShownAlpha = mAlpha; 1065 mHaveMatrix = false; 1066 mDsDx = mWin.mGlobalScale; 1067 mDtDx = 0; 1068 mDsDy = 0; 1069 mDtDy = mWin.mGlobalScale; 1070 } 1071 } 1072 1073 void applyDecorRect(final Rect decorRect) { 1074 final WindowState w = mWin; 1075 // Compute the offset of the window in relation to the decor rect. 1076 final int offX = w.mXOffset + w.mFrame.left; 1077 final int offY = w.mYOffset + w.mFrame.top; 1078 // Initialize the decor rect to the entire frame. 1079 w.mSystemDecorRect.set(0, 0, w.mFrame.width(), w.mFrame.height()); 1080 // Intersect with the decor rect, offsetted by window position. 1081 w.mSystemDecorRect.intersect(decorRect.left-offX, decorRect.top-offY, 1082 decorRect.right-offX, decorRect.bottom-offY); 1083 // If size compatibility is being applied to the window, the 1084 // surface is scaled relative to the screen. Also apply this 1085 // scaling to the crop rect. We aren't using the standard rect 1086 // scale function because we want to round things to make the crop 1087 // always round to a larger rect to ensure we don't crop too 1088 // much and hide part of the window that should be seen. 1089 if (w.mEnforceSizeCompat && w.mInvGlobalScale != 1.0f) { 1090 final float scale = w.mInvGlobalScale; 1091 w.mSystemDecorRect.left = (int) (w.mSystemDecorRect.left * scale - 0.5f); 1092 w.mSystemDecorRect.top = (int) (w.mSystemDecorRect.top * scale - 0.5f); 1093 w.mSystemDecorRect.right = (int) ((w.mSystemDecorRect.right+1) * scale - 0.5f); 1094 w.mSystemDecorRect.bottom = (int) ((w.mSystemDecorRect.bottom+1) * scale - 0.5f); 1095 } 1096 } 1097 1098 void updateSurfaceWindowCrop(final boolean recoveringMemory) { 1099 final WindowState w = mWin; 1100 final DisplayContent displayContent = w.getDisplayContent(); 1101 if (displayContent == null) { 1102 return; 1103 } 1104 DisplayInfo displayInfo = displayContent.getDisplayInfo(); 1105 1106 // Need to recompute a new system decor rect each time. 1107 if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { 1108 // Currently can't do this cropping for scaled windows. We'll 1109 // just keep the crop rect the same as the source surface. 1110 w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight); 1111 } else if (!w.isDefaultDisplay()) { 1112 // On a different display there is no system decor. Crop the window 1113 // by the screen boundaries. 1114 w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height()); 1115 w.mSystemDecorRect.intersect(-w.mCompatFrame.left, -w.mCompatFrame.top, 1116 displayInfo.logicalWidth - w.mCompatFrame.left, 1117 displayInfo.logicalHeight - w.mCompatFrame.top); 1118 } else if (w.mLayer >= mService.mSystemDecorLayer) { 1119 // Above the decor layer is easy, just use the entire window. 1120 // Unless we have a universe background... in which case all the 1121 // windows need to be cropped by the screen, so they don't cover 1122 // the universe background. 1123 if (mAnimator.mUniverseBackground == null) { 1124 w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), 1125 w.mCompatFrame.height()); 1126 } else { 1127 applyDecorRect(mService.mScreenRect); 1128 } 1129 } else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND 1130 || w.mDecorFrame.isEmpty()) { 1131 // The universe background isn't cropped, nor windows without policy decor. 1132 w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), 1133 w.mCompatFrame.height()); 1134 } else { 1135 // Crop to the system decor specified by policy. 1136 applyDecorRect(w.mDecorFrame); 1137 } 1138 1139 if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) { 1140 w.mLastSystemDecorRect.set(w.mSystemDecorRect); 1141 try { 1142 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1143 "CROP " + w.mSystemDecorRect.toShortString(), null); 1144 mSurfaceControl.setWindowCrop(w.mSystemDecorRect); 1145 } catch (RuntimeException e) { 1146 Slog.w(TAG, "Error setting crop surface of " + w 1147 + " crop=" + w.mSystemDecorRect.toShortString(), e); 1148 if (!recoveringMemory) { 1149 mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true); 1150 } 1151 } 1152 } 1153 } 1154 1155 void setSurfaceBoundariesLocked(final boolean recoveringMemory) { 1156 final WindowState w = mWin; 1157 int width, height; 1158 if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { 1159 // for a scaled surface, we just want to use 1160 // the requested size. 1161 width = w.mRequestedWidth; 1162 height = w.mRequestedHeight; 1163 } else { 1164 width = w.mCompatFrame.width(); 1165 height = w.mCompatFrame.height(); 1166 } 1167 1168 if (width < 1) { 1169 width = 1; 1170 } 1171 if (height < 1) { 1172 height = 1; 1173 } 1174 final boolean surfaceResized = mSurfaceW != width || mSurfaceH != height; 1175 if (surfaceResized) { 1176 mSurfaceW = width; 1177 mSurfaceH = height; 1178 } 1179 1180 final float left = w.mShownFrame.left; 1181 final float top = w.mShownFrame.top; 1182 if (mSurfaceX != left || mSurfaceY != top) { 1183 try { 1184 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1185 "POS " + left + ", " + top, null); 1186 mSurfaceX = left; 1187 mSurfaceY = top; 1188 mSurfaceControl.setPosition(left, top); 1189 } catch (RuntimeException e) { 1190 Slog.w(TAG, "Error positioning surface of " + w 1191 + " pos=(" + left 1192 + "," + top + ")", e); 1193 if (!recoveringMemory) { 1194 mService.reclaimSomeSurfaceMemoryLocked(this, "position", true); 1195 } 1196 } 1197 } 1198 1199 if (surfaceResized) { 1200 try { 1201 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1202 "SIZE " + width + "x" + height, null); 1203 mSurfaceResized = true; 1204 mSurfaceControl.setSize(width, height); 1205 mAnimator.setPendingLayoutChanges(w.getDisplayId(), 1206 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER); 1207 if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) { 1208 w.getStack().startDimmingIfNeeded(this); 1209 } 1210 } catch (RuntimeException e) { 1211 // If something goes wrong with the surface (such 1212 // as running out of memory), don't take down the 1213 // entire system. 1214 Slog.e(TAG, "Error resizing surface of " + w 1215 + " size=(" + width + "x" + height + ")", e); 1216 if (!recoveringMemory) { 1217 mService.reclaimSomeSurfaceMemoryLocked(this, "size", true); 1218 } 1219 } 1220 } 1221 1222 updateSurfaceWindowCrop(recoveringMemory); 1223 } 1224 1225 public void prepareSurfaceLocked(final boolean recoveringMemory) { 1226 final WindowState w = mWin; 1227 if (mSurfaceControl == null) { 1228 if (w.mOrientationChanging) { 1229 if (DEBUG_ORIENTATION) { 1230 Slog.v(TAG, "Orientation change skips hidden " + w); 1231 } 1232 w.mOrientationChanging = false; 1233 } 1234 return; 1235 } 1236 1237 boolean displayed = false; 1238 1239 computeShownFrameLocked(); 1240 1241 setSurfaceBoundariesLocked(recoveringMemory); 1242 1243 if (mIsWallpaper && !mWin.mWallpaperVisible) { 1244 // Wallpaper is no longer visible and there is no wp target => hide it. 1245 hide(); 1246 } else if (w.mAttachedHidden || !w.isOnScreen()) { 1247 hide(); 1248 mAnimator.hideWallpapersLocked(w); 1249 1250 // If we are waiting for this window to handle an 1251 // orientation change, well, it is hidden, so 1252 // doesn't really matter. Note that this does 1253 // introduce a potential glitch if the window 1254 // becomes unhidden before it has drawn for the 1255 // new orientation. 1256 if (w.mOrientationChanging) { 1257 w.mOrientationChanging = false; 1258 if (DEBUG_ORIENTATION) Slog.v(TAG, 1259 "Orientation change skips hidden " + w); 1260 } 1261 } else if (mLastLayer != mAnimLayer 1262 || mLastAlpha != mShownAlpha 1263 || mLastDsDx != mDsDx 1264 || mLastDtDx != mDtDx 1265 || mLastDsDy != mDsDy 1266 || mLastDtDy != mDtDy 1267 || w.mLastHScale != w.mHScale 1268 || w.mLastVScale != w.mVScale 1269 || mLastHidden) { 1270 displayed = true; 1271 mLastAlpha = mShownAlpha; 1272 mLastLayer = mAnimLayer; 1273 mLastDsDx = mDsDx; 1274 mLastDtDx = mDtDx; 1275 mLastDsDy = mDsDy; 1276 mLastDtDy = mDtDy; 1277 w.mLastHScale = w.mHScale; 1278 w.mLastVScale = w.mVScale; 1279 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1280 "alpha=" + mShownAlpha + " layer=" + mAnimLayer 1281 + " matrix=[" + (mDsDx*w.mHScale) 1282 + "," + (mDtDx*w.mVScale) 1283 + "][" + (mDsDy*w.mHScale) 1284 + "," + (mDtDy*w.mVScale) + "]", null); 1285 if (mSurfaceControl != null) { 1286 try { 1287 mSurfaceAlpha = mShownAlpha; 1288 mSurfaceControl.setAlpha(mShownAlpha); 1289 mSurfaceLayer = mAnimLayer; 1290 mSurfaceControl.setLayer(mAnimLayer); 1291 mSurfaceControl.setMatrix( 1292 mDsDx*w.mHScale, mDtDx*w.mVScale, 1293 mDsDy*w.mHScale, mDtDy*w.mVScale); 1294 1295 if (mLastHidden && mDrawState == HAS_DRAWN) { 1296 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1297 "SHOW (performLayout)", null); 1298 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w 1299 + " during relayout"); 1300 if (showSurfaceRobustlyLocked()) { 1301 mLastHidden = false; 1302 if (mIsWallpaper) { 1303 mService.dispatchWallpaperVisibility(w, true); 1304 } 1305 // This draw means the difference between unique content and mirroring. 1306 // Run another pass through performLayout to set mHasContent in the 1307 // LogicalDisplay. 1308 mAnimator.setPendingLayoutChanges(w.getDisplayId(), 1309 WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM); 1310 } else { 1311 w.mOrientationChanging = false; 1312 } 1313 } 1314 if (mSurfaceControl != null) { 1315 w.mToken.hasVisible = true; 1316 } 1317 } catch (RuntimeException e) { 1318 Slog.w(TAG, "Error updating surface in " + w, e); 1319 if (!recoveringMemory) { 1320 mService.reclaimSomeSurfaceMemoryLocked(this, "update", true); 1321 } 1322 } 1323 } 1324 } else { 1325 if (DEBUG_ANIM && isAnimating()) { 1326 Slog.v(TAG, "prepareSurface: No changes in animation for " + this); 1327 } 1328 displayed = true; 1329 } 1330 1331 if (displayed) { 1332 if (w.mOrientationChanging) { 1333 if (!w.isDrawnLw()) { 1334 mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE; 1335 mAnimator.mLastWindowFreezeSource = w; 1336 if (DEBUG_ORIENTATION) Slog.v(TAG, 1337 "Orientation continue waiting for draw in " + w); 1338 } else { 1339 w.mOrientationChanging = false; 1340 if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w); 1341 } 1342 } 1343 w.mToken.hasVisible = true; 1344 } 1345 } 1346 1347 void setTransparentRegionHintLocked(final Region region) { 1348 if (mSurfaceControl == null) { 1349 Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true"); 1350 return; 1351 } 1352 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setTransparentRegion"); 1353 SurfaceControl.openTransaction(); 1354 try { 1355 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 1356 "transparentRegionHint=" + region, null); 1357 mSurfaceControl.setTransparentRegionHint(region); 1358 } finally { 1359 SurfaceControl.closeTransaction(); 1360 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, 1361 "<<< CLOSE TRANSACTION setTransparentRegion"); 1362 } 1363 } 1364 1365 void setWallpaperOffset(RectF shownFrame) { 1366 final int left = (int) shownFrame.left; 1367 final int top = (int) shownFrame.top; 1368 if (mSurfaceX != left || mSurfaceY != top) { 1369 mSurfaceX = left; 1370 mSurfaceY = top; 1371 if (mAnimating) { 1372 // If this window (or its app token) is animating, then the position 1373 // of the surface will be re-computed on the next animation frame. 1374 // We can't poke it directly here because it depends on whatever 1375 // transformation is being applied by the animation. 1376 return; 1377 } 1378 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setWallpaperOffset"); 1379 SurfaceControl.openTransaction(); 1380 try { 1381 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 1382 "POS " + left + ", " + top, null); 1383 mSurfaceControl.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top); 1384 updateSurfaceWindowCrop(false); 1385 } catch (RuntimeException e) { 1386 Slog.w(TAG, "Error positioning surface of " + mWin 1387 + " pos=(" + left + "," + top + ")", e); 1388 } finally { 1389 SurfaceControl.closeTransaction(); 1390 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, 1391 "<<< CLOSE TRANSACTION setWallpaperOffset"); 1392 } 1393 } 1394 } 1395 1396 void setOpaque(boolean isOpaque) { 1397 if (mSurfaceControl == null) { 1398 return; 1399 } 1400 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setOpaque"); 1401 SurfaceControl.openTransaction(); 1402 try { 1403 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "isOpaque=" + isOpaque, 1404 null); 1405 mSurfaceControl.setOpaque(isOpaque); 1406 } finally { 1407 SurfaceControl.closeTransaction(); 1408 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setOpaque"); 1409 } 1410 } 1411 1412 // This must be called while inside a transaction. 1413 boolean performShowLocked() { 1414 if (mWin.isHiddenFromUserLocked()) { 1415 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display " 1416 + this + ", type " + mWin.mAttrs.type + ", belonging to " + mWin.mOwnerUid); 1417 return false; 1418 } 1419 if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && 1420 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { 1421 RuntimeException e = null; 1422 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 1423 e = new RuntimeException(); 1424 e.fillInStackTrace(); 1425 } 1426 Slog.v(TAG, "performShow on " + this 1427 + ": mDrawState=" + mDrawState + " readyForDisplay=" 1428 + mWin.isReadyForDisplayIgnoringKeyguard() 1429 + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING) 1430 + " during animation: policyVis=" + mWin.mPolicyVisibility 1431 + " attHidden=" + mWin.mAttachedHidden 1432 + " tok.hiddenRequested=" 1433 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false) 1434 + " tok.hidden=" 1435 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) 1436 + " animating=" + mAnimating 1437 + " tok animating=" 1438 + (mAppAnimator != null ? mAppAnimator.animating : false), e); 1439 } 1440 if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplayIgnoringKeyguard()) { 1441 if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) 1442 WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null); 1443 if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && 1444 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { 1445 Slog.v(TAG, "Showing " + this 1446 + " during animation: policyVis=" + mWin.mPolicyVisibility 1447 + " attHidden=" + mWin.mAttachedHidden 1448 + " tok.hiddenRequested=" 1449 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false) 1450 + " tok.hidden=" 1451 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) 1452 + " animating=" + mAnimating 1453 + " tok animating=" 1454 + (mAppAnimator != null ? mAppAnimator.animating : false)); 1455 } 1456 1457 mService.enableScreenIfNeededLocked(); 1458 1459 applyEnterAnimationLocked(); 1460 1461 // Force the show in the next prepareSurfaceLocked() call. 1462 mLastAlpha = -1; 1463 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) 1464 Slog.v(TAG, "performShowLocked: mDrawState=HAS_DRAWN in " + this); 1465 mDrawState = HAS_DRAWN; 1466 mService.scheduleAnimationLocked(); 1467 1468 int i = mWin.mChildWindows.size(); 1469 while (i > 0) { 1470 i--; 1471 WindowState c = mWin.mChildWindows.get(i); 1472 if (c.mAttachedHidden) { 1473 c.mAttachedHidden = false; 1474 if (c.mWinAnimator.mSurfaceControl != null) { 1475 c.mWinAnimator.performShowLocked(); 1476 // It hadn't been shown, which means layout not 1477 // performed on it, so now we want to make sure to 1478 // do a layout. If called from within the transaction 1479 // loop, this will cause it to restart with a new 1480 // layout. 1481 final DisplayContent displayContent = c.getDisplayContent(); 1482 if (displayContent != null) { 1483 displayContent.layoutNeeded = true; 1484 } 1485 } 1486 } 1487 } 1488 1489 if (mWin.mAttrs.type != TYPE_APPLICATION_STARTING 1490 && mWin.mAppToken != null) { 1491 mWin.mAppToken.firstWindowDrawn = true; 1492 1493 if (mWin.mAppToken.startingData != null) { 1494 if (WindowManagerService.DEBUG_STARTING_WINDOW || 1495 WindowManagerService.DEBUG_ANIM) Slog.v(TAG, 1496 "Finish starting " + mWin.mToken 1497 + ": first real window is shown, no animation"); 1498 // If this initial window is animating, stop it -- we 1499 // will do an animation to reveal it from behind the 1500 // starting window, so there is no need for it to also 1501 // be doing its own stuff. 1502 clearAnimation(); 1503 mService.mFinishedStarting.add(mWin.mAppToken); 1504 mService.mH.sendEmptyMessage(H.FINISHED_STARTING); 1505 } 1506 mWin.mAppToken.updateReportedVisibilityLocked(); 1507 } 1508 1509 return true; 1510 } 1511 1512 return false; 1513 } 1514 1515 /** 1516 * Have the surface flinger show a surface, robustly dealing with 1517 * error conditions. In particular, if there is not enough memory 1518 * to show the surface, then we will try to get rid of other surfaces 1519 * in order to succeed. 1520 * 1521 * @return Returns true if the surface was successfully shown. 1522 */ 1523 boolean showSurfaceRobustlyLocked() { 1524 try { 1525 if (mSurfaceControl != null) { 1526 mSurfaceShown = true; 1527 mSurfaceControl.show(); 1528 if (mWin.mTurnOnScreen) { 1529 if (DEBUG_VISIBILITY) Slog.v(TAG, 1530 "Show surface turning screen on: " + mWin); 1531 mWin.mTurnOnScreen = false; 1532 mAnimator.mBulkUpdateParams |= SET_TURN_ON_SCREEN; 1533 } 1534 } 1535 return true; 1536 } catch (RuntimeException e) { 1537 Slog.w(TAG, "Failure showing surface " + mSurfaceControl + " in " + mWin, e); 1538 } 1539 1540 mService.reclaimSomeSurfaceMemoryLocked(this, "show", true); 1541 1542 return false; 1543 } 1544 1545 void applyEnterAnimationLocked() { 1546 final int transit; 1547 if (mEnterAnimationPending) { 1548 mEnterAnimationPending = false; 1549 transit = WindowManagerPolicy.TRANSIT_ENTER; 1550 } else { 1551 transit = WindowManagerPolicy.TRANSIT_SHOW; 1552 } 1553 applyAnimationLocked(transit, true); 1554 //TODO (multidisplay): Magnification is supported only for the default display. 1555 if (mService.mDisplayMagnifier != null 1556 && mWin.getDisplayId() == Display.DEFAULT_DISPLAY) { 1557 mService.mDisplayMagnifier.onWindowTransitionLocked(mWin, transit); 1558 } 1559 } 1560 1561 /** 1562 * Choose the correct animation and set it to the passed WindowState. 1563 * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn 1564 * then the animation will be app_starting_exit. Any other value loads the animation from 1565 * the switch statement below. 1566 * @param isEntrance The animation type the last time this was called. Used to keep from 1567 * loading the same animation twice. 1568 * @return true if an animation has been loaded. 1569 */ 1570 boolean applyAnimationLocked(int transit, boolean isEntrance) { 1571 if (mLocalAnimating && mAnimationIsEntrance == isEntrance) { 1572 // If we are trying to apply an animation, but already running 1573 // an animation of the same type, then just leave that one alone. 1574 return true; 1575 } 1576 1577 // Only apply an animation if the display isn't frozen. If it is 1578 // frozen, there is no reason to animate and it can cause strange 1579 // artifacts when we unfreeze the display if some different animation 1580 // is running. 1581 if (mService.okToDisplay()) { 1582 int anim = mPolicy.selectAnimationLw(mWin, transit); 1583 int attr = -1; 1584 Animation a = null; 1585 if (anim != 0) { 1586 a = anim != -1 ? AnimationUtils.loadAnimation(mContext, anim) : null; 1587 } else { 1588 switch (transit) { 1589 case WindowManagerPolicy.TRANSIT_ENTER: 1590 attr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation; 1591 break; 1592 case WindowManagerPolicy.TRANSIT_EXIT: 1593 attr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation; 1594 break; 1595 case WindowManagerPolicy.TRANSIT_SHOW: 1596 attr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation; 1597 break; 1598 case WindowManagerPolicy.TRANSIT_HIDE: 1599 attr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation; 1600 break; 1601 } 1602 if (attr >= 0) { 1603 a = mService.mAppTransition.loadAnimation(mWin.mAttrs, attr); 1604 } 1605 } 1606 if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, 1607 "applyAnimation: win=" + this 1608 + " anim=" + anim + " attr=0x" + Integer.toHexString(attr) 1609 + " a=" + a 1610 + " transit=" + transit 1611 + " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3)); 1612 if (a != null) { 1613 if (WindowManagerService.DEBUG_ANIM) { 1614 RuntimeException e = null; 1615 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 1616 e = new RuntimeException(); 1617 e.fillInStackTrace(); 1618 } 1619 Slog.v(TAG, "Loaded animation " + a + " for " + this, e); 1620 } 1621 setAnimation(a); 1622 mAnimationIsEntrance = isEntrance; 1623 } 1624 } else { 1625 clearAnimation(); 1626 } 1627 1628 return mAnimation != null; 1629 } 1630 1631 public void dump(PrintWriter pw, String prefix, boolean dumpAll) { 1632 if (mAnimating || mLocalAnimating || mAnimationIsEntrance 1633 || mAnimation != null) { 1634 pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); 1635 pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); 1636 pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); 1637 pw.print(" mAnimation="); pw.println(mAnimation); 1638 } 1639 if (mHasTransformation || mHasLocalTransformation) { 1640 pw.print(prefix); pw.print("XForm: has="); 1641 pw.print(mHasTransformation); 1642 pw.print(" hasLocal="); pw.print(mHasLocalTransformation); 1643 pw.print(" "); mTransformation.printShortString(pw); 1644 pw.println(); 1645 } 1646 if (mSurfaceControl != null) { 1647 if (dumpAll) { 1648 pw.print(prefix); pw.print("mSurface="); pw.println(mSurfaceControl); 1649 pw.print(prefix); pw.print("mDrawState="); 1650 pw.print(drawStateToString(mDrawState)); 1651 pw.print(" mLastHidden="); pw.println(mLastHidden); 1652 } 1653 pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); 1654 pw.print(" layer="); pw.print(mSurfaceLayer); 1655 pw.print(" alpha="); pw.print(mSurfaceAlpha); 1656 pw.print(" rect=("); pw.print(mSurfaceX); 1657 pw.print(","); pw.print(mSurfaceY); 1658 pw.print(") "); pw.print(mSurfaceW); 1659 pw.print(" x "); pw.println(mSurfaceH); 1660 } 1661 if (mPendingDestroySurface != null) { 1662 pw.print(prefix); pw.print("mPendingDestroySurface="); 1663 pw.println(mPendingDestroySurface); 1664 } 1665 if (mSurfaceResized || mSurfaceDestroyDeferred) { 1666 pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized); 1667 pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred); 1668 } 1669 if (mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND) { 1670 pw.print(prefix); pw.print("mUniverseTransform="); 1671 mUniverseTransform.printShortString(pw); 1672 pw.println(); 1673 } 1674 if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { 1675 pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); 1676 pw.print(" mAlpha="); pw.print(mAlpha); 1677 pw.print(" mLastAlpha="); pw.println(mLastAlpha); 1678 } 1679 if (mHaveMatrix || mWin.mGlobalScale != 1) { 1680 pw.print(prefix); pw.print("mGlobalScale="); pw.print(mWin.mGlobalScale); 1681 pw.print(" mDsDx="); pw.print(mDsDx); 1682 pw.print(" mDtDx="); pw.print(mDtDx); 1683 pw.print(" mDsDy="); pw.print(mDsDy); 1684 pw.print(" mDtDy="); pw.println(mDtDy); 1685 } 1686 } 1687 1688 @Override 1689 public String toString() { 1690 StringBuffer sb = new StringBuffer("WindowStateAnimator{"); 1691 sb.append(Integer.toHexString(System.identityHashCode(this))); 1692 sb.append(' '); 1693 sb.append(mWin.mAttrs.getTitle()); 1694 sb.append('}'); 1695 return sb.toString(); 1696 } 1697} 1698