summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-03-30 13:03:49 -0700
committerCraig Mautner <cmautner@google.com>2012-03-30 13:19:45 -0700
commita608b882327fbb393bde3854953cd322a6fea675 (patch)
tree32f957f0baae3b13a76fcbab3e7b23e4198735a6 /services/java
parentd87946ba48b62a6a83fd971ef7c4c419407db836 (diff)
downloadframeworks_base-a608b882327fbb393bde3854953cd322a6fea675.zip
frameworks_base-a608b882327fbb393bde3854953cd322a6fea675.tar.gz
frameworks_base-a608b882327fbb393bde3854953cd322a6fea675.tar.bz2
Move variables into animation class.
Moved drawPending and commitDrawPending and associated methods from WindowState to WindowStateAnimator. Created mechanism for passing results from WindowAnimator to WindowManagerService. Initial results passed are mUpdateRotation and mWallpaperMayChange. Change-Id: Ib03d28f921580ac9426ea9233bea6eafc9ea964c
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/wm/AppWindowToken.java4
-rw-r--r--services/java/com/android/server/wm/WindowAnimator.java28
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java71
-rw-r--r--services/java/com/android/server/wm/WindowState.java46
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java44
5 files changed, 105 insertions, 88 deletions
diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java
index c24c2d9..d1f1b44 100644
--- a/services/java/com/android/server/wm/AppWindowToken.java
+++ b/services/java/com/android/server/wm/AppWindowToken.java
@@ -393,8 +393,8 @@ class AppWindowToken extends WindowToken {
if (!win.isDrawnLw()) {
Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurface
+ " pv=" + win.mPolicyVisibility
- + " dp=" + win.mDrawPending
- + " cdp=" + win.mCommitDrawPending
+ + " dp=" + win.mWinAnimator.mDrawPending
+ + " cdp=" + win.mWinAnimator.mCommitDrawPending
+ " ah=" + win.mAttachedHidden
+ " th="
+ (win.mAppToken != null
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index eddfe92..26f4d0d 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -4,6 +4,9 @@ package com.android.server.wm;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
+import static com.android.server.wm.WindowManagerService.LayoutFields.SET_UPDATE_ROTATION;
+import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPAPER_MAY_CHANGE;
+
import android.content.Context;
import android.os.SystemClock;
import android.util.Log;
@@ -30,7 +33,6 @@ public class WindowAnimator {
final WindowManagerPolicy mPolicy;
boolean mAnimating;
- boolean mUpdateRotation;
boolean mTokenMayBeDrawn;
boolean mForceHiding;
WindowState mWindowAnimationBackground;
@@ -61,9 +63,10 @@ public class WindowAnimator {
// seen.
WindowState mWindowDetachedWallpaper = null;
WindowState mDetachedWallpaper = null;
- boolean mWallpaperMayChange;
DimSurface mWindowAnimationBackgroundSurface = null;
+ int mBulkUpdateParams = 0;
+
WindowAnimator(final WindowManagerService service, final Context context,
final WindowManagerPolicy policy) {
mService = service;
@@ -77,7 +80,7 @@ public class WindowAnimator {
"Detached wallpaper changed from " + mWindowDetachedWallpaper
+ " to " + mDetachedWallpaper);
mWindowDetachedWallpaper = mDetachedWallpaper;
- mWallpaperMayChange = true;
+ mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
}
if (mWindowAnimationBackgroundColor != 0) {
@@ -147,10 +150,9 @@ public class WindowAnimator {
(mScreenRotationAnimation.isAnimating() ||
mScreenRotationAnimation.mFinishAnimReady)) {
if (mScreenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
- mUpdateRotation = false;
mAnimating = true;
} else {
- mUpdateRotation = true;
+ mBulkUpdateParams |= SET_UPDATE_ROTATION;
mScreenRotationAnimation.kill();
mScreenRotationAnimation = null;
}
@@ -217,7 +219,7 @@ public class WindowAnimator {
}
if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == w) {
- mWallpaperMayChange = true;
+ mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2");
@@ -270,7 +272,7 @@ public class WindowAnimator {
}
if (changed && (attrs.flags
& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
- mWallpaperMayChange = true;
+ mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4");
@@ -297,8 +299,8 @@ public class WindowAnimator {
if (!w.isDrawnLw()) {
Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface
+ " pv=" + w.mPolicyVisibility
- + " dp=" + w.mDrawPending
- + " cdp=" + w.mCommitDrawPending
+ + " dp=" + winAnimator.mDrawPending
+ + " cdp=" + winAnimator.mCommitDrawPending
+ " ah=" + w.mAttachedHidden
+ " th=" + atoken.hiddenRequested
+ " a=" + winAnimator.mAnimating);
@@ -386,7 +388,6 @@ public class WindowAnimator {
private void performAnimationsLocked() {
mTokenMayBeDrawn = false;
- mService.mInnerFields.mWallpaperMayChange = false;
mForceHiding = false;
mDetachedWallpaper = null;
mWindowAnimationBackground = null;
@@ -399,11 +400,10 @@ public class WindowAnimator {
}
}
-
void animate() {
mPendingLayoutChanges = 0;
- mWallpaperMayChange = false;
mCurrentTime = SystemClock.uptimeMillis();
+ mBulkUpdateParams = 0;
// Update animations of all applications, including those
// associated with exiting/removed apps
@@ -445,8 +445,8 @@ public class WindowAnimator {
Surface.closeTransaction();
}
- if (mWallpaperMayChange) {
- mService.notifyWallpaperMayChange();
+ if (mBulkUpdateParams != 0) {
+ mService.bulkSetParameters(mBulkUpdateParams);
}
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 58505bd..9cc9b96 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -589,7 +589,10 @@ public class WindowManagerService extends IWindowManager.Stub
/** Pulled out of performLayoutAndPlaceSurfacesLockedInner in order to refactor into multiple
* methods. */
- class LayoutAndSurfaceFields {
+ class LayoutFields {
+ static final int SET_UPDATE_ROTATION = 1 << 0;
+ static final int SET_WALLPAPER_MAY_CHANGE = 1 << 1;
+
boolean mWallpaperForceHidingChanged = false;
boolean mWallpaperMayChange = false;
boolean mOrientationChangeComplete = true;
@@ -600,8 +603,9 @@ public class WindowManagerService extends IWindowManager.Stub
private boolean mSyswin = false;
private float mScreenBrightness = -1;
private float mButtonBrightness = -1;
+ private boolean mUpdateRotation = false;
}
- LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields();
+ LayoutFields mInnerFields = new LayoutFields();
/** Only do a maximum of 6 repeated layouts. After that quit */
private int mLayoutRepeatCount;
@@ -1547,6 +1551,7 @@ public class WindowManagerService extends IWindowManager.Stub
static final int ADJUST_WALLPAPER_VISIBILITY_CHANGED = 1<<2;
int adjustWallpaperWindowsLocked() {
+ mInnerFields.mWallpaperMayChange = false;
int changed = 0;
final int dw = mAppDisplayWidth;
@@ -1584,8 +1589,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
if (DEBUG_WALLPAPER) Slog.v(TAG, "Win " + w + ": readyfordisplay="
- + w.isReadyForDisplay() + " drawpending=" + w.mDrawPending
- + " commitdrawpending=" + w.mCommitDrawPending);
+ + w.isReadyForDisplay() + " drawpending=" + w.mWinAnimator.mDrawPending
+ + " commitdrawpending=" + w.mWinAnimator.mCommitDrawPending);
if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
&& (mWallpaperTarget == w || w.isDrawnLw())) {
if (DEBUG_WALLPAPER) Slog.v(TAG,
@@ -2944,7 +2949,7 @@ public class WindowManagerService extends IWindowManager.Stub
final long origId = Binder.clearCallingIdentity();
synchronized(mWindowMap) {
WindowState win = windowForClientLocked(session, client, false);
- if (win != null && win.finishDrawingLocked()) {
+ if (win != null && win.mWinAnimator.finishDrawingLocked()) {
if ((win.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0) {
adjustWallpaperWindowsLocked();
}
@@ -6651,6 +6656,7 @@ public class WindowManagerService extends IWindowManager.Stub
public static final int REPORT_HARD_KEYBOARD_STATUS_CHANGE = 22;
public static final int BOOT_TIMEOUT = 23;
public static final int WAITING_FOR_DRAWN_TIMEOUT = 24;
+ public static final int BULK_UPDATE_PARAMETERS = 25;
private Session mLastReportedHold;
@@ -7061,6 +7067,21 @@ public class WindowManagerService extends IWindowManager.Stub
}
break;
}
+
+ case BULK_UPDATE_PARAMETERS: {
+ synchronized (mWindowMap) {
+ // TODO(cmautner): As the number of bits grows, use masks of bit groups to
+ // eliminate unnecessary tests.
+ if ((msg.arg1 & LayoutFields.SET_UPDATE_ROTATION) != 0) {
+ mInnerFields.mUpdateRotation = true;
+ }
+ if ((msg.arg1 & LayoutFields.SET_WALLPAPER_MAY_CHANGE) != 0) {
+ mInnerFields.mWallpaperMayChange = true;
+ }
+
+ requestTraversalLocked();
+ }
+ }
}
}
}
@@ -7995,7 +8016,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
mInnerFields.mAdjResult |= adjustWallpaperWindowsLocked();
- mInnerFields.mWallpaperMayChange = false;
mInnerFields.mWallpaperForceHidingChanged = false;
if (DEBUG_WALLPAPER) Slog.v(TAG, "****** OLD: " + oldWallpaper
+ " NEW: " + mWallpaperTarget
@@ -8026,6 +8046,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
private void updateResizingWindows(final WindowState w) {
+ final WindowStateAnimator winAnimator = w.mWinAnimator;
if (!w.mAppFreezing && w.mLayoutSeq == mLayoutSeq) {
w.mContentInsetsChanged |=
!w.mLastContentInsets.equals(w.mContentInsets);
@@ -8045,7 +8066,7 @@ public class WindowManagerService extends IWindowManager.Stub
w.mLastFrame.set(w.mFrame);
if (w.mContentInsetsChanged
|| w.mVisibleInsetsChanged
- || w.mWinAnimator.mSurfaceResized
+ || winAnimator.mSurfaceResized
|| configChanged) {
if (DEBUG_RESIZE || DEBUG_ORIENTATION) {
Slog.v(TAG, "Resize reasons: "
@@ -8067,8 +8088,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (DEBUG_ORIENTATION) Slog.v(TAG,
"Orientation start waiting for draw in "
+ w + ", surface " + w.mWinAnimator.mSurface);
- w.mDrawPending = true;
- w.mCommitDrawPending = false;
+ winAnimator.mDrawPending = true;
+ winAnimator.mCommitDrawPending = false;
w.mReadyToShow = false;
if (w.mAppToken != null) {
w.mAppToken.allDrawn = false;
@@ -8377,7 +8398,7 @@ public class WindowManagerService extends IWindowManager.Stub
// Moved from updateWindowsAndWallpaperLocked().
if (winAnimator.mSurface != null) {
// Take care of the window being ready to display.
- if (w.commitFinishDrawingLocked(currentTime)) {
+ if (winAnimator.commitFinishDrawingLocked(currentTime)) {
if ((w.mAttrs.flags
& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
@@ -8439,6 +8460,7 @@ public class WindowManagerService extends IWindowManager.Stub
do {
i--;
WindowState win = mResizingWindows.get(i);
+ final WindowStateAnimator winAnimator = win.mWinAnimator;
try {
if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
"Reporting new frame to " + win + ": " + win.mCompatFrame);
@@ -8450,20 +8472,20 @@ public class WindowManagerService extends IWindowManager.Stub
if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION)
&& configChanged) {
Slog.i(TAG, "Sending new config to window " + win + ": "
- + win.mWinAnimator.mSurfaceW + "x" + win.mWinAnimator.mSurfaceH
+ + winAnimator.mSurfaceW + "x" + winAnimator.mSurfaceH
+ " / " + mCurConfiguration + " / 0x"
+ Integer.toHexString(diff));
}
win.mConfiguration = mCurConfiguration;
- if (DEBUG_ORIENTATION && win.mDrawPending) Slog.i(
+ if (DEBUG_ORIENTATION && winAnimator.mDrawPending) Slog.i(
TAG, "Resizing " + win + " WITH DRAW PENDING");
- win.mClient.resized((int)win.mWinAnimator.mSurfaceW,
- (int)win.mWinAnimator.mSurfaceH,
- win.mLastContentInsets, win.mLastVisibleInsets, win.mDrawPending,
- configChanged ? win.mConfiguration : null);
+ win.mClient.resized((int)winAnimator.mSurfaceW,
+ (int)winAnimator.mSurfaceH,
+ win.mLastContentInsets, win.mLastVisibleInsets,
+ winAnimator.mDrawPending, configChanged ? win.mConfiguration : null);
win.mContentInsetsChanged = false;
win.mVisibleInsetsChanged = false;
- win.mWinAnimator.mSurfaceResized = false;
+ winAnimator.mSurfaceResized = false;
} catch (RemoteException e) {
win.mOrientationChanging = false;
}
@@ -8574,17 +8596,17 @@ public class WindowManagerService extends IWindowManager.Stub
mTurnOnScreen = false;
}
- if (mAnimator.mUpdateRotation) {
+ if (mInnerFields.mUpdateRotation) {
if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
if (updateRotationUncheckedLocked(false)) {
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
} else {
- mAnimator.mUpdateRotation = false;
+ mInnerFields.mUpdateRotation = false;
}
}
if (mInnerFields.mOrientationChangeComplete && !mLayoutNeeded &&
- !mAnimator.mUpdateRotation) {
+ !mInnerFields.mUpdateRotation) {
checkDrawnWindowsLocked();
}
@@ -9646,15 +9668,14 @@ public class WindowManagerService extends IWindowManager.Stub
requestTraversalLocked();
}
- void notifyWallpaperMayChange() {
- mInnerFields.mWallpaperMayChange = true;
- requestTraversalLocked();
- }
-
void debugLayoutRepeats(final String msg) {
if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) {
Slog.v(TAG, "Layouts looping: " + msg);
Slog.v(TAG, "mPendingLayoutChanges = 0x" + Integer.toHexString(mPendingLayoutChanges));
}
}
+
+ void bulkSetParameters(final int bulkUpdateParams) {
+ mH.sendMessage(mH.obtainMessage(H.BULK_UPDATE_PARAMETERS, bulkUpdateParams, 0));
+ }
}
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index d22b17c..7f63429 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -19,7 +19,6 @@ package com.android.server.wm;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
@@ -207,15 +206,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
// when in that case until the layout is done.
boolean mLayoutNeeded;
- // This is set after the Surface has been created but before the
- // window has been drawn. During this time the surface is hidden.
- boolean mDrawPending;
-
- // This is set after the window has finished drawing for the first
- // time but before its surface is shown. The surface will be
- // displayed when the next layout is run.
- boolean mCommitDrawPending;
-
// This is set during the time after the window's drawing has been
// committed, and before its surface is actually shown. It is used
// to delay showing the surface until all windows in a token are ready
@@ -595,36 +585,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
return mAppToken != null ? mAppToken.firstWindowDrawn : false;
}
- // TODO(cmautner): Move to WindowStateAnimator
- boolean finishDrawingLocked() {
- if (mDrawPending) {
- if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v(
- TAG, "finishDrawingLocked: " + this + " in "
- + mWinAnimator.mSurface);
- mCommitDrawPending = true;
- mDrawPending = false;
- return true;
- }
- return false;
- }
-
- // TODO(cmautner): Move to WindowStateAnimator
- // This must be called while inside a transaction.
- boolean commitFinishDrawingLocked(long currentTime) {
- //Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface);
- if (!mCommitDrawPending) {
- return false;
- }
- mCommitDrawPending = false;
- mReadyToShow = true;
- final boolean starting = mAttrs.type == TYPE_APPLICATION_STARTING;
- final AppWindowToken atoken = mAppToken;
- if (atoken == null || atoken.allDrawn || starting) {
- mWinAnimator.performShowLocked();
- }
- return true;
- }
-
boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
if (dsdx < .99999f || dsdx > 1.00001f) return false;
if (dtdy < .99999f || dtdy > 1.00001f) return false;
@@ -782,7 +742,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
*/
public boolean isDrawnLw() {
return mWinAnimator.mSurface != null && !mDestroying
- && !mDrawPending && !mCommitDrawPending;
+ && !mWinAnimator.mDrawPending && !mWinAnimator.mCommitDrawPending;
}
/**
@@ -1087,8 +1047,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
mWinAnimator.dump(pw, prefix, dumpAll);
if (dumpAll) {
- pw.print(prefix); pw.print("mDrawPending="); pw.print(mDrawPending);
- pw.print(" mCommitDrawPending="); pw.print(mCommitDrawPending);
+ pw.print(prefix); pw.print("mDrawPending="); pw.print(mWinAnimator.mDrawPending);
+ pw.print(" mCommitDrawPending="); pw.print(mWinAnimator.mCommitDrawPending);
pw.print(" mReadyToShow="); pw.print(mReadyToShow);
pw.print(" mHasDrawn="); pw.println(mHasDrawn);
}
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index d1539ba..e99340c 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -98,6 +98,15 @@ class WindowStateAnimator {
// an enter animation.
boolean mEnterAnimationPending;
+ // This is set after the Surface has been created but before the
+ // window has been drawn. During this time the surface is hidden.
+ boolean mDrawPending;
+
+ // This is set after the window has finished drawing for the first
+ // time but before its surface is shown. The surface will be
+ // displayed when the next layout is run.
+ boolean mCommitDrawPending;
+
public WindowStateAnimator(final WindowManagerService service, final WindowState win,
final WindowState attachedWindow) {
mService = service;
@@ -347,14 +356,41 @@ class WindowStateAnimator {
}
}
+ boolean finishDrawingLocked() {
+ if (mDrawPending) {
+ if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v(
+ TAG, "finishDrawingLocked: " + this + " in " + mSurface);
+ mCommitDrawPending = true;
+ mDrawPending = false;
+ return true;
+ }
+ return false;
+ }
+
+ // This must be called while inside a transaction.
+ boolean commitFinishDrawingLocked(long currentTime) {
+ //Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface);
+ if (!mCommitDrawPending) {
+ return false;
+ }
+ mCommitDrawPending = false;
+ mWin.mReadyToShow = true;
+ final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
+ final AppWindowToken atoken = mWin.mAppToken;
+ if (atoken == null || atoken.allDrawn || starting) {
+ performShowLocked();
+ }
+ return true;
+ }
+
Surface createSurfaceLocked() {
if (mSurface == null) {
mReportDestroySurface = false;
mSurfacePendingDestroy = false;
if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG,
"createSurface " + this + ": DRAW NOW PENDING");
- mWin.mDrawPending = true;
- mWin.mCommitDrawPending = false;
+ mDrawPending = true;
+ mCommitDrawPending = false;
mWin.mReadyToShow = false;
if (mWin.mAppToken != null) {
mWin.mAppToken.allDrawn = false;
@@ -471,8 +507,8 @@ class WindowStateAnimator {
}
if (mSurface != null) {
- mWin.mDrawPending = false;
- mWin.mCommitDrawPending = false;
+ mDrawPending = false;
+ mCommitDrawPending = false;
mWin.mReadyToShow = false;
int i = mWin.mChildWindows.size();