WindowStateAnimator.java revision 5f8aa4142919b3001fd2621f7acd5f609a5129a5
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 DisplayInfo displayInfo = win.getDisplayContent().getDisplayInfo(); 175 mAnimDw = displayInfo.appWidth; 176 mAnimDh = displayInfo.appHeight; 177 178 mWin = win; 179 mAttachedWinAnimator = win.mAttachedWindow == null 180 ? null : win.mAttachedWindow.mWinAnimator; 181 mAppAnimator = win.mAppToken == null ? null : win.mAppToken.mAppAnimator; 182 mSession = win.mSession; 183 mAttrFlags = win.mAttrs.flags; 184 mAttrType = win.mAttrs.type; 185 mIsWallpaper = win.mIsWallpaper; 186 } 187 188 public void setAnimation(Animation anim) { 189 if (localLOGV) Slog.v(TAG, "Setting animation in " + this + ": " + anim); 190 mAnimating = false; 191 mLocalAnimating = false; 192 mAnimation = anim; 193 mAnimation.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION); 194 mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale); 195 // Start out animation gone if window is gone, or visible if window is visible. 196 mTransformation.clear(); 197 mTransformation.setAlpha(mLastHidden ? 0 : 1); 198 mHasLocalTransformation = true; 199 } 200 201 public void clearAnimation() { 202 if (mAnimation != null) { 203 mAnimating = true; 204 mLocalAnimating = false; 205 mAnimation.cancel(); 206 mAnimation = null; 207 } 208 } 209 210 /** Is the window or its container currently animating? */ 211 boolean isAnimating() { 212 return mAnimation != null 213 || (mAttachedWinAnimator != null && mAttachedWinAnimator.mAnimation != null) 214 || (mAppAnimator != null && 215 (mAppAnimator.animation != null 216 || mAppAnimator.mAppToken.inPendingTransaction)); 217 } 218 219 /** Is the window animating the DummyAnimation? */ 220 boolean isDummyAnimation() { 221 return mAppAnimator != null 222 && mAppAnimator.animation == AppWindowAnimator.sDummyAnimation; 223 } 224 225 /** Is this window currently animating? */ 226 boolean isWindowAnimating() { 227 return mAnimation != null; 228 } 229 230 void cancelExitAnimationForNextAnimationLocked() { 231 if (mAnimation != null) { 232 mAnimation.cancel(); 233 mAnimation = null; 234 mLocalAnimating = false; 235 destroySurfaceLocked(); 236 } 237 } 238 239 private boolean stepAnimation(long currentTime) { 240 if ((mAnimation == null) || !mLocalAnimating) { 241 return false; 242 } 243 mTransformation.clear(); 244 final boolean more = mAnimation.getTransformation(currentTime, mTransformation); 245 if (false && DEBUG_ANIM) Slog.v( 246 TAG, "Stepped animation in " + this + 247 ": more=" + more + ", xform=" + mTransformation); 248 return more; 249 } 250 251 // This must be called while inside a transaction. Returns true if 252 // there is more animation to run. 253 boolean stepAnimationLocked(long currentTime) { 254 // Save the animation state as it was before this step so WindowManagerService can tell if 255 // we just started or just stopped animating by comparing mWasAnimating with isAnimating(). 256 mWasAnimating = mAnimating; 257 final DisplayContent displayContent = mWin.getDisplayContent(); 258 if (displayContent != null && mService.okToDisplay()) { 259 // We will run animations as long as the display isn't frozen. 260 261 if (mWin.isDrawnLw() && mAnimation != null) { 262 mHasTransformation = true; 263 mHasLocalTransformation = true; 264 if (!mLocalAnimating) { 265 if (DEBUG_ANIM) Slog.v( 266 TAG, "Starting animation in " + this + 267 " @ " + currentTime + ": ww=" + mWin.mFrame.width() + 268 " wh=" + mWin.mFrame.height() + 269 " dw=" + mAnimDw + " dh=" + mAnimDh + 270 " scale=" + mService.mWindowAnimationScale); 271 mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), 272 mAnimDw, mAnimDh); 273 final DisplayInfo displayInfo = displayContent.getDisplayInfo(); 274 mAnimDw = displayInfo.appWidth; 275 mAnimDh = displayInfo.appHeight; 276 mAnimation.setStartTime(currentTime); 277 mLocalAnimating = true; 278 mAnimating = true; 279 } 280 if ((mAnimation != null) && mLocalAnimating) { 281 if (stepAnimation(currentTime)) { 282 return true; 283 } 284 } 285 if (DEBUG_ANIM) Slog.v( 286 TAG, "Finished animation in " + this + 287 " @ " + currentTime); 288 //WindowManagerService.this.dump(); 289 } 290 mHasLocalTransformation = false; 291 if ((!mLocalAnimating || mAnimationIsEntrance) && mAppAnimator != null 292 && mAppAnimator.animation != null) { 293 // When our app token is animating, we kind-of pretend like 294 // we are as well. Note the mLocalAnimating mAnimationIsEntrance 295 // part of this check means that we will only do this if 296 // our window is not currently exiting, or it is not 297 // locally animating itself. The idea being that one that 298 // is exiting and doing a local animation should be removed 299 // once that animation is done. 300 mAnimating = true; 301 mHasTransformation = true; 302 mTransformation.clear(); 303 return false; 304 } else if (mHasTransformation) { 305 // Little trick to get through the path below to act like 306 // we have finished an animation. 307 mAnimating = true; 308 } else if (isAnimating()) { 309 mAnimating = true; 310 } 311 } else if (mAnimation != null) { 312 // If the display is frozen, and there is a pending animation, 313 // clear it and make sure we run the cleanup code. 314 mAnimating = true; 315 } 316 317 if (!mAnimating && !mLocalAnimating) { 318 return false; 319 } 320 321 // Done animating, clean up. 322 if (DEBUG_ANIM) Slog.v( 323 TAG, "Animation done in " + this + ": exiting=" + mWin.mExiting 324 + ", reportedVisible=" 325 + (mWin.mAppToken != null ? mWin.mAppToken.reportedVisible : false)); 326 327 mAnimating = false; 328 mLocalAnimating = false; 329 if (mAnimation != null) { 330 mAnimation.cancel(); 331 mAnimation = null; 332 } 333 if (mAnimator.mWindowDetachedWallpaper == mWin) { 334 mAnimator.mWindowDetachedWallpaper = null; 335 } 336 mAnimLayer = mWin.mLayer; 337 if (mWin.mIsImWindow) { 338 mAnimLayer += mService.mInputMethodAnimLayerAdjustment; 339 } else if (mIsWallpaper) { 340 mAnimLayer += mService.mWallpaperAnimLayerAdjustment; 341 } 342 if (DEBUG_LAYERS) Slog.v(TAG, "Stepping win " + this 343 + " anim layer: " + mAnimLayer); 344 mHasTransformation = false; 345 mHasLocalTransformation = false; 346 if (mWin.mPolicyVisibility != mWin.mPolicyVisibilityAfterAnim) { 347 if (DEBUG_VISIBILITY) { 348 Slog.v(TAG, "Policy visibility changing after anim in " + this + ": " 349 + mWin.mPolicyVisibilityAfterAnim); 350 } 351 mWin.mPolicyVisibility = mWin.mPolicyVisibilityAfterAnim; 352 if (displayContent != null) { 353 displayContent.layoutNeeded = true; 354 } 355 if (!mWin.mPolicyVisibility) { 356 if (mService.mCurrentFocus == mWin) { 357 if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, 358 "setAnimationLocked: setting mFocusMayChange true"); 359 mService.mFocusMayChange = true; 360 } 361 // Window is no longer visible -- make sure if we were waiting 362 // for it to be displayed before enabling the display, that 363 // we allow the display to be enabled now. 364 mService.enableScreenIfNeededLocked(); 365 } 366 } 367 mTransformation.clear(); 368 if (mDrawState == HAS_DRAWN 369 && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING 370 && mWin.mAppToken != null 371 && mWin.mAppToken.firstWindowDrawn 372 && mWin.mAppToken.startingData != null) { 373 if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Finish starting " 374 + mWin.mToken + ": first real window done animating"); 375 mService.mFinishedStarting.add(mWin.mAppToken); 376 mService.mH.sendEmptyMessage(H.FINISHED_STARTING); 377 } else if (mAttrType == LayoutParams.TYPE_STATUS_BAR && mWin.mPolicyVisibility) { 378 // Upon completion of a not-visible to visible status bar animation a relayout is 379 // required. 380 if (displayContent != null) { 381 displayContent.layoutNeeded = true; 382 } 383 } 384 385 finishExit(); 386 final int displayId = mWin.getDisplayId(); 387 mAnimator.setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM); 388 if (WindowManagerService.DEBUG_LAYOUT_REPEATS) mService.debugLayoutRepeats( 389 "WindowStateAnimator", mAnimator.getPendingLayoutChanges(displayId)); 390 391 if (mWin.mAppToken != null) { 392 mWin.mAppToken.updateReportedVisibilityLocked(); 393 } 394 395 return false; 396 } 397 398 void finishExit() { 399 if (WindowManagerService.DEBUG_ANIM) Slog.v( 400 TAG, "finishExit in " + this 401 + ": exiting=" + mWin.mExiting 402 + " remove=" + mWin.mRemoveOnExit 403 + " windowAnimating=" + isWindowAnimating()); 404 405 final int N = mWin.mChildWindows.size(); 406 for (int i=0; i<N; i++) { 407 mWin.mChildWindows.get(i).mWinAnimator.finishExit(); 408 } 409 410 if (!mWin.mExiting) { 411 return; 412 } 413 414 if (isWindowAnimating()) { 415 return; 416 } 417 418 if (WindowManagerService.localLOGV) Slog.v( 419 TAG, "Exit animation finished in " + this 420 + ": remove=" + mWin.mRemoveOnExit); 421 if (mSurfaceControl != null) { 422 mService.mDestroySurface.add(mWin); 423 mWin.mDestroying = true; 424 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface( 425 mWin, "HIDE (finishExit)", null); 426 hide(); 427 } 428 mWin.mExiting = false; 429 if (mWin.mRemoveOnExit) { 430 mService.mPendingRemove.add(mWin); 431 mWin.mRemoveOnExit = false; 432 } 433 mService.mPendingStacksRemove.add(mWin.getStack()); 434 mAnimator.hideWallpapersLocked(mWin); 435 } 436 437 void hide() { 438 if (!mLastHidden) { 439 //dump(); 440 mLastHidden = true; 441 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 442 "HIDE (performLayout)", null); 443 if (mSurfaceControl != null) { 444 mSurfaceShown = false; 445 try { 446 mSurfaceControl.hide(); 447 } catch (RuntimeException e) { 448 Slog.w(TAG, "Exception hiding surface in " + mWin); 449 } 450 } 451 } 452 } 453 454 boolean finishDrawingLocked() { 455 if (DEBUG_STARTING_WINDOW && 456 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 457 Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState=" 458 + drawStateToString(mDrawState)); 459 } 460 if (mDrawState == DRAW_PENDING) { 461 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) 462 Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in " 463 + mSurfaceControl); 464 if (DEBUG_STARTING_WINDOW && 465 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 466 Slog.v(TAG, "Draw state now committed in " + mWin); 467 } 468 mDrawState = COMMIT_DRAW_PENDING; 469 return true; 470 } 471 return false; 472 } 473 474 // This must be called while inside a transaction. 475 boolean commitFinishDrawingLocked(long currentTime) { 476 if (DEBUG_STARTING_WINDOW && 477 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { 478 Slog.i(TAG, "commitFinishDrawingLocked: " + mWin + " cur mDrawState=" 479 + drawStateToString(mDrawState)); 480 } 481 if (mDrawState != COMMIT_DRAW_PENDING) { 482 return false; 483 } 484 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) { 485 Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurfaceControl); 486 } 487 mDrawState = READY_TO_SHOW; 488 final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING; 489 final AppWindowToken atoken = mWin.mAppToken; 490 if (atoken == null || atoken.allDrawn || starting) { 491 performShowLocked(); 492 } 493 return true; 494 } 495 496 static class SurfaceTrace extends SurfaceControl { 497 private final static String SURFACE_TAG = "SurfaceTrace"; 498 final static ArrayList<SurfaceTrace> sSurfaces = new ArrayList<SurfaceTrace>(); 499 500 private float mSurfaceTraceAlpha = 0; 501 private int mLayer; 502 private final PointF mPosition = new PointF(); 503 private final Point mSize = new Point(); 504 private final Rect mWindowCrop = new Rect(); 505 private boolean mShown = false; 506 private int mLayerStack; 507 private boolean mIsOpaque; 508 private final String mName; 509 510 public SurfaceTrace(SurfaceSession s, 511 String name, int w, int h, int format, int flags) 512 throws OutOfResourcesException { 513 super(s, name, w, h, format, flags); 514 mName = name != null ? name : "Not named"; 515 mSize.set(w, h); 516 Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by " 517 + Debug.getCallers(3)); 518 } 519 520 @Override 521 public void setAlpha(float alpha) { 522 if (mSurfaceTraceAlpha != alpha) { 523 Slog.v(SURFACE_TAG, "setAlpha(" + alpha + "): OLD:" + this + ". Called by " 524 + Debug.getCallers(3)); 525 mSurfaceTraceAlpha = alpha; 526 } 527 super.setAlpha(alpha); 528 } 529 530 @Override 531 public void setLayer(int zorder) { 532 if (zorder != mLayer) { 533 Slog.v(SURFACE_TAG, "setLayer(" + zorder + "): OLD:" + this + ". Called by " 534 + Debug.getCallers(3)); 535 mLayer = zorder; 536 } 537 super.setLayer(zorder); 538 539 sSurfaces.remove(this); 540 int i; 541 for (i = sSurfaces.size() - 1; i >= 0; i--) { 542 SurfaceTrace s = sSurfaces.get(i); 543 if (s.mLayer < zorder) { 544 break; 545 } 546 } 547 sSurfaces.add(i + 1, this); 548 } 549 550 @Override 551 public void setPosition(float x, float y) { 552 if (x != mPosition.x || y != mPosition.y) { 553 Slog.v(SURFACE_TAG, "setPosition(" + x + "," + y + "): OLD:" + this 554 + ". Called by " + Debug.getCallers(3)); 555 mPosition.set(x, y); 556 } 557 super.setPosition(x, y); 558 } 559 560 @Override 561 public void setSize(int w, int h) { 562 if (w != mSize.x || h != mSize.y) { 563 Slog.v(SURFACE_TAG, "setSize(" + w + "," + h + "): OLD:" + this + ". Called by " 564 + Debug.getCallers(3)); 565 mSize.set(w, h); 566 } 567 super.setSize(w, h); 568 } 569 570 @Override 571 public void setWindowCrop(Rect crop) { 572 if (crop != null) { 573 if (!crop.equals(mWindowCrop)) { 574 Slog.v(SURFACE_TAG, "setWindowCrop(" + crop.toShortString() + "): OLD:" + this 575 + ". Called by " + Debug.getCallers(3)); 576 mWindowCrop.set(crop); 577 } 578 } 579 super.setWindowCrop(crop); 580 } 581 582 @Override 583 public void setLayerStack(int layerStack) { 584 if (layerStack != mLayerStack) { 585 Slog.v(SURFACE_TAG, "setLayerStack(" + layerStack + "): OLD:" + this 586 + ". Called by " + Debug.getCallers(3)); 587 mLayerStack = layerStack; 588 } 589 super.setLayerStack(layerStack); 590 } 591 592 @Override 593 public void setOpaque(boolean isOpaque) { 594 if (isOpaque != mIsOpaque) { 595 Slog.v(SURFACE_TAG, "setOpaque(" + isOpaque + "): OLD:" + this 596 + ". Called by " + Debug.getCallers(3)); 597 mIsOpaque = isOpaque; 598 } 599 super.setOpaque(isOpaque); 600 } 601 602 @Override 603 public void hide() { 604 if (mShown) { 605 Slog.v(SURFACE_TAG, "hide: OLD:" + this + ". Called by " + Debug.getCallers(3)); 606 mShown = false; 607 } 608 super.hide(); 609 } 610 611 @Override 612 public void show() { 613 if (!mShown) { 614 Slog.v(SURFACE_TAG, "show: OLD:" + this + ". Called by " + Debug.getCallers(3)); 615 mShown = true; 616 } 617 super.show(); 618 } 619 620 @Override 621 public void destroy() { 622 super.destroy(); 623 Slog.v(SURFACE_TAG, "destroy: " + this + ". Called by " + Debug.getCallers(3)); 624 sSurfaces.remove(this); 625 } 626 627 @Override 628 public void release() { 629 super.release(); 630 Slog.v(SURFACE_TAG, "release: " + this + ". Called by " 631 + Debug.getCallers(3)); 632 sSurfaces.remove(this); 633 } 634 635 static void dumpAllSurfaces() { 636 final int N = sSurfaces.size(); 637 for (int i = 0; i < N; i++) { 638 Slog.i(TAG, "SurfaceDump: " + sSurfaces.get(i)); 639 } 640 } 641 642 @Override 643 public String toString() { 644 return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " " 645 + mName + " (" + mLayerStack + "): shown=" + mShown + " layer=" + mLayer 646 + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y 647 + " " + mSize.x + "x" + mSize.y 648 + " crop=" + mWindowCrop.toShortString() 649 + " opaque=" + mIsOpaque; 650 } 651 } 652 653 SurfaceControl createSurfaceLocked() { 654 if (mSurfaceControl == null) { 655 if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG, 656 "createSurface " + this + ": mDrawState=DRAW_PENDING"); 657 mDrawState = DRAW_PENDING; 658 if (mWin.mAppToken != null) { 659 if (mWin.mAppToken.mAppAnimator.animation == null) { 660 mWin.mAppToken.allDrawn = false; 661 mWin.mAppToken.deferClearAllDrawn = false; 662 } else { 663 // Currently animating, persist current state of allDrawn until animation 664 // is complete. 665 mWin.mAppToken.deferClearAllDrawn = true; 666 } 667 } 668 669 mService.makeWindowFreezingScreenIfNeededLocked(mWin); 670 671 int flags = SurfaceControl.HIDDEN; 672 final WindowManager.LayoutParams attrs = mWin.mAttrs; 673 final boolean isVideoPlane = 674 (attrs.privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_VIDEO_PLANE) != 0; 675 676 if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) { 677 flags |= SurfaceControl.SECURE; 678 } 679 if (isVideoPlane) { 680 flags |= SurfaceControl.FX_SURFACE_VIDEO_PLANE; 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