From 19d59bc5ad877e9b1544ab13a08282b7b384fefb Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Tue, 4 Sep 2012 11:15:56 -0700 Subject: [PATCH] Make mLayoutNeeded per-Display. Switch from a global mLayoutNeeded to one for each Display so that we don't run layout on Displays that haven't changed. Change-Id: Ib65c5c667933cceacc46b94f4e6e6bd613d5cb35 --- .../server/wm/WindowManagerService.java | 121 ++++++++++-------- .../com/android/server/wm/WindowState.java | 8 +- .../server/wm/WindowStateAnimator.java | 4 +- 3 files changed, 80 insertions(+), 53 deletions(-) diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 0d6de38078cc1..969991e87c9a5 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -99,7 +99,6 @@ import android.util.EventLog; import android.util.FloatMath; import android.util.Log; import android.util.SparseArray; -//import android.util.LogPrinter; import android.util.Pair; import android.util.Slog; import android.util.SparseIntArray; @@ -454,7 +453,6 @@ public class WindowManagerService extends IWindowManager.Stub int mSystemDecorLayer = 0; final Rect mScreenRect = new Rect(); - boolean mLayoutNeeded = true; boolean mTraversalScheduled = false; boolean mDisplayFrozen = false; boolean mWaitingForConfig = false; @@ -1768,7 +1766,7 @@ public class WindowManagerService extends IWindowManager.Stub token.hidden = !visible; // Need to do a layout to ensure the wallpaper now has the // correct size. - mLayoutNeeded = true; + getDefaultDisplayContent().layoutNeeded = true; } int curWallpaperIndex = token.windows.size(); @@ -2011,7 +2009,7 @@ public class WindowManagerService extends IWindowManager.Stub token.hidden = !visible; // Need to do a layout to ensure the wallpaper now has the // correct size. - mLayoutNeeded = true; + getDefaultDisplayContent().layoutNeeded = true; } int curWallpaperIndex = token.windows.size(); @@ -2310,7 +2308,7 @@ public class WindowManagerService extends IWindowManager.Stub //Slog.i(TAG, "*** Running exit animation..."); win.mExiting = true; win.mRemoveOnExit = true; - mLayoutNeeded = true; + win.mDisplayContent.layoutNeeded = true; updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); performLayoutAndPlaceSurfacesLocked(); @@ -2427,7 +2425,7 @@ public class WindowManagerService extends IWindowManager.Stub if (!mInLayout) { assignLayersLocked(windows); - mLayoutNeeded = true; + win.mDisplayContent.layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); if (win.mAppToken != null) { win.mAppToken.updateReportedVisibilityLocked(); @@ -2493,7 +2491,7 @@ public class WindowManagerService extends IWindowManager.Stub w.mGivenVisibleInsets.scale(w.mGlobalScale); w.mGivenTouchableRegion.scale(w.mGlobalScale); } - mLayoutNeeded = true; + w.mDisplayContent.layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); } } @@ -2588,7 +2586,7 @@ public class WindowManagerService extends IWindowManager.Stub window.mGivenTouchableRegion.op((int)dispRect.left, (int)dispRect.top, (int)dispRect.right, (int)dispRect.bottom, Region.Op.DIFFERENCE); window.mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; - mLayoutNeeded = true; + window.mDisplayContent.layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); } @@ -2856,7 +2854,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - mLayoutNeeded = true; + win.mDisplayContent.layoutNeeded = true; win.mGivenInsetsPending = (flags&WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0; if (assignLayers) { assignLayersLocked(win.getWindowList()); @@ -2946,7 +2944,7 @@ public class WindowManagerService extends IWindowManager.Stub if ((win.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0) { adjustWallpaperWindowsLocked(); } - mLayoutNeeded = true; + win.mDisplayContent.layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); } } @@ -3460,11 +3458,11 @@ public class WindowManagerService extends IWindowManager.Stub win.mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false); changed = true; + win.mDisplayContent.layoutNeeded = true; } } if (changed) { - mLayoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /*updateInputWindows*/); @@ -3720,7 +3718,7 @@ public class WindowManagerService extends IWindowManager.Stub if (computeScreenConfigurationLocked(mTempConfiguration)) { if (currentConfig.diff(mTempConfiguration) != 0) { mWaitingForConfig = true; - mLayoutNeeded = true; + getDefaultDisplayContent().layoutNeeded = true; startFreezingDisplayLocked(false); config = new Configuration(mTempConfiguration); } @@ -4086,7 +4084,7 @@ public class WindowManagerService extends IWindowManager.Stub updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/); - mLayoutNeeded = true; + getDefaultDisplayContent().layoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); Binder.restoreCallingIdentity(origId); return; @@ -4251,6 +4249,7 @@ public class WindowManagerService extends IWindowManager.Stub WindowManagerPolicy.TRANSIT_ENTER, true); } changed = true; + win.mDisplayContent.layoutNeeded = true; } } else if (win.isVisibleNow()) { if (!runningAppAnimation) { @@ -4258,6 +4257,7 @@ public class WindowManagerService extends IWindowManager.Stub WindowManagerPolicy.TRANSIT_EXIT, false); } changed = true; + win.mDisplayContent.layoutNeeded = true; } } @@ -4279,7 +4279,6 @@ public class WindowManagerService extends IWindowManager.Stub + wtoken.hiddenRequested); if (changed) { - mLayoutNeeded = true; mInputMonitor.setUpdateInputWindowsNeededLw(); if (performLayout) { updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, @@ -4407,6 +4406,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mOrientationChangeComplete = false; } unfrozeWindows = true; + w.mDisplayContent.layoutNeeded = true; } } if (force || unfrozeWindows) { @@ -4416,7 +4416,6 @@ public class WindowManagerService extends IWindowManager.Stub } if (unfreezeSurfaceNow) { if (unfrozeWindows) { - mLayoutNeeded = true; performLayoutAndPlaceSurfacesLocked(); } stopFreezingDisplayLocked(); @@ -4761,13 +4760,15 @@ public class WindowManagerService extends IWindowManager.Stub final DisplayContent displayContent = iterator.next(); final WindowList windows = displayContent.getWindowList(); final int pos = findWindowOffsetLocked(windows, index); - reAddAppWindowsLocked(displayContent, pos, wtoken); + final int newPos = reAddAppWindowsLocked(displayContent, pos, wtoken); + if (pos != newPos) { + displayContent.layoutNeeded = true; + } } if (DEBUG_REORDER) Slog.v(TAG, "Final window list:"); if (DEBUG_REORDER) dumpWindowsLocked(); updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); - mLayoutNeeded = true; mInputMonitor.setUpdateInputWindowsNeededLw(); performLayoutAndPlaceSurfacesLocked(); mInputMonitor.updateInputWindowsLw(false /*force*/); @@ -4807,7 +4808,10 @@ public class WindowManagerService extends IWindowManager.Stub final DisplayContent displayContent = iterator.next(); final WindowList windows = displayContent.getWindowList(); final int pos = findWindowOffsetLocked(windows, tokenPos); - reAddAppWindowsLocked(displayContent, pos, wtoken); + final int newPos = reAddAppWindowsLocked(displayContent, pos, wtoken); + if (pos != newPos) { + displayContent.layoutNeeded = true; + } if (updateFocusAndLayout && !updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/)) { @@ -4820,7 +4824,6 @@ public class WindowManagerService extends IWindowManager.Stub // Note that the above updateFocusedWindowLocked conditional used to sit here. - mLayoutNeeded = true; if (!mInLayout) { performLayoutAndPlaceSurfacesLocked(); } @@ -4849,7 +4852,11 @@ public class WindowManagerService extends IWindowManager.Stub for (i=0; i