Skip to content

Commit 041a0ba

Browse files
author
Adam Cohen
committed
Deferring wallpaper update to improve workspace scrolling (issue 5506959)
-> On the Xoom, this change gets us back up to 60 fps. The change is really more of a workaround for the fact that we don't have vsync, and we ought to be able to change it back once we do. Change-Id: I80888f18887bf5f2fed72c19641ed430ef6dbfcf
1 parent 4c96a59 commit 041a0ba

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

core/java/android/app/WallpaperManager.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ public void onWallpaperChanged() {
212212
*/
213213
mHandler.sendEmptyMessage(MSG_CLEAR_WALLPAPER);
214214
}
215-
215+
216+
public Handler getHandler() {
217+
return mHandler;
218+
}
219+
216220
public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault) {
217221
synchronized (this) {
218222
if (mWallpaper != null) {
@@ -604,7 +608,7 @@ public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) {
604608
// Ignore
605609
}
606610
}
607-
611+
608612
/**
609613
* Set the position of the current wallpaper within any larger space, when
610614
* that wallpaper is visible behind the given window. The X and Y offsets
@@ -619,16 +623,23 @@ public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) {
619623
* @param yOffset The offset along the Y dimension, from 0 to 1.
620624
*/
621625
public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) {
622-
try {
623-
//Log.v(TAG, "Sending new wallpaper offsets from app...");
624-
ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
625-
windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep);
626-
//Log.v(TAG, "...app returning after sending offsets!");
627-
} catch (RemoteException e) {
628-
// Ignore.
629-
}
626+
final IBinder fWindowToken = windowToken;
627+
final float fXOffset = xOffset;
628+
final float fYOffset = yOffset;
629+
sGlobals.getHandler().post(new Runnable() {
630+
public void run() {
631+
try {
632+
//Log.v(TAG, "Sending new wallpaper offsets from app...");
633+
ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
634+
fWindowToken, fXOffset, fYOffset, mWallpaperXStep, mWallpaperYStep);
635+
//Log.v(TAG, "...app returning after sending offsets!");
636+
} catch (RemoteException e) {
637+
// Ignore.
638+
}
639+
}
640+
});
630641
}
631-
642+
632643
/**
633644
* For applications that use multiple virtual screens showing a wallpaper,
634645
* specify the step size between virtual screens. For example, if the

0 commit comments

Comments
 (0)