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

Commit 937257ff authored by Pechetty Sravani (xWF)'s avatar Pechetty Sravani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Updating FastBitmapDrawable to store BitmapInfo instead ..."

Revert submission 31445615-model-callbacks

Reason for revert: <Droidmonitor crested revert due to b/393222548. Will be verified through ABTD for stanadard investigation.>

Reverted changes: /q/submissionid:31445615-model-callbacks

Change-Id: I207f343fbe2f9068167becbbfea65f71e8b68ddd
parent 275681c5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ public class BitmapInfo {

    public static final String TAG = "BitmapInfo";

    @NonNull
    public final Bitmap icon;
    public final int color;

@@ -73,7 +72,7 @@ public class BitmapInfo {

    private BitmapInfo badgeInfo;

    public BitmapInfo(@NonNull Bitmap icon, int color) {
    public BitmapInfo(Bitmap icon, int color) {
        this.icon = icon;
        this.color = color;
    }
+5 −5
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
                return super.newIcon(context, creationFlags);
            }
            ClockIconDrawable.ClockConstantState cs = new ClockIconDrawable.ClockConstantState(
                    this, themedFgColor, boundsOffset, info, bg, bgFilter);
                    icon, color, themedFgColor, boundsOffset, info, bg, bgFilter);
            FastBitmapDrawable d = cs.newDrawable();
            applyFlags(context, d, creationFlags);
            return d;
@@ -341,7 +341,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
        private final float mCanvasScale;

        ClockIconDrawable(ClockConstantState cs) {
            super(cs.mBitmapInfo);
            super(cs.mBitmap, cs.mIconColor);
            mBoundsOffset = cs.mBoundsOffset;
            mAnimInfo = cs.mAnimInfo;

@@ -447,7 +447,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap

        @Override
        public FastBitmapConstantState newConstantState() {
            return new ClockConstantState(mBitmapInfo, mThemedFgColor, mBoundsOffset,
            return new ClockConstantState(mBitmap, mIconColor, mThemedFgColor, mBoundsOffset,
                    mAnimInfo, mBG, mBgPaint.getColorFilter());
        }

@@ -459,9 +459,9 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
            private final ColorFilter mBgFilter;
            private final int mThemedFgColor;

            ClockConstantState(BitmapInfo info, int themedFgColor,
            ClockConstantState(Bitmap bitmap, int color, int themedFgColor,
                    float boundsOffset, AnimationInfo animInfo, Bitmap bg, ColorFilter bgFilter) {
                super(info);
                super(bitmap, color);
                mBoundsOffset = boundsOffset;
                mAnimInfo = animInfo;
                mBG = bg;
+18 −25
Original line number Diff line number Diff line
@@ -65,7 +65,8 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
    private static boolean sFlagHoverEnabled = false;

    protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
    public final BitmapInfo mBitmapInfo;
    protected final Bitmap mBitmap;
    protected final int mIconColor;

    @Nullable private ColorFilter mColorFilter;

@@ -98,24 +99,18 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {

    private boolean mHoverScaleEnabledForDisplay = true;

    protected FastBitmapDrawable(Bitmap b, int iconColor) {
        this(BitmapInfo.of(b, iconColor));
    }

    public FastBitmapDrawable(Bitmap b) {
        this(BitmapInfo.fromBitmap(b));
        this(b, Color.TRANSPARENT);
    }

    public FastBitmapDrawable(BitmapInfo info) {
        mBitmapInfo = info;
        setFilterBitmap(true);
        this(info.icon, info.color);
    }

    /**
     * Returns true if the drawable points to the same bitmap icon object
     */
    public boolean isSameInfo(BitmapInfo info) {
        return mBitmapInfo == info;
    protected FastBitmapDrawable(Bitmap b, int iconColor) {
        mBitmap = b;
        mIconColor = iconColor;
        setFilterBitmap(true);
    }

    @Override
@@ -150,7 +145,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
    }

    protected void drawInternal(Canvas canvas, Rect bounds) {
        canvas.drawBitmap(mBitmapInfo.icon, null, bounds, mPaint);
        canvas.drawBitmap(mBitmap, null, bounds, mPaint);
    }

    /**
@@ -158,7 +153,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
     */
    public int getIconColor() {
        int whiteScrim = setColorAlphaBound(Color.WHITE, WHITE_SCRIM_ALPHA);
        return ColorUtils.compositeColors(whiteScrim, mBitmapInfo.color);
        return ColorUtils.compositeColors(whiteScrim, mIconColor);
    }

    /**
@@ -225,12 +220,12 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {

    @Override
    public int getIntrinsicWidth() {
        return mBitmapInfo.icon.getWidth();
        return mBitmap.getWidth();
    }

    @Override
    public int getIntrinsicHeight() {
        return mBitmapInfo.icon.getHeight();
        return mBitmap.getHeight();
    }

    @Override
@@ -338,7 +333,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
    }

    protected FastBitmapConstantState newConstantState() {
        return new FastBitmapConstantState(mBitmapInfo);
        return new FastBitmapConstantState(mBitmap, mIconColor);
    }

    @Override
@@ -428,7 +423,8 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
    }

    public static class FastBitmapConstantState extends ConstantState {
        protected final BitmapInfo mBitmapInfo;
        protected final Bitmap mBitmap;
        protected final int mIconColor;

        // These are initialized later so that subclasses don't need to
        // pass everything in constructor
@@ -438,15 +434,12 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback {
        @DrawableCreationFlags int mCreationFlags = 0;

        public FastBitmapConstantState(Bitmap bitmap, int color) {
            this(BitmapInfo.of(bitmap, color));
        }

        public FastBitmapConstantState(BitmapInfo info) {
            mBitmapInfo = info;
            mBitmap = bitmap;
            mIconColor = color;
        }

        protected FastBitmapDrawable createDrawable() {
            return new FastBitmapDrawable(mBitmapInfo);
            return new FastBitmapDrawable(mBitmap, mIconColor);
        }

        @Override
+6 −5
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ import com.android.launcher3.icons.R

/** Class to handle monochrome themed app icons */
class ThemedIconDrawable(constantState: ThemedConstantState) :
    FastBitmapDrawable(constantState.getBitmapInfo()) {
    FastBitmapDrawable(constantState.getBitmap(), constantState.colorFg) {
    val bitmapInfo = constantState.bitmapInfo
    private val colorFg = constantState.colorFg
    private val colorBg = constantState.colorBg

@@ -65,21 +66,21 @@ class ThemedIconDrawable(constantState: ThemedConstantState) :
    override fun isThemed() = true

    override fun newConstantState() =
        ThemedConstantState(mBitmapInfo, monoIcon, bgBitmap, colorBg, colorFg)
        ThemedConstantState(bitmapInfo, monoIcon, bgBitmap, colorBg, colorFg)

    override fun getIconColor() = colorFg

    class ThemedConstantState(
        bitmapInfo: BitmapInfo,
        val bitmapInfo: BitmapInfo,
        val mono: Bitmap,
        val whiteShadowLayer: Bitmap,
        val colorBg: Int,
        val colorFg: Int,
    ) : FastBitmapConstantState(bitmapInfo) {
    ) : FastBitmapConstantState(bitmapInfo.icon, bitmapInfo.color) {

        public override fun createDrawable() = ThemedIconDrawable(this)

        fun getBitmapInfo(): BitmapInfo = mBitmapInfo
        fun getBitmap(): Bitmap = mBitmap
    }

    companion object {