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

Commit f6637d66 authored by chaviw's avatar chaviw
Browse files

Adjust animation final crop bounds so it's in screen space.

The final crop bounds for animations should use the screen space bounds
instead of stack bounds. Adjust the bounds so they're offset by the
stack position.

Test: WindowAnimationSpec#testApply_clipAfterOffsetPosition
Change-Id: Ibfda5ab505ee3206175e5f59e82f1c16f78d19c4
Fixes: 71619195
parent 03033385
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -89,7 +89,10 @@ public class WindowAnimationSpec implements AnimationSpec {
        if (mStackClipMode == STACK_CLIP_NONE) {
            t.setWindowCrop(leash, tmp.transformation.getClipRect());
        } else if (mStackClipMode == STACK_CLIP_AFTER_ANIM) {
            t.setFinalCrop(leash, mStackBounds);
            mTmpRect.set(mStackBounds);
            // Offset stack bounds to stack position so the final crop is in screen space.
            mTmpRect.offsetTo(mPosition.x, mPosition.y);
            t.setFinalCrop(leash, mTmpRect);
            t.setWindowCrop(leash, tmp.transformation.getClipRect());
        } else {
            mTmpRect.set(mStackBounds);
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import android.graphics.Point;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.support.test.filters.SmallTest;
@@ -71,6 +72,19 @@ public class WindowAnimationSpecTest {
                argThat(rect -> rect.equals(mStackBounds)));
    }

    @Test
    public void testApply_clipAfterOffsetPosition() {
        // Stack bounds is (0, 0, 10, 10) position is (20, 40)
        WindowAnimationSpec windowAnimationSpec = new WindowAnimationSpec(mAnimation,
                new Point(20, 40), mStackBounds, false /* canSkipFirstFrame */,
                STACK_CLIP_AFTER_ANIM);
        windowAnimationSpec.apply(mTransaction, mSurfaceControl, 0);
        verify(mTransaction).setWindowCrop(eq(mSurfaceControl), argThat(Rect::isEmpty));
        verify(mTransaction).setFinalCrop(eq(mSurfaceControl),
                argThat(rect -> rect.left == 20 && rect.top == 40 && rect.right == 30
                        && rect.bottom == 50));
    }

    @Test
    public void testApply_clipBeforeNoAnimationBounds() {
        // Stack bounds is (0, 0, 10, 10) animation clip is (0, 0, 0, 0)