Loading core/java/android/service/wallpaper/WallpaperService.java +2 −1 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ public abstract class WallpaperService extends Service { mCurHeight = h; } mSurfaceHolder.setSurfaceFrameSize(w, h); mSurfaceHolder.mSurfaceLock.unlock(); if (!mSurfaceHolder.mSurface.isValid()) { Loading core/java/android/view/SurfaceView.java +10 −2 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ public class SurfaceView extends View { int mHeight = -1; int mFormat = -1; final Rect mSurfaceFrame = new Rect(); Rect mTmpDirty; int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; boolean mUpdateWindowNeeded; boolean mReportDrawNeeded; Loading Loading @@ -739,9 +740,16 @@ public class SurfaceView extends View { Canvas c = null; if (!mDrawingStopped && mWindow != null) { Rect frame = dirty != null ? dirty : mSurfaceFrame; if (dirty == null) { if (mTmpDirty == null) { mTmpDirty = new Rect(); } mTmpDirty.set(mSurfaceFrame); dirty = mTmpDirty; } try { c = mSurface.lockCanvas(frame); c = mSurface.lockCanvas(dirty); } catch (Exception e) { Log.e(LOG_TAG, "Exception locking surface", e); } Loading core/java/android/view/ViewRoot.java +1 −0 Original line number Diff line number Diff line Loading @@ -1082,6 +1082,7 @@ public final class ViewRoot extends Handler implements ViewParent, //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = mSurface; } mSurfaceHolder.setSurfaceFrameSize(mWidth, mHeight); mSurfaceHolder.mSurfaceLock.unlock(); if (mSurface.isValid()) { if (!hadSurface) { Loading core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +36 −22 Original line number Diff line number Diff line Loading @@ -88,9 +88,13 @@ public class ImageWallpaper extends WallpaperService { class WallpaperObserver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if (DEBUG) { Log.d(TAG, "onReceive"); } synchronized (mLock) { updateWallpaperLocked(); drawFrameLocked(true, false); drawFrameLocked(); } // Assume we are the only one using the wallpaper in this Loading @@ -101,6 +105,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onCreate(SurfaceHolder surfaceHolder) { if (DEBUG) { Log.d(TAG, "onCreate"); } super.onCreate(surfaceHolder); IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); mReceiver = new WallpaperObserver(); Loading @@ -120,9 +128,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void onVisibilityChanged(boolean visible) { if (DEBUG) { Log.d(TAG, "onVisibilityChanged: visible=" + visible); } synchronized (mLock) { if (mVisible != visible) { if (DEBUG) { Log.d(TAG, "Visibility changed to visible=" + visible); } mVisible = visible; drawFrameLocked(false, false); drawFrameLocked(); } } } Loading @@ -135,6 +152,12 @@ public class ImageWallpaper extends WallpaperService { public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixels, int yPixels) { if (DEBUG) { Log.d(TAG, "onOffsetsChanged: xOffset=" + xOffset + ", yOffset=" + yOffset + ", xOffsetStep=" + xOffsetStep + ", yOffsetStep=" + yOffsetStep + ", xPixels=" + xPixels + ", yPixels=" + yPixels); } synchronized (mLock) { if (mXOffset != xOffset || mYOffset != yOffset) { if (DEBUG) { Loading @@ -142,36 +165,27 @@ public class ImageWallpaper extends WallpaperService { } mXOffset = xOffset; mYOffset = yOffset; drawFrameLocked(false, true); } else { drawFrameLocked(false, false); mOffsetsChanged = true; } drawFrameLocked(); } } @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (DEBUG) { Log.d(TAG, "onSurfaceChanged: width=" + width + ", height=" + height); } super.onSurfaceChanged(holder, format, width, height); synchronized (mLock) { drawFrameLocked(true, false); } } @Override public void onSurfaceCreated(SurfaceHolder holder) { super.onSurfaceCreated(holder); mRedrawNeeded = true; drawFrameLocked(); } @Override public void onSurfaceDestroyed(SurfaceHolder holder) { super.onSurfaceDestroyed(holder); } void drawFrameLocked(boolean redrawNeeded, boolean offsetsChanged) { mRedrawNeeded |= redrawNeeded; mOffsetsChanged |= offsetsChanged; void drawFrameLocked() { if (!mVisible) { if (DEBUG) { Log.d(TAG, "Suppressed drawFrame since wallpaper is not visible."); Loading core/java/com/android/internal/view/BaseSurfaceHolder.java +17 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { int mType = -1; final Rect mSurfaceFrame = new Rect(); Rect mTmpDirty; public abstract void onUpdateSurface(); public abstract void onRelayoutContainer(); Loading Loading @@ -171,9 +172,16 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { Canvas c = null; if (onAllowLockCanvas()) { Rect frame = dirty != null ? dirty : mSurfaceFrame; if (dirty == null) { if (mTmpDirty == null) { mTmpDirty = new Rect(); } mTmpDirty.set(mSurfaceFrame); dirty = mTmpDirty; } try { c = mSurface.lockCanvas(frame); c = mSurface.lockCanvas(dirty); } catch (Exception e) { Log.e(TAG, "Exception locking surface", e); } Loading Loading @@ -215,4 +223,11 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { public Rect getSurfaceFrame() { return mSurfaceFrame; } public void setSurfaceFrameSize(int width, int height) { mSurfaceFrame.top = 0; mSurfaceFrame.left = 0; mSurfaceFrame.right = width; mSurfaceFrame.bottom = height; } }; Loading
core/java/android/service/wallpaper/WallpaperService.java +2 −1 Original line number Diff line number Diff line Loading @@ -547,6 +547,7 @@ public abstract class WallpaperService extends Service { mCurHeight = h; } mSurfaceHolder.setSurfaceFrameSize(w, h); mSurfaceHolder.mSurfaceLock.unlock(); if (!mSurfaceHolder.mSurface.isValid()) { Loading
core/java/android/view/SurfaceView.java +10 −2 Original line number Diff line number Diff line Loading @@ -158,6 +158,7 @@ public class SurfaceView extends View { int mHeight = -1; int mFormat = -1; final Rect mSurfaceFrame = new Rect(); Rect mTmpDirty; int mLastSurfaceWidth = -1, mLastSurfaceHeight = -1; boolean mUpdateWindowNeeded; boolean mReportDrawNeeded; Loading Loading @@ -739,9 +740,16 @@ public class SurfaceView extends View { Canvas c = null; if (!mDrawingStopped && mWindow != null) { Rect frame = dirty != null ? dirty : mSurfaceFrame; if (dirty == null) { if (mTmpDirty == null) { mTmpDirty = new Rect(); } mTmpDirty.set(mSurfaceFrame); dirty = mTmpDirty; } try { c = mSurface.lockCanvas(frame); c = mSurface.lockCanvas(dirty); } catch (Exception e) { Log.e(LOG_TAG, "Exception locking surface", e); } Loading
core/java/android/view/ViewRoot.java +1 −0 Original line number Diff line number Diff line Loading @@ -1082,6 +1082,7 @@ public final class ViewRoot extends Handler implements ViewParent, //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = mSurface; } mSurfaceHolder.setSurfaceFrameSize(mWidth, mHeight); mSurfaceHolder.mSurfaceLock.unlock(); if (mSurface.isValid()) { if (!hadSurface) { Loading
core/java/com/android/internal/service/wallpaper/ImageWallpaper.java +36 −22 Original line number Diff line number Diff line Loading @@ -88,9 +88,13 @@ public class ImageWallpaper extends WallpaperService { class WallpaperObserver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if (DEBUG) { Log.d(TAG, "onReceive"); } synchronized (mLock) { updateWallpaperLocked(); drawFrameLocked(true, false); drawFrameLocked(); } // Assume we are the only one using the wallpaper in this Loading @@ -101,6 +105,10 @@ public class ImageWallpaper extends WallpaperService { @Override public void onCreate(SurfaceHolder surfaceHolder) { if (DEBUG) { Log.d(TAG, "onCreate"); } super.onCreate(surfaceHolder); IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); mReceiver = new WallpaperObserver(); Loading @@ -120,9 +128,18 @@ public class ImageWallpaper extends WallpaperService { @Override public void onVisibilityChanged(boolean visible) { if (DEBUG) { Log.d(TAG, "onVisibilityChanged: visible=" + visible); } synchronized (mLock) { if (mVisible != visible) { if (DEBUG) { Log.d(TAG, "Visibility changed to visible=" + visible); } mVisible = visible; drawFrameLocked(false, false); drawFrameLocked(); } } } Loading @@ -135,6 +152,12 @@ public class ImageWallpaper extends WallpaperService { public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixels, int yPixels) { if (DEBUG) { Log.d(TAG, "onOffsetsChanged: xOffset=" + xOffset + ", yOffset=" + yOffset + ", xOffsetStep=" + xOffsetStep + ", yOffsetStep=" + yOffsetStep + ", xPixels=" + xPixels + ", yPixels=" + yPixels); } synchronized (mLock) { if (mXOffset != xOffset || mYOffset != yOffset) { if (DEBUG) { Loading @@ -142,36 +165,27 @@ public class ImageWallpaper extends WallpaperService { } mXOffset = xOffset; mYOffset = yOffset; drawFrameLocked(false, true); } else { drawFrameLocked(false, false); mOffsetsChanged = true; } drawFrameLocked(); } } @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (DEBUG) { Log.d(TAG, "onSurfaceChanged: width=" + width + ", height=" + height); } super.onSurfaceChanged(holder, format, width, height); synchronized (mLock) { drawFrameLocked(true, false); } } @Override public void onSurfaceCreated(SurfaceHolder holder) { super.onSurfaceCreated(holder); mRedrawNeeded = true; drawFrameLocked(); } @Override public void onSurfaceDestroyed(SurfaceHolder holder) { super.onSurfaceDestroyed(holder); } void drawFrameLocked(boolean redrawNeeded, boolean offsetsChanged) { mRedrawNeeded |= redrawNeeded; mOffsetsChanged |= offsetsChanged; void drawFrameLocked() { if (!mVisible) { if (DEBUG) { Log.d(TAG, "Suppressed drawFrame since wallpaper is not visible."); Loading
core/java/com/android/internal/view/BaseSurfaceHolder.java +17 −2 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { int mType = -1; final Rect mSurfaceFrame = new Rect(); Rect mTmpDirty; public abstract void onUpdateSurface(); public abstract void onRelayoutContainer(); Loading Loading @@ -171,9 +172,16 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { Canvas c = null; if (onAllowLockCanvas()) { Rect frame = dirty != null ? dirty : mSurfaceFrame; if (dirty == null) { if (mTmpDirty == null) { mTmpDirty = new Rect(); } mTmpDirty.set(mSurfaceFrame); dirty = mTmpDirty; } try { c = mSurface.lockCanvas(frame); c = mSurface.lockCanvas(dirty); } catch (Exception e) { Log.e(TAG, "Exception locking surface", e); } Loading Loading @@ -215,4 +223,11 @@ public abstract class BaseSurfaceHolder implements SurfaceHolder { public Rect getSurfaceFrame() { return mSurfaceFrame; } public void setSurfaceFrameSize(int width, int height) { mSurfaceFrame.top = 0; mSurfaceFrame.left = 0; mSurfaceFrame.right = width; mSurfaceFrame.bottom = height; } };