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