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

Commit f3dc7ac7 authored by Chris Craik's avatar Chris Craik
Browse files

Correct GradientDrawable outline alpha computation

bug:26066107

GradientDrawable should provide a shadow casting outline if using a
translucent fill.

Change-Id: Ie6b409bafe3fcf9c5216662168d7349e2a9e3413
parent 79aeb92f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1636,8 +1636,14 @@ public class GradientDrawable extends Drawable {
    public void getOutline(Outline outline) {
        final GradientState st = mGradientState;
        final Rect bounds = getBounds();
        // only report non-zero alpha if shape being drawn is opaque
        outline.setAlpha(st.mOpaqueOverShape && isOpaqueForState() ? (mAlpha / 255.0f) : 0.0f);
        // only report non-zero alpha if shape being drawn has consistent opacity over shape. Must
        // either not have a stroke, or have same stroke/fill opacity
        boolean useFillOpacity = st.mOpaqueOverShape && (mGradientState.mStrokeWidth <= 0
                || mStrokePaint == null
                || mStrokePaint.getAlpha() == mFillPaint.getAlpha());
        outline.setAlpha(useFillOpacity
                ? modulateAlpha(mFillPaint.getAlpha()) / 255.0f
                : 0.0f);

        switch (st.mShape) {
            case RECTANGLE: