Load and draw bitmap only once with ImageWallpaper
Given that ImageWallpaper uses surface.SetFixedSize with the dimensions of the image, and that WallpaperController moves the without redrawing the bitmap (e.g. in case of rotation/unfold), the bitmap only needs to be drawn once (in theory). Bug: 288582051 Bug: 265018814 Test: manual on foldable: fold, unfold, rotate, with one or two ImageWallpaper engines Test: atest ImageWallpaperTest Change-Id: I1a61c5d30c5f4d6abff4eac76195b74dfb18fe6f
This commit is contained in:
@@ -109,6 +109,7 @@ public class ImageWallpaper extends WallpaperService {
|
||||
private WallpaperManager mWallpaperManager;
|
||||
private final WallpaperLocalColorExtractor mWallpaperLocalColorExtractor;
|
||||
private SurfaceHolder mSurfaceHolder;
|
||||
private boolean mDrawn = false;
|
||||
@VisibleForTesting
|
||||
static final int MIN_SURFACE_WIDTH = 128;
|
||||
@VisibleForTesting
|
||||
@@ -238,6 +239,7 @@ public class ImageWallpaper extends WallpaperService {
|
||||
|
||||
private void drawFrameSynchronized() {
|
||||
synchronized (mLock) {
|
||||
if (mDrawn) return;
|
||||
drawFrameInternal();
|
||||
}
|
||||
}
|
||||
@@ -275,6 +277,7 @@ public class ImageWallpaper extends WallpaperService {
|
||||
Rect dest = mSurfaceHolder.getSurfaceFrame();
|
||||
try {
|
||||
canvas.drawBitmap(bitmap, null, dest, null);
|
||||
mDrawn = true;
|
||||
} finally {
|
||||
surface.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user