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

Commit 15d8ea3a authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Fix the animation position when launch into PiP

When attach the task snapshot to the leash of newly created Task, move
its position to the new Task's coordinates and apply the crop with scale
in mind (snapshot is scaled to its task size).

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/d72OCvyYh0G0Z6YrEwyXMp
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/eacts7tgSeN28R3BWpXAem
Bug: 232984253
Test: launch into PiP with source rect hint middle of screen, \
      see also the video
Change-Id: Ib79e75d7e6f6f667e50db197d5377b87cffc714d
parent 999a0666
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -132,7 +132,11 @@ public abstract class PipContentOverlay {
            tx.show(mLeash);
            tx.setLayer(mLeash, Integer.MAX_VALUE);
            tx.setBuffer(mLeash, mSnapshot.getHardwareBuffer());
            tx.setCrop(mLeash, mSourceRectHint);
            // Relocate the content to parentLeash's coordinates.
            tx.setPosition(mLeash, -mSourceRectHint.left, -mSourceRectHint.top);
            tx.setWindowCrop(mLeash,
                    (int) (mSourceRectHint.width() * mTaskSnapshotScaleX),
                    (int) (mSourceRectHint.height() * mTaskSnapshotScaleY));
            tx.setScale(mLeash, mTaskSnapshotScaleX, mTaskSnapshotScaleY);
            tx.reparent(mLeash, parentLeash);
            tx.apply();
@@ -149,10 +153,11 @@ public abstract class PipContentOverlay {
            // the atomicTx is committed along with the final WindowContainerTransaction.
            final SurfaceControl.Transaction nonAtomicTx = new SurfaceControl.Transaction();
            final float scaleX = (float) destinationBounds.width()
                    / mSnapshot.getHardwareBuffer().getWidth();
                    / mSourceRectHint.width();
            final float scaleY = (float) destinationBounds.height()
                    / mSnapshot.getHardwareBuffer().getHeight();
            final float scale = Math.max(scaleX, scaleY);
                    / mSourceRectHint.height();
            final float scale = Math.max(
                    scaleX * mTaskSnapshotScaleX, scaleY * mTaskSnapshotScaleY);
            nonAtomicTx.setScale(mLeash, scale, scale);
            nonAtomicTx.setPosition(mLeash,
                    -scale * mSourceRectHint.left / mTaskSnapshotScaleX,
+3 −1
Original line number Diff line number Diff line
@@ -105,8 +105,10 @@ public class PipSurfaceTransactionHelper {
            SurfaceControl leash, Rect sourceRectHint,
            Rect sourceBounds, Rect destinationBounds, Rect insets,
            boolean isInPipDirection) {
        mTmpSourceRectF.set(sourceBounds);
        mTmpDestinationRect.set(sourceBounds);
        // Similar to {@link #scale}, we want to position the surface relative to the screen
        // coordinates so offset the bounds to 0,0
        mTmpDestinationRect.offsetTo(0, 0);
        mTmpDestinationRect.inset(insets);
        // Scale by the shortest edge and offset such that the top/left of the scaled inset source
        // rect aligns with the top/left of the destination bounds