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