diff options
author | Chet Haase <chet@google.com> | 2011-10-28 15:13:27 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-28 15:13:27 -0700 |
commit | d568bba507b0f66d4d57c67b08ade894d2c75e53 (patch) | |
tree | a69d650ae295d479170f0f0ddf67dd87e3e4c4df /core | |
parent | c00d2ddcc343b7bcdce30925df90523bb7371f83 (diff) | |
parent | a8e5a2bcd6a0d35893187c6df42425c03be005da (diff) | |
download | frameworks_base-d568bba507b0f66d4d57c67b08ade894d2c75e53.zip frameworks_base-d568bba507b0f66d4d57c67b08ade894d2c75e53.tar.gz frameworks_base-d568bba507b0f66d4d57c67b08ade894d2c75e53.tar.bz2 |
Merge "Optimize handling of scrolled wallpapers" into ics-mr1
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 29 | ||||
-rw-r--r-- | core/java/android/view/WindowManager.java | 11 |
2 files changed, 39 insertions, 1 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index ba94ab2..a9a628a 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -148,7 +148,10 @@ public abstract class WallpaperService extends Service { int mCurWidth; int mCurHeight; int mWindowFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; + int mWindowPrivateFlags = + WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; int mCurWindowFlags = mWindowFlags; + int mCurWindowPrivateFlags = mWindowPrivateFlags; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); final Rect mContentInsets = new Rect(); @@ -359,6 +362,25 @@ public abstract class WallpaperService extends Service { updateSurface(false, false, false); } } + + /** + * Control whether this wallpaper will receive notifications when the wallpaper + * has been scrolled. By default, wallpapers will receive notifications, although + * the default static image wallpapers do not. It is a performance optimization to + * set this to false. + * + * @param enabled whether the wallpaper wants to receive offset notifications + */ + public void setOffsetNotificationsEnabled(boolean enabled) { + mWindowPrivateFlags = enabled + ? (mWindowPrivateFlags | + WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) + : (mWindowPrivateFlags & + ~WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS); + if (mCreated) { + updateSurface(false, false, false); + } + } /** * Called once to initialize the engine. After returning, the @@ -478,6 +500,8 @@ public abstract class WallpaperService extends Service { out.print(prefix); out.print("mType="); out.print(mType); out.print(" mWindowFlags="); out.print(mWindowFlags); out.print(" mCurWindowFlags="); out.println(mCurWindowFlags); + out.print(" mWindowPrivateFlags="); out.print(mWindowPrivateFlags); + out.print(" mCurWindowPrivateFlags="); out.println(mCurWindowPrivateFlags); out.print(prefix); out.print("mVisibleInsets="); out.print(mVisibleInsets.toShortString()); out.print(" mWinFrame="); out.print(mWinFrame.toShortString()); @@ -528,7 +552,8 @@ public abstract class WallpaperService extends Service { final boolean formatChanged = mFormat != mSurfaceHolder.getRequestedFormat(); boolean sizeChanged = mWidth != myWidth || mHeight != myHeight; final boolean typeChanged = mType != mSurfaceHolder.getRequestedType(); - final boolean flagsChanged = mCurWindowFlags != mWindowFlags; + final boolean flagsChanged = mCurWindowFlags != mWindowFlags || + mCurWindowPrivateFlags != mWindowPrivateFlags; if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged || typeChanged || flagsChanged || redrawNeeded) { @@ -554,6 +579,8 @@ public abstract class WallpaperService extends Service { | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE ; + mCurWindowPrivateFlags = mWindowPrivateFlags; + mLayout.privateFlags = mWindowPrivateFlags; mLayout.memoryType = mType; mLayout.token = mWindowToken; diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index e8ab227..e74fec6 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -813,6 +813,17 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; /** + * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers + * may elect to skp these notifications if they are no doing anything productive with + * them (they do not affect the wallpaper scrolling operation) by calling + * {@link + * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. + * + * @hide + */ + public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; + + /** * Control flags that are private to the platform. * @hide */ |