am 27c0773c: Merge "Fix wallpaper not updating on initial boot." into jb-mr1-dev

* commit '27c0773c34001c02cb7e2a6ae6e085ee3ed150cf':
  Fix wallpaper not updating on initial boot.
This commit is contained in:
Craig Mautner
2012-10-14 11:27:40 -07:00
committed by Android Git Automerger

View File

@@ -156,7 +156,7 @@ public class ImageWallpaper extends WallpaperService {
mBackgroundWidth = mBackgroundHeight = -1; mBackgroundWidth = mBackgroundHeight = -1;
mBackground = null; mBackground = null;
mRedrawNeeded = true; mRedrawNeeded = true;
drawFrameLocked(); drawFrameLocked(false);
} }
} }
} }
@@ -234,7 +234,7 @@ public class ImageWallpaper extends WallpaperService {
Log.d(TAG, "Visibility changed to visible=" + visible); Log.d(TAG, "Visibility changed to visible=" + visible);
} }
mVisible = visible; mVisible = visible;
drawFrameLocked(); drawFrameLocked(false);
} }
} }
} }
@@ -263,7 +263,7 @@ public class ImageWallpaper extends WallpaperService {
mYOffset = yOffset; mYOffset = yOffset;
mOffsetsChanged = true; mOffsetsChanged = true;
} }
drawFrameLocked(); drawFrameLocked(false);
} }
} }
@@ -277,7 +277,8 @@ public class ImageWallpaper extends WallpaperService {
synchronized (mLock) { synchronized (mLock) {
mRedrawNeeded = true; mRedrawNeeded = true;
drawFrameLocked(); mBackgroundWidth = mBackgroundHeight = -1;
drawFrameLocked(true);
} }
} }
@@ -290,25 +291,26 @@ public class ImageWallpaper extends WallpaperService {
synchronized (mLock) { synchronized (mLock) {
mRedrawNeeded = true; mRedrawNeeded = true;
drawFrameLocked(); drawFrameLocked(false);
} }
} }
void drawFrameLocked() { void drawFrameLocked(boolean force) {
if (!mVisible) { if (!force) {
if (DEBUG) { if (!mVisible) {
Log.d(TAG, "Suppressed drawFrame since wallpaper is not visible."); if (DEBUG) {
Log.d(TAG, "Suppressed drawFrame since wallpaper is not visible.");
}
return;
} }
return; if (!mRedrawNeeded && !mOffsetsChanged) {
} if (DEBUG) {
if (!mRedrawNeeded && !mOffsetsChanged) { Log.d(TAG, "Suppressed drawFrame since redraw is not needed "
if (DEBUG) { + "and offsets have not changed.");
Log.d(TAG, "Suppressed drawFrame since redraw is not needed " }
+ "and offsets have not changed."); return;
} }
return;
} }
// If we don't yet know the size of the wallpaper bitmap, // If we don't yet know the size of the wallpaper bitmap,
// we need to get it now. // we need to get it now.
boolean updateWallpaper = mBackgroundWidth < 0 || mBackgroundHeight < 0 ; boolean updateWallpaper = mBackgroundWidth < 0 || mBackgroundHeight < 0 ;
@@ -332,7 +334,8 @@ public class ImageWallpaper extends WallpaperService {
int yPixels = availh < 0 ? (int)(availh * mYOffset + .5f) : (availh / 2); int yPixels = availh < 0 ? (int)(availh * mYOffset + .5f) : (availh / 2);
mOffsetsChanged = false; mOffsetsChanged = false;
if (!mRedrawNeeded && xPixels == mLastXTranslation && yPixels == mLastYTranslation) { if (!force && !mRedrawNeeded
&& xPixels == mLastXTranslation && yPixels == mLastYTranslation) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "Suppressed drawFrame since the image has not " Log.d(TAG, "Suppressed drawFrame since the image has not "
+ "actually moved an integral number of pixels."); + "actually moved an integral number of pixels.");
@@ -343,6 +346,11 @@ public class ImageWallpaper extends WallpaperService {
mLastXTranslation = xPixels; mLastXTranslation = xPixels;
mLastYTranslation = yPixels; mLastYTranslation = yPixels;
if (DEBUG) {
Log.d(TAG, "drawFrameUnlocked(" + force + "): mBackgroundWxH=" + mBackgroundWidth + "x"
+ mBackgroundHeight + " SurfaceFrame=" + frame.toShortString()
+ " X,YOffset=" + mXOffset + "," + mYOffset);
}
if (mIsHwAccelerated) { if (mIsHwAccelerated) {
if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) { if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) {
drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels); drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels);