Craig Mautner | c2c0a61 | 2014-02-20 20:25:41 -0800 | [diff] [blame] | 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 | */ |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 20 | import static com.android.server.wm.WindowManagerService.DEBUG_ANIM; |
| 21 | import static com.android.server.wm.WindowManagerService.DEBUG_LAYERS; |
| 22 | import static com.android.server.wm.WindowManagerService.DEBUG_ORIENTATION; |
| 23 | import static com.android.server.wm.WindowManagerService.DEBUG_STARTING_WINDOW; |
| 24 | import static com.android.server.wm.WindowManagerService.DEBUG_SURFACE_TRACE; |
| 25 | import static com.android.server.wm.WindowManagerService.SHOW_TRANSACTIONS; |
| 26 | import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY; |
| 27 | import static com.android.server.wm.WindowManagerService.SHOW_LIGHT_TRANSACTIONS; |
| 28 | import static com.android.server.wm.WindowManagerService.SHOW_SURFACE_ALLOC; |
| 29 | import static com.android.server.wm.WindowManagerService.localLOGV; |
Craig Mautner | 2639da5 | 2012-07-09 09:39:06 -0700 | [diff] [blame] | 30 | import static com.android.server.wm.WindowManagerService.LayoutFields.SET_ORIENTATION_CHANGE_COMPLETE; |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 31 | import static com.android.server.wm.WindowManagerService.LayoutFields.SET_TURN_ON_SCREEN; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 32 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 33 | import android.content.Context; |
| 34 | import android.graphics.Matrix; |
| 35 | import android.graphics.PixelFormat; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 36 | import android.graphics.Point; |
| 37 | import android.graphics.PointF; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 38 | import android.graphics.Rect; |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 39 | import android.graphics.RectF; |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 40 | import android.graphics.Region; |
Craig Mautner | a51a956 | 2012-04-17 17:05:26 -0700 | [diff] [blame] | 41 | import android.os.Debug; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 42 | import android.util.Slog; |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 43 | import android.view.Display; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 44 | import android.view.DisplayInfo; |
Svetoslav Ganov | 152e9bb | 2012-10-12 20:15:29 -0700 | [diff] [blame] | 45 | import android.view.MagnificationSpec; |
Igor Murashkin | a86ab640 | 2013-08-30 12:58:36 -0700 | [diff] [blame] | 46 | import android.view.Surface.OutOfResourcesException; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 47 | import android.view.SurfaceControl; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 48 | import android.view.SurfaceSession; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 49 | import android.view.WindowManager; |
| 50 | import android.view.WindowManagerPolicy; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 51 | import android.view.WindowManager.LayoutParams; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 52 | import android.view.animation.Animation; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 53 | import android.view.animation.AnimationUtils; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 54 | import android.view.animation.Transformation; |
| 55 | |
| 56 | import com.android.server.wm.WindowManagerService.H; |
| 57 | |
| 58 | import java.io.PrintWriter; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 59 | import java.util.ArrayList; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 60 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 61 | class WinAnimatorList extends ArrayList<WindowStateAnimator> { |
| 62 | } |
| 63 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 64 | /** |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 65 | * Keep track of animations and surface operations for a single WindowState. |
| 66 | **/ |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 67 | class WindowStateAnimator { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 68 | static final String TAG = "WindowStateAnimator"; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 69 | |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 70 | // Unchanging local convenience fields. |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 71 | final WindowManagerService mService; |
| 72 | final WindowState mWin; |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 73 | final WindowStateAnimator mAttachedWinAnimator; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 74 | final WindowAnimator mAnimator; |
Craig Mautner | 8863cca | 2012-09-18 15:04:34 -0700 | [diff] [blame] | 75 | AppWindowAnimator mAppAnimator; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 76 | final Session mSession; |
| 77 | final WindowManagerPolicy mPolicy; |
| 78 | final Context mContext; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 79 | final boolean mIsWallpaper; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 80 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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? |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 94 | int mAnimLayer; |
| 95 | int mLastLayer; |
| 96 | |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 97 | SurfaceControl mSurfaceControl; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 98 | SurfaceControl mPendingDestroySurface; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 112 | float mShownAlpha = 0; |
| 113 | float mAlpha = 0; |
| 114 | float mLastAlpha = 0; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 115 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 116 | boolean mHasClipRect; |
| 117 | Rect mClipRect = new Rect(); |
| 118 | Rect mTmpClipRect = new Rect(); |
| 119 | Rect mLastClipRect = new Rect(); |
| 120 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 139 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 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; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 164 | int mDrawState; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 165 | |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 166 | /** Was this window last hidden? */ |
| 167 | boolean mLastHidden; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 168 | |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 169 | int mAttrFlags; |
| 170 | int mAttrType; |
| 171 | |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 172 | public WindowStateAnimator(final WindowState win) { |
| 173 | final WindowManagerService service = win.mService; |
| 174 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 175 | mService = service; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 176 | mAnimator = service.mAnimator; |
| 177 | mPolicy = service.mPolicy; |
| 178 | mContext = service.mContext; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 179 | final DisplayInfo displayInfo = win.getDisplayContent().getDisplayInfo(); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 180 | mAnimDw = displayInfo.appWidth; |
| 181 | mAnimDh = displayInfo.appHeight; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 182 | |
| 183 | mWin = win; |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 184 | mAttachedWinAnimator = win.mAttachedWindow == null |
| 185 | ? null : win.mAttachedWindow.mWinAnimator; |
| 186 | mAppAnimator = win.mAppToken == null ? null : win.mAppToken.mAppAnimator; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 187 | mSession = win.mSession; |
| 188 | mAttrFlags = win.mAttrs.flags; |
| 189 | mAttrType = win.mAttrs.type; |
| 190 | mIsWallpaper = win.mIsWallpaper; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | public void setAnimation(Animation anim) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 194 | if (localLOGV) Slog.v(TAG, "Setting animation in " + this + ": " + anim); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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(); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 202 | mTransformation.setAlpha(mLastHidden ? 0 : 1); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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() { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 217 | return mAnimation != null |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 218 | || (mAttachedWinAnimator != null && mAttachedWinAnimator.mAnimation != null) |
| 219 | || (mAppAnimator != null && |
| 220 | (mAppAnimator.animation != null |
| 221 | || mAppAnimator.mAppToken.inPendingTransaction)); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 224 | /** Is the window animating the DummyAnimation? */ |
| 225 | boolean isDummyAnimation() { |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 226 | return mAppAnimator != null |
| 227 | && mAppAnimator.animation == AppWindowAnimator.sDummyAnimation; |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 230 | /** Is this window currently animating? */ |
| 231 | boolean isWindowAnimating() { |
| 232 | return mAnimation != null; |
| 233 | } |
| 234 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 235 | void cancelExitAnimationForNextAnimationLocked() { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 236 | if (mAnimation != null) { |
| 237 | mAnimation.cancel(); |
| 238 | mAnimation = null; |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 239 | mLocalAnimating = false; |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 240 | destroySurfaceLocked(); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 241 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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); |
Craig Mautner | 9e80944 | 2012-06-22 17:13:04 -0700 | [diff] [blame] | 250 | if (false && DEBUG_ANIM) Slog.v( |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 251 | TAG, "Stepped animation in " + this + |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 262 | final DisplayContent displayContent = mWin.getDisplayContent(); |
| 263 | if (displayContent != null && mService.okToDisplay()) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 270 | if (DEBUG_ANIM) Slog.v( |
| 271 | TAG, "Starting animation in " + this + |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 272 | " @ " + currentTime + ": ww=" + mWin.mFrame.width() + |
| 273 | " wh=" + mWin.mFrame.height() + |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 274 | " dw=" + mAnimDw + " dh=" + mAnimDh + |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 275 | " scale=" + mService.mWindowAnimationScale); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 276 | mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), |
| 277 | mAnimDw, mAnimDh); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 278 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 279 | mAnimDw = displayInfo.appWidth; |
| 280 | mAnimDh = displayInfo.appHeight; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 290 | if (DEBUG_ANIM) Slog.v( |
| 291 | TAG, "Finished animation in " + this + |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 292 | " @ " + currentTime); |
| 293 | //WindowManagerService.this.dump(); |
| 294 | } |
| 295 | mHasLocalTransformation = false; |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 296 | if ((!mLocalAnimating || mAnimationIsEntrance) && mAppAnimator != null |
| 297 | && mAppAnimator.animation != null) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | if (!mAnimating && !mLocalAnimating) { |
| 323 | return false; |
| 324 | } |
| 325 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 326 | // Done animating, clean up. |
| 327 | if (DEBUG_ANIM) Slog.v( |
| 328 | TAG, "Animation done in " + this + ": exiting=" + mWin.mExiting |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 338 | if (mAnimator.mWindowDetachedWallpaper == mWin) { |
| 339 | mAnimator.mWindowDetachedWallpaper = null; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 340 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 341 | mAnimLayer = mWin.mLayer; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 342 | if (mWin.mIsImWindow) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 343 | mAnimLayer += mService.mInputMethodAnimLayerAdjustment; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 344 | } else if (mIsWallpaper) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 345 | mAnimLayer += mService.mWallpaperAnimLayerAdjustment; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 346 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 347 | if (DEBUG_LAYERS) Slog.v(TAG, "Stepping win " + this |
| 348 | + " anim layer: " + mAnimLayer); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 349 | mHasTransformation = false; |
| 350 | mHasLocalTransformation = false; |
| 351 | if (mWin.mPolicyVisibility != mWin.mPolicyVisibilityAfterAnim) { |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 352 | if (DEBUG_VISIBILITY) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 353 | Slog.v(TAG, "Policy visibility changing after anim in " + this + ": " |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 354 | + mWin.mPolicyVisibilityAfterAnim); |
| 355 | } |
| 356 | mWin.mPolicyVisibility = mWin.mPolicyVisibilityAfterAnim; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 357 | if (displayContent != null) { |
| 358 | displayContent.layoutNeeded = true; |
| 359 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 360 | if (!mWin.mPolicyVisibility) { |
| 361 | if (mService.mCurrentFocus == mWin) { |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 362 | if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, |
| 363 | "setAnimationLocked: setting mFocusMayChange true"); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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(); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 373 | if (mDrawState == HAS_DRAWN |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 374 | && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING |
| 375 | && mWin.mAppToken != null |
| 376 | && mWin.mAppToken.firstWindowDrawn |
| 377 | && mWin.mAppToken.startingData != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 378 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Finish starting " |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 379 | + mWin.mToken + ": first real window done animating"); |
| 380 | mService.mFinishedStarting.add(mWin.mAppToken); |
| 381 | mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 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. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 385 | if (displayContent != null) { |
| 386 | displayContent.layoutNeeded = true; |
| 387 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | finishExit(); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 391 | final int displayId = mWin.getDisplayId(); |
Craig Mautner | 76a7165 | 2012-09-03 23:23:58 -0700 | [diff] [blame] | 392 | mAnimator.setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM); |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 393 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) mService.debugLayoutRepeats( |
Craig Mautner | 66f78d7 | 2012-12-04 16:46:50 -0800 | [diff] [blame] | 394 | "WindowStateAnimator", mAnimator.getPendingLayoutChanges(displayId)); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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( |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 405 | TAG, "finishExit in " + this |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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( |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 424 | TAG, "Exit animation finished in " + this |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 425 | + ": remove=" + mWin.mRemoveOnExit); |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 426 | if (mSurfaceControl != null) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 427 | mService.mDestroySurface.add(mWin); |
| 428 | mWin.mDestroying = true; |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 429 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface( |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 430 | mWin, "HIDE (finishExit)", null); |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 431 | hide(); |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 432 | } |
| 433 | mWin.mExiting = false; |
| 434 | if (mWin.mRemoveOnExit) { |
| 435 | mService.mPendingRemove.add(mWin); |
| 436 | mWin.mRemoveOnExit = false; |
| 437 | } |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 438 | mAnimator.hideWallpapersLocked(mWin); |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 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); |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 447 | if (mSurfaceControl != null) { |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 448 | mSurfaceShown = false; |
| 449 | try { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 450 | mSurfaceControl.hide(); |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 451 | } catch (RuntimeException e) { |
| 452 | Slog.w(TAG, "Exception hiding surface in " + mWin); |
| 453 | } |
| 454 | } |
| 455 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 458 | boolean finishDrawingLocked() { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 464 | if (mDrawState == DRAW_PENDING) { |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 465 | if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) |
| 466 | Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in " |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 467 | + mSurfaceControl); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 472 | mDrawState = COMMIT_DRAW_PENDING; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 473 | return true; |
| 474 | } |
| 475 | return false; |
| 476 | } |
| 477 | |
| 478 | // This must be called while inside a transaction. |
| 479 | boolean commitFinishDrawingLocked(long currentTime) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 485 | if (mDrawState != COMMIT_DRAW_PENDING) { |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 486 | return false; |
| 487 | } |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 488 | if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 489 | Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurfaceControl); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 490 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 491 | mDrawState = READY_TO_SHOW; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 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 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 500 | static class SurfaceTrace extends SurfaceControl { |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 501 | private final static String SURFACE_TAG = "SurfaceTrace"; |
| 502 | final static ArrayList<SurfaceTrace> sSurfaces = new ArrayList<SurfaceTrace>(); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 503 | |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 504 | private float mSurfaceTraceAlpha = 0; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 505 | private int mLayer; |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 506 | private final PointF mPosition = new PointF(); |
| 507 | private final Point mSize = new Point(); |
| 508 | private final Rect mWindowCrop = new Rect(); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 509 | private boolean mShown = false; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 510 | private int mLayerStack; |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 511 | private boolean mIsOpaque; |
Igor Murashkin | a86ab640 | 2013-08-30 12:58:36 -0700 | [diff] [blame] | 512 | private final String mName; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 513 | |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 514 | public SurfaceTrace(SurfaceSession s, |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 515 | String name, int w, int h, int format, int flags) |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 516 | throws OutOfResourcesException { |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 517 | super(s, name, w, h, format, flags); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 518 | mName = name != null ? name : "Not named"; |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 519 | mSize.set(w, h); |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 520 | Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by " |
Craig Mautner | a51a956 | 2012-04-17 17:05:26 -0700 | [diff] [blame] | 521 | + Debug.getCallers(3)); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | @Override |
| 525 | public void setAlpha(float alpha) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 526 | if (mSurfaceTraceAlpha != alpha) { |
| 527 | Slog.v(SURFACE_TAG, "setAlpha(" + alpha + "): OLD:" + this + ". Called by " |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 528 | + Debug.getCallers(3)); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 529 | mSurfaceTraceAlpha = alpha; |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 530 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 531 | super.setAlpha(alpha); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | @Override |
| 535 | public void setLayer(int zorder) { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 536 | if (zorder != mLayer) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 537 | Slog.v(SURFACE_TAG, "setLayer(" + zorder + "): OLD:" + this + ". Called by " |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 538 | + Debug.getCallers(3)); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 539 | mLayer = zorder; |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 540 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 541 | super.setLayer(zorder); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 542 | |
| 543 | sSurfaces.remove(this); |
| 544 | int i; |
| 545 | for (i = sSurfaces.size() - 1; i >= 0; i--) { |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 546 | SurfaceTrace s = sSurfaces.get(i); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 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) { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 556 | if (x != mPosition.x || y != mPosition.y) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 557 | Slog.v(SURFACE_TAG, "setPosition(" + x + "," + y + "): OLD:" + this |
| 558 | + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 66d7730 | 2013-04-10 15:33:26 -0700 | [diff] [blame] | 559 | mPosition.set(x, y); |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 560 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 561 | super.setPosition(x, y); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | @Override |
| 565 | public void setSize(int w, int h) { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 566 | if (w != mSize.x || h != mSize.y) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 567 | Slog.v(SURFACE_TAG, "setSize(" + w + "," + h + "): OLD:" + this + ". Called by " |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 568 | + Debug.getCallers(3)); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 569 | mSize.set(w, h); |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 570 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 571 | super.setSize(w, h); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | @Override |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 575 | public void setWindowCrop(Rect crop) { |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 576 | if (crop != null) { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 577 | if (!crop.equals(mWindowCrop)) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 578 | Slog.v(SURFACE_TAG, "setWindowCrop(" + crop.toShortString() + "): OLD:" + this |
| 579 | + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 66d7730 | 2013-04-10 15:33:26 -0700 | [diff] [blame] | 580 | mWindowCrop.set(crop); |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 581 | } |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 582 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 583 | super.setWindowCrop(crop); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | @Override |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 587 | public void setLayerStack(int layerStack) { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 588 | if (layerStack != mLayerStack) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 589 | Slog.v(SURFACE_TAG, "setLayerStack(" + layerStack + "): OLD:" + this |
| 590 | + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 66d7730 | 2013-04-10 15:33:26 -0700 | [diff] [blame] | 591 | mLayerStack = layerStack; |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 592 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 593 | super.setLayerStack(layerStack); |
Craig Mautner | 9de4936 | 2012-08-02 14:30:30 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | @Override |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 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 |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 607 | public void hide() { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 608 | if (mShown) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 609 | Slog.v(SURFACE_TAG, "hide: OLD:" + this + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 66d7730 | 2013-04-10 15:33:26 -0700 | [diff] [blame] | 610 | mShown = false; |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 611 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 612 | super.hide(); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 613 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 614 | |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 615 | @Override |
| 616 | public void show() { |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 617 | if (!mShown) { |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 618 | Slog.v(SURFACE_TAG, "show: OLD:" + this + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 66d7730 | 2013-04-10 15:33:26 -0700 | [diff] [blame] | 619 | mShown = true; |
Dianne Hackborn | 9812973 | 2012-11-01 16:28:16 -0700 | [diff] [blame] | 620 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 621 | super.show(); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | @Override |
| 625 | public void destroy() { |
| 626 | super.destroy(); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 627 | Slog.v(SURFACE_TAG, "destroy: " + this + ". Called by " + Debug.getCallers(3)); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 628 | sSurfaces.remove(this); |
| 629 | } |
| 630 | |
Craig Mautner | acaf9cc | 2012-04-17 11:45:25 -0700 | [diff] [blame] | 631 | @Override |
| 632 | public void release() { |
| 633 | super.release(); |
| 634 | Slog.v(SURFACE_TAG, "release: " + this + ". Called by " |
Craig Mautner | a51a956 | 2012-04-17 17:05:26 -0700 | [diff] [blame] | 635 | + Debug.getCallers(3)); |
Craig Mautner | acaf9cc | 2012-04-17 11:45:25 -0700 | [diff] [blame] | 636 | sSurfaces.remove(this); |
| 637 | } |
| 638 | |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 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() { |
Craig Mautner | fbf378c | 2012-04-23 17:24:21 -0700 | [diff] [blame] | 648 | return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " " |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 649 | + mName + " (" + mLayerStack + "): shown=" + mShown + " layer=" + mLayer |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 650 | + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 651 | + " " + mSize.x + "x" + mSize.y |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 652 | + " crop=" + mWindowCrop.toShortString() |
| 653 | + " opaque=" + mIsOpaque; |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 654 | } |
| 655 | } |
| 656 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 657 | SurfaceControl createSurfaceLocked() { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 658 | if (mSurfaceControl == null) { |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 659 | if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG, |
| 660 | "createSurface " + this + ": mDrawState=DRAW_PENDING"); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 661 | mDrawState = DRAW_PENDING; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 662 | if (mWin.mAppToken != null) { |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | mService.makeWindowFreezingScreenIfNeededLocked(mWin); |
| 674 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 675 | int flags = SurfaceControl.HIDDEN; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 676 | final WindowManager.LayoutParams attrs = mWin.mAttrs; |
| 677 | |
| 678 | if ((attrs.flags&WindowManager.LayoutParams.FLAG_SECURE) != 0) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 679 | flags |= SurfaceControl.SECURE; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 680 | } |
Craig Mautner | b3b36ba | 2013-05-20 13:21:10 -0700 | [diff] [blame] | 681 | if (DEBUG_VISIBILITY) Slog.v( |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 704 | mSurfaceAlpha = 0; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 705 | mSurfaceX = 0; |
| 706 | mSurfaceY = 0; |
| 707 | mSurfaceW = w; |
| 708 | mSurfaceH = h; |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 709 | mWin.mLastSystemDecorRect.set(0, 0, 0, 0); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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)) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 715 | flags |= SurfaceControl.OPAQUE; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 716 | } |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 717 | if (DEBUG_SURFACE_TRACE) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 718 | mSurfaceControl = new SurfaceTrace( |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 719 | mSession.mSurfaceSession, |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 720 | attrs.getTitle().toString(), |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 721 | w, h, format, flags); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 722 | } else { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 723 | mSurfaceControl = new SurfaceControl( |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 724 | mSession.mSurfaceSession, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 725 | attrs.getTitle().toString(), |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 726 | w, h, format, flags); |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 727 | } |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 728 | mWin.mHasSurface = true; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 729 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG, |
| 730 | " CREATE SURFACE " |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 731 | + mSurfaceControl + " IN SESSION " |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 732 | + mSession.mSurfaceSession |
| 733 | + ": pid=" + mSession.mPid + " format=" |
| 734 | + attrs.format + " flags=0x" |
| 735 | + Integer.toHexString(flags) |
| 736 | + " / " + this); |
Igor Murashkin | a86ab640 | 2013-08-30 12:58:36 -0700 | [diff] [blame] | 737 | } catch (OutOfResourcesException e) { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 738 | mWin.mHasSurface = false; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 739 | Slog.w(TAG, "OutOfResourcesException creating surface"); |
| 740 | mService.reclaimSomeSurfaceMemoryLocked(this, "create", true); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 741 | mDrawState = NO_SURFACE; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 742 | return null; |
| 743 | } catch (Exception e) { |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 744 | mWin.mHasSurface = false; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 745 | Slog.e(TAG, "Exception creating surface", e); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 746 | mDrawState = NO_SURFACE; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 747 | return null; |
| 748 | } |
| 749 | |
| 750 | if (WindowManagerService.localLOGV) Slog.v( |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 751 | TAG, "Got surface: " + mSurfaceControl |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 761 | SurfaceControl.openTransaction(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 762 | try { |
| 763 | try { |
| 764 | mSurfaceX = mWin.mFrame.left + mWin.mXOffset; |
| 765 | mSurfaceY = mWin.mFrame.top + mWin.mYOffset; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 766 | mSurfaceControl.setPosition(mSurfaceX, mSurfaceY); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 767 | mSurfaceLayer = mAnimLayer; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 768 | final DisplayContent displayContent = mWin.getDisplayContent(); |
| 769 | if (displayContent != null) { |
| 770 | mSurfaceControl.setLayerStack(displayContent.getDisplay().getLayerStack()); |
| 771 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 772 | mSurfaceControl.setLayer(mAnimLayer); |
| 773 | mSurfaceControl.setAlpha(0); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 774 | mSurfaceShown = false; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 775 | } catch (RuntimeException e) { |
| 776 | Slog.w(TAG, "Error creating surface in " + w, e); |
| 777 | mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true); |
| 778 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 779 | mLastHidden = true; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 780 | } finally { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 781 | SurfaceControl.closeTransaction(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 788 | return mSurfaceControl; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 789 | } |
| 790 | |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 791 | void destroySurfaceLocked() { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 792 | if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) { |
| 793 | mWin.mAppToken.startingDisplayed = false; |
| 794 | } |
| 795 | |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 796 | if (mSurfaceControl != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 " |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 813 | + mSurfaceControl + ", session " + mSession, e); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 814 | } |
| 815 | if (mSurfaceDestroyDeferred) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 816 | if (mSurfaceControl != null && mPendingDestroySurface != mSurfaceControl) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 828 | mPendingDestroySurface = mSurfaceControl; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 839 | mSurfaceControl.destroy(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 840 | } |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 841 | mAnimator.hideWallpapersLocked(mWin); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 842 | } catch (RuntimeException e) { |
| 843 | Slog.w(TAG, "Exception thrown when destroying Window " + this |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 844 | + " surface " + mSurfaceControl + " session " + mSession |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 845 | + ": " + e.toString()); |
| 846 | } |
| 847 | |
| 848 | mSurfaceShown = false; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 849 | mSurfaceControl = null; |
Craig Mautner | e855214 | 2012-11-07 13:55:47 -0800 | [diff] [blame] | 850 | mWin.mHasSurface = false; |
Craig Mautner | bf08af3 | 2012-05-16 19:43:42 -0700 | [diff] [blame] | 851 | mDrawState = NO_SURFACE; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 855 | void destroyDeferredSurfaceLocked() { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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(); |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 867 | mAnimator.hideWallpapersLocked(mWin); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 868 | } |
| 869 | } catch (RuntimeException e) { |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 870 | Slog.w(TAG, "Exception thrown when destroying Window " |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 = |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 881 | (mAttachedWinAnimator != null && mAttachedWinAnimator.mHasLocalTransformation) |
| 882 | ? mAttachedWinAnimator.mTransformation : null; |
| 883 | Transformation appTransformation = (mAppAnimator != null && mAppAnimator.hasTransformation) |
| 884 | ? mAppAnimator.transformation : null; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 885 | |
| 886 | // Wallpapers are animated based on the "real" window they |
| 887 | // are currently targeting. |
Craig Mautner | 798adef | 2013-10-22 14:29:01 -0700 | [diff] [blame] | 888 | final WindowState wallpaperTarget = mService.mWallpaperTarget; |
| 889 | if (mIsWallpaper && wallpaperTarget != null && mService.mAnimateWallpaperWithTarget) { |
| 890 | final WindowStateAnimator wallpaperAnimator = wallpaperTarget.mWinAnimator; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 891 | if (wallpaperAnimator.mHasLocalTransformation && |
| 892 | wallpaperAnimator.mAnimation != null && |
| 893 | !wallpaperAnimator.mAnimation.getDetachWallpaper()) { |
| 894 | attachedTransformation = wallpaperAnimator.mTransformation; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 895 | if (WindowManagerService.DEBUG_WALLPAPER && attachedTransformation != null) { |
| 896 | Slog.v(TAG, "WP target attached xform: " + attachedTransformation); |
| 897 | } |
| 898 | } |
Craig Mautner | 798adef | 2013-10-22 14:29:01 -0700 | [diff] [blame] | 899 | final AppWindowAnimator wpAppAnimator = wallpaperTarget.mAppToken == null ? |
| 900 | null : wallpaperTarget.mAppToken.mAppAnimator; |
| 901 | if (wpAppAnimator != null && wpAppAnimator.hasTransformation |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 902 | && wpAppAnimator.animation != null |
| 903 | && !wpAppAnimator.animation.getDetachWallpaper()) { |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 904 | appTransformation = wpAppAnimator.transformation; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 905 | if (WindowManagerService.DEBUG_WALLPAPER && appTransformation != null) { |
| 906 | Slog.v(TAG, "WP target app xform: " + appTransformation); |
| 907 | } |
| 908 | } |
| 909 | } |
| 910 | |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 911 | final int displayId = mWin.getDisplayId(); |
| 912 | final ScreenRotationAnimation screenRotationAnimation = |
| 913 | mAnimator.getScreenRotationAnimationLocked(displayId); |
| 914 | final boolean screenAnimation = |
| 915 | screenRotationAnimation != null && screenRotationAnimation.isAnimating(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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. |
Dianne Hackborn | 4b16969 | 2012-11-29 17:51:24 -0800 | [diff] [blame] | 924 | if (screenAnimation && screenRotationAnimation.isRotating()) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 953 | if (mAnimator.mUniverseBackground != null) { |
| 954 | tmpMatrix.postConcat(mAnimator.mUniverseBackground.mUniverseTransform.getMatrix()); |
| 955 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 956 | if (screenAnimation) { |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 957 | tmpMatrix.postConcat(screenRotationAnimation.getEnterTransformation().getMatrix()); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 958 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 959 | |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 960 | //TODO (multidisplay): Magnification is supported only for the default display. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 961 | if (mService.mDisplayMagnifier != null && displayId == Display.DEFAULT_DISPLAY) { |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 962 | MagnificationSpec spec = mService.mDisplayMagnifier |
| 963 | .getMagnificationSpecForWindowLocked(mWin); |
Svetoslav Ganov | 152e9bb | 2012-10-12 20:15:29 -0700 | [diff] [blame] | 964 | if (spec != null && !spec.isNop()) { |
| 965 | tmpMatrix.postScale(spec.scale, spec.scale); |
| 966 | tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); |
| 967 | } |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 968 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 994 | mHasClipRect = false; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1008 | if (appTransformation.hasClipRect()) { |
| 1009 | mClipRect.set(appTransformation.getClipRect()); |
| 1010 | mHasClipRect = true; |
| 1011 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1012 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1013 | if (mAnimator.mUniverseBackground != null) { |
| 1014 | mShownAlpha *= mAnimator.mUniverseBackground.mUniverseTransform.getAlpha(); |
| 1015 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1016 | if (screenAnimation) { |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 1017 | mShownAlpha *= screenRotationAnimation.getEnterTransformation().getAlpha(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1018 | } |
| 1019 | } else { |
| 1020 | //Slog.i(TAG, "Not applying alpha transform"); |
| 1021 | } |
| 1022 | |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 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")); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1032 | return; |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1033 | } else if (mIsWallpaper && mService.mInnerFields.mWallpaperActionPending) { |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1034 | return; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | if (WindowManagerService.localLOGV) Slog.v( |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1038 | TAG, "computeShownFrameLocked: " + this + |
| 1039 | " not attached, mAlpha=" + mAlpha); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1040 | |
| 1041 | final boolean applyUniverseTransformation = (mAnimator.mUniverseBackground != null |
| 1042 | && mWin.mAttrs.type != WindowManager.LayoutParams.TYPE_UNIVERSE_BACKGROUND |
| 1043 | && mWin.mBaseLayer < mAnimator.mAboveUniverseLayer); |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1044 | MagnificationSpec spec = null; |
| 1045 | //TODO (multidisplay): Magnification is supported only for the default display. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1046 | if (mService.mDisplayMagnifier != null && displayId == Display.DEFAULT_DISPLAY) { |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1047 | spec = mService.mDisplayMagnifier.getMagnificationSpecForWindowLocked(mWin); |
| 1048 | } |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1049 | if (applyUniverseTransformation || spec != null) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1050 | final Rect frame = mWin.mFrame; |
| 1051 | final float tmpFloats[] = mService.mTmpFloats; |
| 1052 | final Matrix tmpMatrix = mWin.mTmpMatrix; |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1053 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1054 | tmpMatrix.setScale(mWin.mGlobalScale, mWin.mGlobalScale); |
| 1055 | tmpMatrix.postTranslate(frame.left + mWin.mXOffset, frame.top + mWin.mYOffset); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1056 | |
| 1057 | if (applyUniverseTransformation) { |
| 1058 | tmpMatrix.postConcat(mAnimator.mUniverseBackground.mUniverseTransform.getMatrix()); |
| 1059 | } |
| 1060 | |
| 1061 | if (spec != null && !spec.isNop()) { |
Svetoslav Ganov | 152e9bb | 2012-10-12 20:15:29 -0700 | [diff] [blame] | 1062 | tmpMatrix.postScale(spec.scale, spec.scale); |
| 1063 | tmpMatrix.postTranslate(spec.offsetX, spec.offsetY); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1064 | } |
| 1065 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1066 | tmpMatrix.getValues(tmpFloats); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1067 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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(); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1077 | mWin.mShownFrame.set(x, y, x + w, y + h); |
| 1078 | |
| 1079 | mShownAlpha = mAlpha; |
| 1080 | if (applyUniverseTransformation) { |
| 1081 | mShownAlpha *= mAnimator.mUniverseBackground.mUniverseTransform.getAlpha(); |
| 1082 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1094 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1120 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1121 | |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1122 | void updateSurfaceWindowCrop(final boolean recoveringMemory) { |
| 1123 | final WindowState w = mWin; |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1124 | final DisplayContent displayContent = w.getDisplayContent(); |
| 1125 | if (displayContent == null) { |
| 1126 | return; |
| 1127 | } |
| 1128 | DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 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); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1135 | } else if (!w.isDefaultDisplay()) { |
Jeff Brown | 28e0b09 | 2012-09-25 11:31:28 -0700 | [diff] [blame] | 1136 | // On a different display there is no system decor. Crop the window |
| 1137 | // by the screen boundaries. |
Jeff Brown | 3671410 | 2012-09-24 17:36:06 -0700 | [diff] [blame] | 1138 | w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height()); |
Jeff Brown | 28e0b09 | 2012-09-25 11:31:28 -0700 | [diff] [blame] | 1139 | w.mSystemDecorRect.intersect(-w.mCompatFrame.left, -w.mCompatFrame.top, |
| 1140 | displayInfo.logicalWidth - w.mCompatFrame.left, |
| 1141 | displayInfo.logicalHeight - w.mCompatFrame.top); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1142 | } else if (w.mLayer >= mService.mSystemDecorLayer) { |
| 1143 | // Above the decor layer is easy, just use the entire window. |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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 | } |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 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. |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1156 | w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), |
| 1157 | w.mCompatFrame.height()); |
| 1158 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 1159 | // Crop to the system decor specified by policy. |
| 1160 | applyDecorRect(w.mDecorFrame); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 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 |
Winson Chung | 96d970c | 2014-03-20 18:04:46 -0700 | [diff] [blame^] | 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); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 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); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1182 | try { |
| 1183 | if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1184 | "CROP " + clipRect.toShortString(), null); |
| 1185 | mSurfaceControl.setWindowCrop(clipRect); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1186 | } catch (RuntimeException e) { |
| 1187 | Slog.w(TAG, "Error setting crop surface of " + w |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1188 | + " crop=" + clipRect.toShortString(), e); |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1189 | if (!recoveringMemory) { |
| 1190 | mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true); |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 1196 | void setSurfaceBoundariesLocked(final boolean recoveringMemory) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1197 | final WindowState w = mWin; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1221 | final float left = w.mShownFrame.left; |
| 1222 | final float top = w.mShownFrame.top; |
| 1223 | if (mSurfaceX != left || mSurfaceY != top) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1224 | try { |
| 1225 | if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w, |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1226 | "POS " + left + ", " + top, null); |
| 1227 | mSurfaceX = left; |
| 1228 | mSurfaceY = top; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1229 | mSurfaceControl.setPosition(left, top); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1230 | } catch (RuntimeException e) { |
| 1231 | Slog.w(TAG, "Error positioning surface of " + w |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1232 | + " pos=(" + left |
| 1233 | + "," + top + ")", e); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1245 | mSurfaceControl.setSize(width, height); |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1246 | mAnimator.setPendingLayoutChanges(w.getDisplayId(), |
Craig Mautner | 76a7165 | 2012-09-03 23:23:58 -0700 | [diff] [blame] | 1247 | WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER); |
Craig Mautner | 3a67f35 | 2012-05-07 11:21:33 -0700 | [diff] [blame] | 1248 | if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) { |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1249 | w.getStack().startDimmingIfNeeded(this); |
Craig Mautner | 3a67f35 | 2012-05-07 11:21:33 -0700 | [diff] [blame] | 1250 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1262 | |
Dianne Hackborn | 3e52fc2 | 2012-05-15 17:58:02 -0700 | [diff] [blame] | 1263 | updateSurfaceWindowCrop(recoveringMemory); |
Craig Mautner | acaf9cc | 2012-04-17 11:45:25 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | public void prepareSurfaceLocked(final boolean recoveringMemory) { |
| 1267 | final WindowState w = mWin; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1268 | if (mSurfaceControl == null) { |
Craig Mautner | acaf9cc | 2012-04-17 11:45:25 -0700 | [diff] [blame] | 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 | |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 1282 | setSurfaceBoundariesLocked(recoveringMemory); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1283 | |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 1284 | if (mIsWallpaper && !mWin.mWallpaperVisible) { |
Craig Mautner | 0fa77c1 | 2012-06-11 15:57:19 -0700 | [diff] [blame] | 1285 | // Wallpaper is no longer visible and there is no wp target => hide it. |
| 1286 | hide(); |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 1287 | } else if (w.mAttachedHidden || !w.isOnScreen()) { |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 1288 | hide(); |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1289 | mAnimator.hideWallpapersLocked(w); |
Craig Mautner | b9836b9 | 2012-06-11 11:40:09 -0700 | [diff] [blame] | 1290 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1299 | if (DEBUG_ORIENTATION) Slog.v(TAG, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1310 | || mLastHidden) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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); |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1326 | if (mSurfaceControl != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1327 | try { |
| 1328 | mSurfaceAlpha = mShownAlpha; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1329 | mSurfaceControl.setAlpha(mShownAlpha); |
Craig Mautner | ad5725d | 2012-06-05 10:20:56 -0700 | [diff] [blame] | 1330 | mSurfaceLayer = mAnimLayer; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1331 | mSurfaceControl.setLayer(mAnimLayer); |
| 1332 | mSurfaceControl.setMatrix( |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1333 | mDsDx * w.mHScale, mDtDx * w.mVScale, |
| 1334 | mDsDy * w.mHScale, mDtDy * w.mVScale); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 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; |
Craig Mautner | 918b53b | 2012-07-09 14:15:54 -0700 | [diff] [blame] | 1343 | if (mIsWallpaper) { |
Craig Mautner | 507a2ee | 2012-06-13 08:39:38 -0700 | [diff] [blame] | 1344 | mService.dispatchWallpaperVisibility(w, true); |
| 1345 | } |
Craig Mautner | 8efb0a4 | 2013-08-08 14:59:00 -0700 | [diff] [blame] | 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); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1351 | } else { |
| 1352 | w.mOrientationChanging = false; |
| 1353 | } |
| 1354 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1355 | if (mSurfaceControl != null) { |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1356 | w.mToken.hasVisible = true; |
| 1357 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1365 | } else { |
Craig Mautner | 9e80944 | 2012-06-22 17:13:04 -0700 | [diff] [blame] | 1366 | if (DEBUG_ANIM && isAnimating()) { |
| 1367 | Slog.v(TAG, "prepareSurface: No changes in animation for " + this); |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 1368 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1369 | displayed = true; |
| 1370 | } |
| 1371 | |
| 1372 | if (displayed) { |
| 1373 | if (w.mOrientationChanging) { |
| 1374 | if (!w.isDrawnLw()) { |
Craig Mautner | 2639da5 | 2012-07-09 09:39:06 -0700 | [diff] [blame] | 1375 | mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE; |
Dianne Hackborn | a57c695 | 2013-03-29 14:46:40 -0700 | [diff] [blame] | 1376 | mAnimator.mLastWindowFreezeSource = w; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1377 | if (DEBUG_ORIENTATION) Slog.v(TAG, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1378 | "Orientation continue waiting for draw in " + w); |
| 1379 | } else { |
| 1380 | w.mOrientationChanging = false; |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1381 | if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1382 | } |
| 1383 | } |
| 1384 | w.mToken.hasVisible = true; |
| 1385 | } |
| 1386 | } |
| 1387 | |
Craig Mautner | ef65501 | 2013-01-03 11:20:24 -0800 | [diff] [blame] | 1388 | void setTransparentRegionHintLocked(final Region region) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1389 | if (mSurfaceControl == null) { |
Craig Mautner | 1f4e0cc | 2012-04-10 14:24:38 -0700 | [diff] [blame] | 1390 | Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true"); |
| 1391 | return; |
| 1392 | } |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 1393 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setTransparentRegion"); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1394 | SurfaceControl.openTransaction(); |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 1395 | try { |
| 1396 | if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, |
| 1397 | "transparentRegionHint=" + region, null); |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1398 | mSurfaceControl.setTransparentRegionHint(region); |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 1399 | } finally { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1400 | SurfaceControl.closeTransaction(); |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 1401 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 1402 | "<<< CLOSE TRANSACTION setTransparentRegion"); |
| 1403 | } |
| 1404 | } |
| 1405 | |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 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 | } |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 1419 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setWallpaperOffset"); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1420 | SurfaceControl.openTransaction(); |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 1421 | try { |
| 1422 | if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin, |
| 1423 | "POS " + left + ", " + top, null); |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1424 | mSurfaceControl.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top); |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 1425 | updateSurfaceWindowCrop(false); |
| 1426 | } catch (RuntimeException e) { |
| 1427 | Slog.w(TAG, "Error positioning surface of " + mWin |
| 1428 | + " pos=(" + left + "," + top + ")", e); |
| 1429 | } finally { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1430 | SurfaceControl.closeTransaction(); |
Craig Mautner | 5810681 | 2012-12-28 12:27:40 -0800 | [diff] [blame] | 1431 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 1432 | "<<< CLOSE TRANSACTION setWallpaperOffset"); |
| 1433 | } |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 1434 | } |
Craig Mautner | 48ba1e7 | 2012-04-02 13:18:16 -0700 | [diff] [blame] | 1435 | } |
| 1436 | |
Craig Mautner | 71dd1b6 | 2014-02-18 15:48:52 -0800 | [diff] [blame] | 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 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1453 | // This must be called while inside a transaction. |
| 1454 | boolean performShowLocked() { |
Craig Mautner | 5962b12 | 2012-10-05 14:45:52 -0700 | [diff] [blame] | 1455 | if (mWin.isHiddenFromUserLocked()) { |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1456 | Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display " |
Craig Mautner | a2d7b11 | 2012-08-21 15:12:20 -0700 | [diff] [blame] | 1457 | + this + ", type " + mWin.mAttrs.type + ", belonging to " + mWin.mOwnerUid); |
Craig Mautner | 9dc52bc | 2012-08-06 14:15:42 -0700 | [diff] [blame] | 1458 | return false; |
| 1459 | } |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1460 | if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && |
| 1461 | mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1462 | RuntimeException e = null; |
| 1463 | if (!WindowManagerService.HIDE_STACK_CRAWLS) { |
| 1464 | e = new RuntimeException(); |
| 1465 | e.fillInStackTrace(); |
| 1466 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1467 | Slog.v(TAG, "performShow on " + this |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1468 | + ": mDrawState=" + mDrawState + " readyForDisplay=" |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 1469 | + mWin.isReadyForDisplayIgnoringKeyguard() |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1470 | + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING) |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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=" |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 1479 | + (mAppAnimator != null ? mAppAnimator.animating : false), e); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 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=" |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 1495 | + (mAppAnimator != null ? mAppAnimator.animating : false)); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1496 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1497 | |
| 1498 | mService.enableScreenIfNeededLocked(); |
| 1499 | |
| 1500 | applyEnterAnimationLocked(); |
| 1501 | |
Craig Mautner | de6198e | 2012-04-19 09:59:31 -0700 | [diff] [blame] | 1502 | // Force the show in the next prepareSurfaceLocked() call. |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1503 | mLastAlpha = -1; |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 1504 | if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) |
| 1505 | Slog.v(TAG, "performShowLocked: mDrawState=HAS_DRAWN in " + this); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1506 | mDrawState = HAS_DRAWN; |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 1507 | mService.scheduleAnimationLocked(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1515 | if (c.mWinAnimator.mSurfaceControl != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 1522 | final DisplayContent displayContent = c.getDisplayContent(); |
| 1523 | if (displayContent != null) { |
| 1524 | displayContent.layoutNeeded = true; |
| 1525 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 || |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1536 | WindowManagerService.DEBUG_ANIM) Slog.v(TAG, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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. |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1543 | clearAnimation(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1566 | if (mSurfaceControl != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1567 | mSurfaceShown = true; |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1568 | mSurfaceControl.show(); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1569 | if (mWin.mTurnOnScreen) { |
| 1570 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
| 1571 | "Show surface turning screen on: " + mWin); |
| 1572 | mWin.mTurnOnScreen = false; |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 1573 | mAnimator.mBulkUpdateParams |= SET_TURN_ON_SCREEN; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1574 | } |
| 1575 | } |
| 1576 | return true; |
| 1577 | } catch (RuntimeException e) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1578 | Slog.w(TAG, "Failure showing surface " + mSurfaceControl + " in " + mWin, e); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1594 | applyAnimationLocked(transit, true); |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 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); |
Svetoslav Ganov | 152e9bb | 2012-10-12 20:15:29 -0700 | [diff] [blame] | 1599 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | /** |
| 1603 | * Choose the correct animation and set it to the passed WindowState. |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1604 | * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1627 | a = anim != -1 ? AnimationUtils.loadAnimation(mContext, anim) : null; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1644 | a = mService.mAppTransition.loadAnimation(mWin.mAttrs, attr); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1645 | } |
| 1646 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1647 | if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1648 | "applyAnimation: win=" + this |
| 1649 | + " anim=" + anim + " attr=0x" + Integer.toHexString(attr) |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 1650 | + " a=" + a |
Craig Mautner | 8863cca | 2012-09-18 15:04:34 -0700 | [diff] [blame] | 1651 | + " transit=" + transit |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 1652 | + " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3)); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | d87946b | 2012-03-29 18:00:19 -0700 | [diff] [blame] | 1660 | Slog.v(TAG, "Loaded animation " + a + " for " + this, e); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1661 | } |
| 1662 | setAnimation(a); |
| 1663 | mAnimationIsEntrance = isEntrance; |
| 1664 | } |
| 1665 | } else { |
| 1666 | clearAnimation(); |
| 1667 | } |
| 1668 | |
| 1669 | return mAnimation != null; |
| 1670 | } |
| 1671 | |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 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 | } |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1687 | if (mSurfaceControl != null) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 1688 | if (dumpAll) { |
Mathias Agopian | 29479eb | 2013-02-14 14:36:04 -0800 | [diff] [blame] | 1689 | pw.print(prefix); pw.print("mSurface="); pw.println(mSurfaceControl); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1690 | pw.print(prefix); pw.print("mDrawState="); |
| 1691 | pw.print(drawStateToString(mDrawState)); |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 1692 | pw.print(" mLastHidden="); pw.println(mLastHidden); |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 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 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1727 | } |
| 1728 | |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1729 | @Override |
| 1730 | public String toString() { |
Dianne Hackborn | 529e744 | 2012-11-01 14:22:28 -0700 | [diff] [blame] | 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('}'); |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 1736 | return sb.toString(); |
| 1737 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 1738 | } |