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

Commit 0bafe890 authored by Shawn Lin's avatar Shawn Lin Committed by Automerger Merge Worker
Browse files

Merge "Fixed incorrect size and position of a snapshot starting window in...

Merge "Fixed incorrect size and position of a snapshot starting window in waterfall device." into rvc-dev am: ae4f1360

Change-Id: Ib2b771aaa7465b68c8d23fe099cc401b87122d7a
parents fa422e8d ae4f1360
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ class TaskSnapshotSurface implements StartingSurface {
                    = topFullscreenOpaqueWindow.mAttrs.insetsFlags.behavior;
            layoutParams.insetsFlags.appearance
                    = topFullscreenOpaqueWindow.mAttrs.insetsFlags.appearance;
            layoutParams.layoutInDisplayCutoutMode = attrs.layoutInDisplayCutoutMode;
            layoutParams.setFitInsetsTypes(attrs.getFitInsetsTypes());
            layoutParams.setFitInsetsSides(attrs.getFitInsetsSides());
            layoutParams.setFitInsetsIgnoringVisibility(attrs.isFitInsetsIgnoringVisibility());
@@ -374,15 +375,15 @@ class TaskSnapshotSurface implements StartingSurface {
            frame = calculateSnapshotFrame(crop);
            mTransaction.setWindowCrop(mChildSurfaceControl, crop);
            mTransaction.setPosition(mChildSurfaceControl, frame.left, frame.top);
            mTmpSnapshotSize.set(crop);
            mTmpDstFrame.set(frame);
        } else {
            frame = null;
            mTmpSnapshotSize.set(0, 0, buffer.getWidth(), buffer.getHeight());
            mTmpDstFrame.set(mFrame);
        }
        mTmpDstFrame.offsetTo(0, 0);

        // Scale the mismatch dimensions to fill the task bounds
        mTmpSnapshotSize.set(0, 0, buffer.getWidth(), buffer.getHeight());
        mSnapshotMatrix.setRectToRect(mTmpSnapshotSize, mTmpDstFrame, Matrix.ScaleToFit.FILL);
        mTransaction.setMatrix(mChildSurfaceControl, mSnapshotMatrix, mTmpFloat9);

@@ -435,16 +436,11 @@ class TaskSnapshotSurface implements StartingSurface {
                (float) mSnapshot.getSnapshot().getHeight() / mSnapshot.getTaskSize().y;

        // Rescale the frame from snapshot to window coordinate space
        final Rect frame = new Rect(
                (int) (crop.left / scaleX + 0.5f),
                (int) (crop.top / scaleY + 0.5f),
                (int) (crop.right / scaleX + 0.5f),
                (int) (crop.bottom / scaleY + 0.5f)
        final Rect frame = new Rect(0, 0,
                (int) (crop.width() / scaleX + 0.5f),
                (int) (crop.height() / scaleY + 0.5f)
        );

        // By default, offset it to to top/left corner
        frame.offsetTo((int) (-crop.left / scaleX), (int) (-crop.top / scaleY));

        // However, we also need to make space for the navigation bar on the left side.
        final int colorViewLeftInset = getColorViewLeftInset(mStableInsets.left,
                mContentInsets.left);
+17 −2
Original line number Diff line number Diff line
@@ -180,12 +180,18 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
        assertEquals(new Rect(0, 0, 90, 100), mSurface.calculateSnapshotCrop());
    }

    @Test
    public void testCalculateSnapshotCrop_waterfall() {
        setupSurface(100, 100, new Rect(5, 10, 5, 10), 0, 0, new Rect(0, 0, 100, 100));
        assertEquals(new Rect(5, 0, 95, 90), mSurface.calculateSnapshotCrop());
    }

    @Test
    public void testCalculateSnapshotFrame() {
        setupSurface(100, 100);
        final Rect insets = new Rect(0, 10, 0, 10);
        mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
        assertEquals(new Rect(0, -10, 100, 70),
        assertEquals(new Rect(0, 0, 100, 80),
                mSurface.calculateSnapshotFrame(new Rect(0, 10, 100, 90)));
    }

@@ -194,10 +200,19 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
        setupSurface(100, 100);
        final Rect insets = new Rect(10, 10, 0, 0);
        mSurface.setFrames(new Rect(0, 0, 100, 100), insets, insets);
        assertEquals(new Rect(0, -10, 90, 80),
        assertEquals(new Rect(10, 0, 100, 90),
                mSurface.calculateSnapshotFrame(new Rect(10, 10, 100, 100)));
    }

    @Test
    public void testCalculateSnapshotFrame_waterfall() {
        setupSurface(100, 100, new Rect(5, 10, 5, 10), 0, 0, new Rect(0, 0, 100, 100));
        final Rect insets = new Rect(0, 10, 0, 10);
        mSurface.setFrames(new Rect(5, 0, 95, 100), insets, insets);
        assertEquals(new Rect(0, 0, 90, 90),
                mSurface.calculateSnapshotFrame(new Rect(5, 0, 95, 90)));
    }

    @Test
    public void testDrawStatusBarBackground() {
        setupSurface(100, 100);