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

Commit 1d34c94a authored by Shamali Patwa's avatar Shamali Patwa Committed by Android (Google) Code Review
Browse files

Merge "Update the scale on corner radii on scaled image drawable." into main

parents 9b23494c 223bdfb0
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);
    }