Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cd7cc41 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Load wallpaper bitmap once instead of twice" into sc-dev am: 6d21beab am: aa61cd5d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14985019

Change-Id: I18472a99e6d5bf84ccdcf8092bef08a27edf0946
parents 013c419f aa61cd5d
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -130,10 +130,7 @@ public class ImageWallpaper extends WallpaperService {
                    .getBounds();
            mHeight = window.height();
            mWidth = window.width();
            mMiniBitmap = null;
            if (mWorker != null && mWorker.getThreadHandler() != null) {
                mWorker.getThreadHandler().post(this::updateMiniBitmap);
            }
            mRenderer.setOnBitmapChanged(this::updateMiniBitmap);
        }

        EglHelper getEglHelperInstance() {
@@ -177,8 +174,8 @@ public class ImageWallpaper extends WallpaperService {
            mPageOffset = (1 - imgWidth) / (float) (mPages - 1);
        }

        private void updateMiniBitmap() {
            mRenderer.useBitmap(b -> {
        private void updateMiniBitmap(Bitmap b) {
            if (b == null) return;
            int size = Math.min(b.getWidth(), b.getHeight());
            float scale = 1.0f;
            if (size > MIN_SURFACE_WIDTH) {
@@ -190,7 +187,6 @@ public class ImageWallpaper extends WallpaperService {
                    (int) Math.max(scale * b.getHeight(), 1), false);
            computeAndNotifyLocalColors(mLocalColorsToAdd, mMiniBitmap);
            mLocalColorsToAdd.clear();
            });
        }

        private void updateSurfaceSize() {
+5 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer {
    private final ImageGLWallpaper mWallpaper;
    private final Rect mSurfaceSize = new Rect();
    private final WallpaperTexture mTexture;
    private Consumer<Bitmap> mOnBitmapUpdated;

    public ImageWallpaperRenderer(Context context) {
        final WallpaperManager wpm = context.getSystemService(WallpaperManager.class);
@@ -60,10 +61,9 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer {

    /**
     * @hide
     * @return
     */
    public void useBitmap(Consumer<Bitmap> c) {
        mTexture.use(c);
    public void setOnBitmapChanged(Consumer<Bitmap> c) {
        mOnBitmapUpdated = c;
    }

    @Override
@@ -80,6 +80,8 @@ public class ImageWallpaperRenderer implements GLWallpaperRenderer {
        mTexture.use(bitmap -> {
            if (bitmap == null) {
                Log.w(TAG, "reload texture failed!");
            } else if (mOnBitmapUpdated != null) {
                mOnBitmapUpdated.accept(bitmap);
            }
            mWallpaper.setup(bitmap);
        });