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

Commit 2e91e0e0 authored by George Mount's avatar George Mount
Browse files

Fixed EdgeEffect drawn on non-RecordingCanvas

Fixes: 183079166

When the EdgeEffect was drawn on a non-RecordingCanvas, the
animation was never completed when using TYPE_STRETCH. Because
TYPE_STRETCH can only be applied to RecordingCanvas, the
animation ends immediately when drawn on a non-RecordingCanvas.

Test: manual, I53d59a3b3cd14be658d899ff41c1fa4b83a98a32
Change-Id: I29c04ff7e0aa3269c1b4e9e503dfa641195820a8
parent e0f61653
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -640,6 +640,12 @@ public class EdgeEffect {
                    mWidth,
                    mHeight
            );
        } else {
            // This is TYPE_STRETCH and drawing into a Canvas that isn't a Recording Canvas,
            // so no effect can be shown. Just end the effect.
            mState = STATE_IDLE;
            mDistance = 0;
            mVelocity = 0;
        }

        boolean oneLastFrame = false;
@@ -771,8 +777,9 @@ public class EdgeEffect {
     * considered at rest or false if it is still animating.
     */
    private boolean isAtEquilibrium() {
        double displacement = mDistance * mHeight; // in pixels
        return Math.abs(mVelocity) < VELOCITY_THRESHOLD
        double displacement = mDistance * mHeight * LINEAR_STRETCH_INTENSITY; // in pixels
        double velocity = mVelocity * LINEAR_STRETCH_INTENSITY;
        return Math.abs(velocity) < VELOCITY_THRESHOLD
                && Math.abs(displacement) < VALUE_THRESHOLD;
    }