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