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

Commit 7c051727 authored by Alan Viverette's avatar Alan Viverette
Browse files

Fix getOutline() in ripple and layer drawables

BUG: 16134862
Change-Id: Ibcef20fc154ecc342344770f96fbd3d77d6fad26
parent 5e458dd6
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -566,13 +566,24 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
    }

    /**
     * Builds an Outline from the first child Drawable, if present.
     * Populates <code>outline</code> with the first available layer outline.
     * Returns <code>true</code> if an outline is available, <code>false</code>
     * otherwise.
     *
     * @param outline Outline in which to place the first available layer outline
     * @return <code>true</code> if an outline is available
     */
    @Override
    public boolean getOutline(@NonNull Outline outline) {
        if (mLayerState.mNum < 1) return false;
        final Drawable firstChild = mLayerState.mChildren[0].mDrawable;
        return firstChild.getOutline(outline);
        final LayerState state = mLayerState;
        final ChildDrawable[] children = state.mChildren;
        final int N = state.mNum;
        for (int i = 0; i < N; i++) {
            if (children[i].mDrawable.getOutline(outline)) {
                return true;
            }
        }
        return false;
    }

    @Override
+23 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff.Mode;
@@ -497,8 +498,29 @@ public class RippleDrawable extends LayerDrawable {
        }
    }

    /**
     * Populates <code>outline</code> with the first available layer outline,
     * excluding the mask layer. Returns <code>true</code> if an outline is
     * available, <code>false</code> otherwise.
     *
     * @param outline Outline in which to place the first available layer outline
     * @return <code>true</code> if an outline is available
     */
    @Override
    public boolean getOutline(@NonNull Outline outline) {
        final LayerState state = mLayerState;
        final ChildDrawable[] children = state.mChildren;
        final int N = state.mNum;
        for (int i = 0; i < N; i++) {
            if (children[i].mId != R.id.mask && children[i].mDrawable.getOutline(outline)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public void draw(Canvas canvas) {
    public void draw(@NonNull Canvas canvas) {
        final boolean isProjected = isProjected();
        final boolean hasMask = mMask != null;
        final boolean drawNonMaskContent = mLayerState.mNum > (hasMask ? 1 : 0);