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

Commit 223bdfb0 authored by Shamali P's avatar Shamali P
Browse files

Update the scale on corner radii on scaled image drawable.

The RoundedDrawableWrapper applies rounded corners on each draw, so,
on scaling, the corners look odd for small widgets.

This change, applies the same scale to corner radius as well.
There are some widgets whose preview images have embedded transparency,
but we don't do much for such previews.

Bug: 359860747
Test: Manual
Flag: EXEMPT bugfix
Change-Id: Idbc3950fa96da07047a9b15db105f58367375a2c
parent f405ea09
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -31,18 +31,27 @@ public class RoundDrawableWrapper extends DrawableWrapper {
    private final RectF mTempRect = new RectF();
    private final Path mClipPath = new Path();
    private final float mRoundedCornersRadius;
    private float mScaledCornerRadius;

    public RoundDrawableWrapper(Drawable dr, float radius) {
        super(dr);
        mRoundedCornersRadius = radius;
        mScaledCornerRadius = mRoundedCornersRadius;
    }

    /**
     * Sets the scaling to be applied to the corner radius when it draws next time.
     */
    public void setCornerRadiusScale(float scale) {
        mScaledCornerRadius = Math.round(mRoundedCornersRadius * scale);
    }

    @Override
    protected void onBoundsChange(Rect bounds) {
        mTempRect.set(getBounds());
        mClipPath.reset();
        mClipPath.addRoundRect(mTempRect, mRoundedCornersRadius,
                mRoundedCornersRadius, Path.Direction.CCW);
        mClipPath.addRoundRect(mTempRect, mScaledCornerRadius, mScaledCornerRadius,
                Path.Direction.CCW);
        super.onBoundsChange(bounds);
    }