WindowStateAnimator.java revision 96d970c93e0ed639f0639a1ea17bb98acc703ff1
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 // NOTE: We are adding a temporary workaround due to the status bar not always reporting 1169 // the correct system decor rect. In such cases, we take into account the specified 1170 // content insets as well. 1171 int offsetTop = Math.max(w.mSystemDecorRect.top, w.mContentInsets.top); 1172 mTmpClipRect.set(w.mSystemDecorRect); 1173 mTmpClipRect.offset(0, -offsetTop); 1174 mTmpClipRect.intersect(mClipRect); 1175 mTmpClipRect.offset(0, offsetTop); 1176 clipRect = mTmpClipRect; 1177 1178 } 1179 1180 if (!clipRect.equals(mLastClipRect)) { 1181 mLastClipRect.set(clipRect); 1182 try { 1183 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1184 "CROP " + clipRect.toShortString(), null); 1185 mSurfaceControl.setWindowCrop(clipRect); 1186 } catch (RuntimeException e) { 1187 Slog.w(TAG, "Error setting crop surface of " + w 1188 + " crop=" + clipRect.toShortString(), e); 1189 if (!recoveringMemory) { 1190 mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true); 1191 } 1192 } 1193 } 1194 } 1195 1196 void setSurfaceBoundariesLocked(final boolean recoveringMemory) { 1197 final WindowState w = mWin; 1198 int width, height; 1199 if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) { 1200 // for a scaled surface, we just want to use 1201 // the requested size. 1202 width = w.mRequestedWidth; 1203 height = w.mRequestedHeight; 1204 } else { 1205 width = w.mCompatFrame.width(); 1206 height = w.mCompatFrame.height(); 1207 } 1208 1209 if (width < 1) { 1210 width = 1; 1211 } 1212 if (height < 1) { 1213 height = 1; 1214 } 1215 final boolean surfaceResized = mSurfaceW != width || mSurfaceH != height; 1216 if (surfaceResized) { 1217 mSurfaceW = width; 1218 mSurfaceH = height; 1219 } 1220 1221 final float left = w.mShownFrame.left; 1222 final float top = w.mShownFrame.top; 1223 if (mSurfaceX != left || mSurfaceY != top) { 1224 try { 1225 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1226 "POS " + left + ", " + top, null); 1227 mSurfaceX = left; 1228 mSurfaceY = top; 1229 mSurfaceControl.setPosition(left, top); 1230 } catch (RuntimeException e) { 1231 Slog.w(TAG, "Error positioning surface of " + w 1232 + " pos=(" + left 1233 + "," + top + ")", e); 1234 if (!recoveringMemory) { 1235 mService.reclaimSomeSurfaceMemoryLocked(this, "position", true); 1236 } 1237 } 1238 } 1239 1240 if (surfaceResized) { 1241 try { 1242 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1243 "SIZE " + width + "x" + height, null); 1244 mSurfaceResized = true; 1245 mSurfaceControl.setSize(width, height); 1246 mAnimator.setPendingLayoutChanges(w.getDisplayId(), 1247 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER); 1248 if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) { 1249 w.getStack().startDimmingIfNeeded(this); 1250 } 1251 } catch (RuntimeException e) { 1252 // If something goes wrong with the surface (such 1253 // as running out of memory), don't take down the 1254 // entire system. 1255 Slog.e(TAG, "Error resizing surface of " + w 1256 + " size=(" + width + "x" + height + ")", e); 1257 if (!recoveringMemory) { 1258 mService.reclaimSomeSurfaceMemoryLocked(this, "size", true); 1259 } 1260 } 1261 } 1262 1263 updateSurfaceWindowCrop(recoveringMemory); 1264 } 1265 1266 public void prepareSurfaceLocked(final boolean recoveringMemory) { 1267 final WindowState w = mWin; 1268 if (mSurfaceControl == null) { 1269 if (w.mOrientationChanging) { 1270 if (DEBUG_ORIENTATION) { 1271 Slog.v(TAG, "Orientation change skips hidden " + w); 1272 } 1273 w.mOrientationChanging = false; 1274 } 1275 return; 1276 } 1277 1278 boolean displayed = false; 1279 1280 computeShownFrameLocked(); 1281 1282 setSurfaceBoundariesLocked(recoveringMemory); 1283 1284 if (mIsWallpaper && !mWin.mWallpaperVisible) { 1285 // Wallpaper is no longer visible and there is no wp target => hide it. 1286 hide(); 1287 } else if (w.mAttachedHidden || !w.isOnScreen()) { 1288 hide(); 1289 mAnimator.hideWallpapersLocked(w); 1290 1291 // If we are waiting for this window to handle an 1292 // orientation change, well, it is hidden, so 1293 // doesn't really matter. Note that this does 1294 // introduce a potential glitch if the window 1295 // becomes unhidden before it has drawn for the 1296 // new orientation. 1297 if (w.mOrientationChanging) { 1298 w.mOrientationChanging = false; 1299 if (DEBUG_ORIENTATION) Slog.v(TAG, 1300 "Orientation change skips hidden " + w); 1301 } 1302 } else if (mLastLayer != mAnimLayer 1303 || mLastAlpha != mShownAlpha 1304 || mLastDsDx != mDsDx 1305 || mLastDtDx != mDtDx 1306 || mLastDsDy != mDsDy 1307 || mLastDtDy != mDtDy 1308 || w.mLastHScale != w.mHScale 1309 || w.mLastVScale != w.mVScale 1310 || mLastHidden) { 1311 displayed = true; 1312 mLastAlpha = mShownAlpha; 1313 mLastLayer = mAnimLayer; 1314 mLastDsDx = mDsDx; 1315 mLastDtDx = mDtDx; 1316 mLastDsDy = mDsDy; 1317 mLastDtDy = mDtDy; 1318 w.mLastHScale = w.mHScale; 1319 w.mLastVScale = w.mVScale; 1320 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1321 "alpha=" + mShownAlpha + " layer=" + mAnimLayer 1322 + " matrix=[" + (mDsDx*w.mHScale) 1323 + "," + (mDtDx*w.mVScale) 1324 + "][" + (mDsDy*w.mHScale) 1325 + "," + (mDtDy*w.mVScale) + "]", null); 1326 if (mSurfaceControl != null) { 1327 try { 1328 mSurfaceAlpha = mShownAlpha; 1329 mSurfaceControl.setAlpha(mShownAlpha); 1330 mSurfaceLayer = mAnimLayer; 1331 mSurfaceControl.setLayer(mAnimLayer); 1332 mSurfaceControl.setMatrix( 1333 mDsDx * w.mHScale, mDtDx * w.mVScale, 1334 mDsDy * w.mHScale, mDtDy * w.mVScale); 1335 1336 if (mLastHidden && mDrawState == HAS_DRAWN) { 1337 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, 1338 "SHOW (performLayout)", null); 1339 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w 1340 + " during relayout"); 1341 if (showSurfaceRobustlyLocked()) { 1342 mLastHidden = false; 1343 if (mIsWallpaper) { 1344 mService.dispatchWallpaperVisibility(w, true); 1345 } 1346 // This draw means the difference between unique content and mirroring. 1347 // Run another pass through performLayout to set mHasContent in the 1348 // LogicalDisplay. 1349 mAnimator.setPendingLayoutChanges(w.getDisplayId(), 1350 WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM); 1351 } else { 1352 w.mOrientationChanging = false; 1353 } 1354 } 1355 if (mSurfaceControl != null) { 1356 w.mToken.hasVisible = true; 1357 } 1358 } catch (RuntimeException e) { 1359 Slog.w(TAG, "Error updating surface in " + w, e); 1360 if (!recoveringMemory) { 1361 mService.reclaimSomeSurfaceMemoryLocked(this, "update", true); 1362 } 1363 } 1364 } 1365 } else { 1366 if (DEBUG_ANIM && isAnimating()) { 1367 Slog.v(TAG, "prepareSurface: No changes in animation for " + this); 1368 } 1369 displayed = true; 1370 } 1371 1372 if (displayed) { 1373 if (w.mOrientationChanging) { 1374 if (!w.isDrawnLw()) { 1375 mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE; 1376 mAnimator.mLastWindowFreezeSource = w; 1377 if (DEBUG_ORIENTATION) Slog.v(TAG, 1378 "Orientation continue waiting for draw in " + w); 1379 } else { 1380 w.mOrientationChanging = false; 1381 if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w); 1382 } 1383 } 1384 w.mToken.hasVisible = true; 1385 } 1386 } 1387 1388 void setTransparentRegionHintLocked(final Region region) { 1389 if (mSurfaceControl == null) { 1390 Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true"); 1391 return; 1392 } 1393 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setTransparentRegion"); 1394 SurfaceControl.openTransaction(); 1395 try { 1396 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 1397 "transparentRegionHint=" + region, null); 1398 mSurfaceControl.setTransparentRegionHint(region); 1399 } finally { 1400 SurfaceControl.closeTransaction(); 1401 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, 1402 "<<< CLOSE TRANSACTION setTransparentRegion"); 1403 } 1404 } 1405 1406 void setWallpaperOffset(RectF shownFrame) { 1407 final int left = (int) shownFrame.left; 1408 final int top = (int) shownFrame.top; 1409 if (mSurfaceX != left || mSurfaceY != top) { 1410 mSurfaceX = left; 1411 mSurfaceY = top; 1412 if (mAnimating) { 1413 // If this window (or its app token) is animating, then the position 1414 // of the surface will be re-computed on the next animation frame. 1415 // We can't poke it directly here because it depends on whatever 1416 // transformation is being applied by the animation. 1417 return; 1418 } 1419 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setWallpaperOffset"); 1420 SurfaceControl.openTransaction(); 1421 try { 1422 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, 1423 "POS " + left + ", " + top, null); 1424 mSurfaceControl.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top); 1425 updateSurfaceWindowCrop(false); 1426 } catch (RuntimeException e) { 1427 Slog.w(TAG, "Error positioning surface of " + mWin 1428 + " pos=(" + left + "," + top + ")", e); 1429 } finally { 1430 SurfaceControl.closeTransaction(); 1431 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, 1432 "<<< CLOSE TRANSACTION setWallpaperOffset"); 1433 } 1434 } 1435 } 1436 1437 void setOpaque(boolean isOpaque) { 1438 if (mSurfaceControl == null) { 1439 return; 1440 } 1441 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setOpaque"); 1442 SurfaceControl.openTransaction(); 1443 try { 1444 if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, "isOpaque=" + isOpaque, 1445 null); 1446 mSurfaceControl.setOpaque(isOpaque); 1447 } finally { 1448 SurfaceControl.closeTransaction(); 1449 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setOpaque"); 1450 } 1451 } 1452 1453 // This must be called while inside a transaction. 1454 boolean performShowLocked() { 1455 if (mWin.isHiddenFromUserLocked()) { 1456 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display " 1457 + this + ", type " + mWin.mAttrs.type + ", belonging to " + mWin.mOwnerUid); 1458 return false; 1459 } 1460 if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && 1461 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { 1462 RuntimeException e = null; 1463 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 1464 e = new RuntimeException(); 1465 e.fillInStackTrace(); 1466 } 1467 Slog.v(TAG, "performShow on " + this 1468 + ": mDrawState=" + mDrawState + " readyForDisplay=" 1469 + mWin.isReadyForDisplayIgnoringKeyguard() 1470 + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING) 1471 + " during animation: policyVis=" + mWin.mPolicyVisibility 1472 + " attHidden=" + mWin.mAttachedHidden 1473 + " tok.hiddenRequested=" 1474 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false) 1475 + " tok.hidden=" 1476 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) 1477 + " animating=" + mAnimating 1478 + " tok animating=" 1479 + (mAppAnimator != null ? mAppAnimator.animating : false), e); 1480 } 1481 if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplayIgnoringKeyguard()) { 1482 if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) 1483 WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null); 1484 if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && 1485 mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { 1486 Slog.v(TAG, "Showing " + this 1487 + " during animation: policyVis=" + mWin.mPolicyVisibility 1488 + " attHidden=" + mWin.mAttachedHidden 1489 + " tok.hiddenRequested=" 1490 + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false) 1491 + " tok.hidden=" 1492 + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) 1493 + " animating=" + mAnimating 1494 + " tok animating=" 1495 + (mAppAnimator != null ? mAppAnimator.animating : false)); 1496 } 1497 1498 mService.enableScreenIfNeededLocked(); 1499 1500 applyEnterAnimationLocked(); 1501 1502 // Force the show in the next prepareSurfaceLocked() call. 1503 mLastAlpha = -1; 1504 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) 1505 Slog.v(TAG, "performShowLocked: mDrawState=HAS_DRAWN in " + this); 1506 mDrawState = HAS_DRAWN; 1507 mService.scheduleAnimationLocked(); 1508 1509 int i = mWin.mChildWindows.size(); 1510 while (i > 0) { 1511 i--; 1512 WindowState c = mWin.mChildWindows.get(i); 1513 if (c.mAttachedHidden) { 1514 c.mAttachedHidden = false; 1515 if (c.mWinAnimator.mSurfaceControl != null) { 1516 c.mWinAnimator.performShowLocked(); 1517 // It hadn't been shown, which means layout not 1518 // performed on it, so now we want to make sure to 1519 // do a layout. If called from within the transaction 1520 // loop, this will cause it to restart with a new 1521 // layout. 1522 final DisplayContent displayContent = c.getDisplayContent(); 1523 if (displayContent != null) { 1524 displayContent.layoutNeeded = true; 1525 } 1526 } 1527 } 1528 } 1529 1530 if (mWin.mAttrs.type != TYPE_APPLICATION_STARTING 1531 && mWin.mAppToken != null) { 1532 mWin.mAppToken.firstWindowDrawn = true; 1533 1534 if (mWin.mAppToken.startingData != null) { 1535 if (WindowManagerService.DEBUG_STARTING_WINDOW || 1536 WindowManagerService.DEBUG_ANIM) Slog.v(TAG, 1537 "Finish starting " + mWin.mToken 1538 + ": first real window is shown, no animation"); 1539 // If this initial window is animating, stop it -- we 1540 // will do an animation to reveal it from behind the 1541 // starting window, so there is no need for it to also 1542 // be doing its own stuff. 1543 clearAnimation(); 1544 mService.mFinishedStarting.add(mWin.mAppToken); 1545 mService.mH.sendEmptyMessage(H.FINISHED_STARTING); 1546 } 1547 mWin.mAppToken.updateReportedVisibilityLocked(); 1548 } 1549 1550 return true; 1551 } 1552 1553 return false; 1554 } 1555 1556 /** 1557 * Have the surface flinger show a surface, robustly dealing with 1558 * error conditions. In particular, if there is not enough memory 1559 * to show the surface, then we will try to get rid of other surfaces 1560 * in order to succeed. 1561 * 1562 * @return Returns true if the surface was successfully shown. 1563 */ 1564 boolean showSurfaceRobustlyLocked() { 1565 try { 1566 if (mSurfaceControl != null) { 1567 mSurfaceShown = true; 1568 mSurfaceControl.show(); 1569 if (mWin.mTurnOnScreen) { 1570 if (DEBUG_VISIBILITY) Slog.v(TAG, 1571 "Show surface turning screen on: " + mWin); 1572 mWin.mTurnOnScreen = false; 1573 mAnimator.mBulkUpdateParams |= SET_TURN_ON_SCREEN; 1574 } 1575 } 1576 return true; 1577 } catch (RuntimeException e) { 1578 Slog.w(TAG, "Failure showing surface " + mSurfaceControl + " in " + mWin, e); 1579 } 1580 1581 mService.reclaimSomeSurfaceMemoryLocked(this, "show", true); 1582 1583 return false; 1584 } 1585 1586 void applyEnterAnimationLocked() { 1587 final int transit; 1588 if (mEnterAnimationPending) { 1589 mEnterAnimationPending = false; 1590 transit = WindowManagerPolicy.TRANSIT_ENTER; 1591 } else { 1592 transit = WindowManagerPolicy.TRANSIT_SHOW; 1593 } 1594 applyAnimationLocked(transit, true); 1595 //TODO (multidisplay): Magnification is supported only for the default display. 1596 if (mService.mDisplayMagnifier != null 1597 && mWin.getDisplayId() == Display.DEFAULT_DISPLAY) { 1598 mService.mDisplayMagnifier.onWindowTransitionLocked(mWin, transit); 1599 } 1600 } 1601 1602 /** 1603 * Choose the correct animation and set it to the passed WindowState. 1604 * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn 1605 * then the animation will be app_starting_exit. Any other value loads the animation from 1606 * the switch statement below. 1607 * @param isEntrance The animation type the last time this was called. Used to keep from 1608 * loading the same animation twice. 1609 * @return true if an animation has been loaded. 1610 */ 1611 boolean applyAnimationLocked(int transit, boolean isEntrance) { 1612 if (mLocalAnimating && mAnimationIsEntrance == isEntrance) { 1613 // If we are trying to apply an animation, but already running 1614 // an animation of the same type, then just leave that one alone. 1615 return true; 1616 } 1617 1618 // Only apply an animation if the display isn't frozen. If it is 1619 // frozen, there is no reason to animate and it can cause strange 1620 // artifacts when we unfreeze the display if some different animation 1621 // is running. 1622 if (mService.okToDisplay()) { 1623 int anim = mPolicy.selectAnimationLw(mWin, transit); 1624 int attr = -1; 1625 Animation a = null; 1626 if (anim != 0) { 1627 a = anim != -1 ? AnimationUtils.loadAnimation(mContext, anim) : null; 1628 } else { 1629 switch (transit) { 1630 case WindowManagerPolicy.TRANSIT_ENTER: 1631 attr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation; 1632 break; 1633 case WindowManagerPolicy.TRANSIT_EXIT: 1634 attr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation; 1635 break; 1636 case WindowManagerPolicy.TRANSIT_SHOW: 1637 attr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation; 1638 break; 1639 case WindowManagerPolicy.TRANSIT_HIDE: 1640 attr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation; 1641 break; 1642 } 1643 if (attr >= 0) { 1644 a = mService.mAppTransition.loadAnimation(mWin.mAttrs, attr); 1645 } 1646 } 1647 if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, 1648 "applyAnimation: win=" + this 1649 + " anim=" + anim + " attr=0x" + Integer.toHexString(attr) 1650 + " a=" + a 1651 + " transit=" + transit 1652 + " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3)); 1653 if (a != null) { 1654 if (WindowManagerService.DEBUG_ANIM) { 1655 RuntimeException e = null; 1656 if (!WindowManagerService.HIDE_STACK_CRAWLS) { 1657 e = new RuntimeException(); 1658 e.fillInStackTrace(); 1659 } 1660 Slog.v(TAG, "Loaded animation " + a + " for " + this, e); 1661 } 1662 setAnimation(a); 1663 mAnimationIsEntrance = isEntrance; 1664 } 1665 } else { 1666 clearAnimation(); 1667 } 1668 1669 return mAnimation != null; 1670 } 1671 1672 public void dump(PrintWriter pw, String prefix, boolean dumpAll) { 1673 if (mAnimating || mLocalAnimating || mAnimationIsEntrance 1674 || mAnimation != null) { 1675 pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); 1676 pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); 1677 pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); 1678 pw.print(" mAnimation="); pw.println(mAnimation); 1679 } 1680 if (mHasTransformation || mHasLocalTransformation) { 1681 pw.print(prefix); pw.print("XForm: has="); 1682 pw.print(mHasTransformation); 1683 pw.print(" hasLocal="); pw.print(mHasLocalTransformation); 1684 pw.print(" "); mTransformation.printShortString(pw); 1685 pw.println(); 1686 } 1687 if (mSurfaceControl != null) { 1688 if (dumpAll) { 1689 pw.print(prefix); pw.print("mSurface="); pw.println(mSurfaceControl); 1690 pw.print(prefix); pw.print("mDrawState="); 1691 pw.print(drawStateToString(mDrawState)); 1692 pw.print(" mLastHidden="); pw.println(mLastHidden); 1693 } 1694 pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); 1695 pw.print(" layer="); pw.print(mSurfaceLayer); 1696 pw.print(" alpha="); pw.print(mSurfaceAlpha); 1697 pw.print(" rect=("); pw.print(mSurfaceX); 1698 pw.print(","); pw.print(mSurfaceY); 1699 pw.print(") "); pw.print(mSurfaceW); 1700 pw.print(" x "); pw.println(mSurfaceH); 1701 } 1702 if (mPendingDestroySurface != null) { 1703 pw.print(prefix); pw.print("mPendingDestroySurface="); 1704 pw.println(mPendingDestroySurface); 1705 } 1706 if (mSurfaceResized || mSurfaceDestroyDeferred) { 1707 pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized); 1708 pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred); 1709 } 1710 if (mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND) { 1711 pw.print(prefix); pw.print("mUniverseTransform="); 1712 mUniverseTransform.printShortString(pw); 1713 pw.println(); 1714 } 1715 if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { 1716 pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); 1717 pw.print(" mAlpha="); pw.print(mAlpha); 1718 pw.print(" mLastAlpha="); pw.println(mLastAlpha); 1719 } 1720 if (mHaveMatrix || mWin.mGlobalScale != 1) { 1721 pw.print(prefix); pw.print("mGlobalScale="); pw.print(mWin.mGlobalScale); 1722 pw.print(" mDsDx="); pw.print(mDsDx); 1723 pw.print(" mDtDx="); pw.print(mDtDx); 1724 pw.print(" mDsDy="); pw.print(mDsDy); 1725 pw.print(" mDtDy="); pw.println(mDtDy); 1726 } 1727 } 1728 1729 @Override 1730 public String toString() { 1731 StringBuffer sb = new StringBuffer("WindowStateAnimator{"); 1732 sb.append(Integer.toHexString(System.identityHashCode(this))); 1733 sb.append(' '); 1734 sb.append(mWin.mAttrs.getTitle()); 1735 sb.append('}'); 1736 return sb.toString(); 1737 } 1738} 1739