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

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

Use RoundRect clipping for circle reveal animation

bug:16630975

Also, remove inverse clipping feature from reveal animator.

Change-Id: I770a4eb48cd123b0ca0f39d16a0f3eefd1be3653
parent 3d1856f4
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ public class RevealAnimator extends ValueAnimator {

    private View mClipView;
    private int mX, mY;
    private boolean mInverseClip;
    private float mStartRadius, mEndRadius;
    private float mDelta;
    private boolean mMayRunAsync;
@@ -41,14 +40,13 @@ public class RevealAnimator extends ValueAnimator {
    private RenderNodeAnimator mRtAnimator;

    public RevealAnimator(View clipView, int x, int y,
            float startRadius, float endRadius, boolean inverseClip) {
            float startRadius, float endRadius) {
        mClipView = clipView;
        mStartRadius = startRadius;
        mEndRadius = endRadius;
        mDelta = endRadius - startRadius;
        mX = x;
        mY = y;
        mInverseClip = inverseClip;
        super.setValues(PropertyValuesHolder.ofFloat("radius", startRadius, endRadius));
    }

@@ -57,12 +55,12 @@ public class RevealAnimator extends ValueAnimator {
        super.animateValue(fraction);
        fraction = getAnimatedFraction();
        float radius = mStartRadius + (mDelta * fraction);
        mClipView.setRevealClip(true, mInverseClip, mX, mY, radius);
        mClipView.setRevealClip(true, mX, mY, radius);
    }

    @Override
    protected void endAnimation(AnimationHandler handler) {
        mClipView.setRevealClip(false, false, 0, 0, 0);
        mClipView.setRevealClip(false, 0, 0, 0);
        super.endAnimation(handler);
    }

@@ -92,7 +90,7 @@ public class RevealAnimator extends ValueAnimator {
            mRtAnimator = null;
        }
        if (canRunAsync()) {
            mRtAnimator = new RenderNodeAnimator(mX, mY, mInverseClip, mStartRadius, mEndRadius);
            mRtAnimator = new RenderNodeAnimator(mX, mY, mStartRadius, mEndRadius);
            mRtAnimator.setDuration(getDuration());
            mRtAnimator.setInterpolator(getInterpolator());
            mRtAnimator.setTarget(mClipView);
+3 −3
Original line number Diff line number Diff line
@@ -378,9 +378,9 @@ public class RenderNode {
    /**
     * Controls the RenderNode's circular reveal clip.
     */
    public boolean setRevealClip(boolean shouldClip, boolean inverseClip,
    public boolean setRevealClip(boolean shouldClip,
            float x, float y, float radius) {
        return nSetRevealClip(mNativeRenderNode, shouldClip, inverseClip, x, y, radius);
        return nSetRevealClip(mNativeRenderNode, shouldClip, x, y, radius);
    }

    /**
@@ -855,7 +855,7 @@ public class RenderNode {
    private static native boolean nSetOutlineNone(long renderNode);
    private static native boolean nSetClipToOutline(long renderNode, boolean clipToOutline);
    private static native boolean nSetRevealClip(long renderNode,
            boolean shouldClip, boolean inverseClip, float x, float y, float radius);
            boolean shouldClip, float x, float y, float radius);
    private static native boolean nSetAlpha(long renderNode, float alpha);
    private static native boolean nSetHasOverlappingRendering(long renderNode,
            boolean hasOverlappingRendering);
+4 −5
Original line number Diff line number Diff line
@@ -125,10 +125,9 @@ public class RenderNodeAnimator extends Animator {
                property.getNativeContainer(), paintField, finalValue));
    }

    public RenderNodeAnimator(int x, int y, boolean inverseClip,
            float startRadius, float endRadius) {
        init(nCreateRevealAnimator(new WeakReference<>(this),
                x, y, inverseClip, startRadius, endRadius));
    public RenderNodeAnimator(int x, int y, float startRadius, float endRadius) {
        init(nCreateRevealAnimator(new WeakReference<RenderNodeAnimator>(this),
                x, y, startRadius, endRadius));
    }

    private void init(long ptr) {
@@ -333,7 +332,7 @@ public class RenderNodeAnimator extends Animator {
    private static native long nCreateCanvasPropertyPaintAnimator(WeakReference<RenderNodeAnimator> weakThis,
            long canvasProperty, int paintField, float finalValue);
    private static native long nCreateRevealAnimator(WeakReference<RenderNodeAnimator> weakThis,
            int x, int y, boolean inverseClip, float startRadius, float endRadius);
            int x, int y, float startRadius, float endRadius);

    private static native void nSetStartValue(long nativePtr, float startValue);
    private static native void nSetDuration(long nativePtr, long duration);
+3 −8
Original line number Diff line number Diff line
@@ -10845,14 +10845,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        invalidateViewProperty(false, false);
    }
    /**
     * Private API to be used for reveal animation
     *
     * @hide
     */
    public void setRevealClip(boolean shouldClip, boolean inverseClip,
            float x, float y, float radius) {
        mRenderNode.setRevealClip(shouldClip, inverseClip, x, y, radius);
    /** @hide */
    public void setRevealClip(boolean shouldClip, float x, float y, float radius) {
        mRenderNode.setRevealClip(shouldClip, x, y, radius);
        invalidateViewProperty(false, false);
    }
+1 −1
Original line number Diff line number Diff line
@@ -38,6 +38,6 @@ public final class ViewAnimationUtils {
     */
    public static final Animator createCircularReveal(View view,
            int centerX,  int centerY, float startRadius, float endRadius) {
        return new RevealAnimator(view, centerX, centerY, startRadius, endRadius, false);
        return new RevealAnimator(view, centerX, centerY, startRadius, endRadius);
    }
}
Loading