Merge "Only cache mini bitmap wallpaper when there are widgets" into sc-v2-dev
This commit is contained in:
@@ -127,7 +127,12 @@ public class ImageWallpaper extends WallpaperService {
|
|||||||
setFixedSizeAllowed(true);
|
setFixedSizeAllowed(true);
|
||||||
updateSurfaceSize();
|
updateSurfaceSize();
|
||||||
|
|
||||||
mRenderer.setOnBitmapChanged(this::updateMiniBitmap);
|
mRenderer.setOnBitmapChanged(b -> {
|
||||||
|
mLocalColorsToAdd.addAll(mColorAreas);
|
||||||
|
if (mLocalColorsToAdd.size() > 0) {
|
||||||
|
updateMiniBitmapAndNotify(b);
|
||||||
|
}
|
||||||
|
});
|
||||||
getDisplayContext().getSystemService(DisplayManager.class)
|
getDisplayContext().getSystemService(DisplayManager.class)
|
||||||
.registerDisplayListener(this, mWorker.getThreadHandler());
|
.registerDisplayListener(this, mWorker.getThreadHandler());
|
||||||
Trace.endSection();
|
Trace.endSection();
|
||||||
@@ -171,7 +176,7 @@ public class ImageWallpaper extends WallpaperService {
|
|||||||
computeAndNotifyLocalColors(new ArrayList<>(mColorAreas), mMiniBitmap));
|
computeAndNotifyLocalColors(new ArrayList<>(mColorAreas), mMiniBitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMiniBitmap(Bitmap b) {
|
private void updateMiniBitmapAndNotify(Bitmap b) {
|
||||||
if (b == null) return;
|
if (b == null) return;
|
||||||
int size = Math.min(b.getWidth(), b.getHeight());
|
int size = Math.min(b.getWidth(), b.getHeight());
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
@@ -233,6 +238,9 @@ public class ImageWallpaper extends WallpaperService {
|
|||||||
Bitmap bitmap = mMiniBitmap;
|
Bitmap bitmap = mMiniBitmap;
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
mLocalColorsToAdd.addAll(regions);
|
mLocalColorsToAdd.addAll(regions);
|
||||||
|
mRenderer.use(b -> {
|
||||||
|
updateMiniBitmapAndNotify(b);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
computeAndNotifyLocalColors(regions, bitmap);
|
computeAndNotifyLocalColors(regions, bitmap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer {
|
|||||||
mOnBitmapUpdated = c;
|
mOnBitmapUpdated = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void use(Consumer<Bitmap> c) {
|
||||||
|
mTexture.use(c);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWcgContent() {
|
public boolean isWcgContent() {
|
||||||
return mTexture.isWcgContent();
|
return mTexture.isWcgContent();
|
||||||
|
|||||||
Reference in New Issue
Block a user