summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2011-10-28 13:18:16 -0700
committerChet Haase <chet@google.com>2011-10-28 14:49:23 -0700
commita8e5a2bcd6a0d35893187c6df42425c03be005da (patch)
treef6ef550565e525e7b8262182a336eb40432915e9 /services
parent48ba4139b9dc1f53f996b71f509a9d0c6fd2d72b (diff)
downloadframeworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.zip
frameworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.tar.gz
frameworks_base-a8e5a2bcd6a0d35893187c6df42425c03be005da.tar.bz2
Optimize handling of scrolled wallpapers
Swiping the home screen causes the WindowManagerService to do a bunch of work to keep the wallpapers in sync. First, it lays out and places all windows. Also, it notifies the SystemUI process that the wallpaper position has changed. The layout/place operation is too much work - we only need to set the position values for the wallpaper, not relayout the whole system. The notification mechanism must exist, but should be optional. Most wallpapers don't care (especially static ImageWallpapers). So we'll give them a new API (WallpaperService.Engine.setWantsOffsets()) to allow wallpapers to opt out of this process and avoid the performance overhead. Change-Id: I66c38375438937f14f6f5550565b28eb204b1e06
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java34
1 files changed, 24 insertions, 10 deletions
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 792ef70..08797dd 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -1836,7 +1836,8 @@ public class WindowManagerService extends IWindowManager.Stub
rawChanged = true;
}
- if (rawChanged) {
+ if (rawChanged && (wallpaperWin.getAttrs().privateFlags &
+ WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) != 0) {
try {
if (DEBUG_WALLPAPER) Slog.v(TAG, "Report new wp offset "
+ wallpaperWin + " x=" + wallpaperWin.mWallpaperX
@@ -1886,12 +1887,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
- boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
+ void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
final int dw = mAppDisplayWidth;
final int dh = mAppDisplayHeight;
- boolean changed = false;
-
WindowState target = mWallpaperTarget;
if (target != null) {
if (target.mWallpaperX >= 0) {
@@ -1916,14 +1915,31 @@ public class WindowManagerService extends IWindowManager.Stub
WindowState wallpaper = token.windows.get(curWallpaperIndex);
if (updateWallpaperOffsetLocked(wallpaper, dw, dh, sync)) {
wallpaper.computeShownFrameLocked();
- changed = true;
+ // No need to lay out the windows - we can just set the wallpaper position
+ // directly.
+ if (wallpaper.mSurfaceX != wallpaper.mShownFrame.left
+ || wallpaper.mSurfaceY != wallpaper.mShownFrame.top) {
+ Surface.openTransaction();
+ try {
+ if (SHOW_TRANSACTIONS) logSurface(wallpaper,
+ "POS " + wallpaper.mShownFrame.left
+ + ", " + wallpaper.mShownFrame.top, null);
+ wallpaper.mSurfaceX = wallpaper.mShownFrame.left;
+ wallpaper.mSurfaceY = wallpaper.mShownFrame.top;
+ wallpaper.mSurface.setPosition(wallpaper.mShownFrame.left,
+ wallpaper.mShownFrame.top);
+ } catch (RuntimeException e) {
+ Slog.w(TAG, "Error positioning surface of " + wallpaper
+ + " pos=(" + wallpaper.mShownFrame.left
+ + "," + wallpaper.mShownFrame.top + ")", e);
+ }
+ Surface.closeTransaction();
+ }
// We only want to be synchronous with one wallpaper.
sync = false;
}
}
}
-
- return changed;
}
void updateWallpaperVisibilityLocked() {
@@ -2436,9 +2452,7 @@ public class WindowManagerService extends IWindowManager.Stub
window.mWallpaperY = y;
window.mWallpaperXStep = xStep;
window.mWallpaperYStep = yStep;
- if (updateWallpaperOffsetLocked(window, true)) {
- performLayoutAndPlaceSurfacesLocked();
- }
+ updateWallpaperOffsetLocked(window, true);
}
}