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

Commit d3f717c7 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Fixing flakiness in shape detection" into ub-launcher3-edmonton

parents bea26c15 6275b0ae
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class IconNormalizer {
    private final float[] mLeftBorder;
    private final float[] mRightBorder;
    private final Rect mBounds;
    private final Path mShapePath;
    private final Matrix mMatrix;

    private final Paint mPaintIcon;
@@ -116,6 +117,7 @@ public class IconNormalizer {
        mPaintMaskShapeOutline.setColor(Color.BLACK);
        mPaintMaskShapeOutline.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));

        mShapePath = new Path();
        mMatrix = new Matrix();
        mAdaptiveIconScale = SCALE_NOT_INITIALIZED;
    }
@@ -146,13 +148,13 @@ public class IconNormalizer {
        mMatrix.reset();
        mMatrix.setScale(mBounds.width(), mBounds.height());
        mMatrix.postTranslate(mBounds.left, mBounds.top);
        maskPath.transform(mMatrix);
        maskPath.transform(mMatrix, mShapePath);

        // XOR operation
        mCanvasARGB.drawPath(maskPath, mPaintMaskShape);
        mCanvasARGB.drawPath(mShapePath, mPaintMaskShape);

        // DST_OUT operation around the mask path outline
        mCanvasARGB.drawPath(maskPath, mPaintMaskShapeOutline);
        mCanvasARGB.drawPath(mShapePath, mPaintMaskShapeOutline);

        // Check if the result is almost transparent
        return isTransparentBitmap(mBitmapARGB);