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

Commit 252b4d99 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Fix scale/translation for fixed rotation PiP enter

Make sure we are properly manipulating the leash during
swipe PiP to home with fixed rotation, by scaling until
the first edge matches the target bounds.

Also make sure to adjust the translation in the proper direction
for cases that involve rotation of the leash from either
ROTATION_90 or ROTATION_270.

These manipulations are also made sure to match those done in Shell
at the jumpcut (TRANSIT_PIP), when the launcher animation is at
fraction=1.0.

Wide video
Counter-clockwise: https://recall.googleplex.com/projects/6af09b54-0cd3-4ca5-ac80-10618382ff72/sessions/ed31b229-9100-4916-be54-27b91909ef12
Clockwise: https://recall.googleplex.com/projects/6af09b54-0cd3-4ca5-ac80-10618382ff72/sessions/7685431a-8ef2-493e-ba80-a7dbb64010c0

Non-wide video:
Counter-clockwise: https://recall.googleplex.com/projects/6af09b54-0cd3-4ca5-ac80-10618382ff72/sessions/c06e24f9-c1db-4f15-8ad3-6abe4c82bb77
Clockwise: https://recall.googleplex.com/projects/6af09b54-0cd3-4ca5-ac80-10618382ff72/sessions/81afd0d6-6057-40fa-a035-97470dc0561e

Bug: 352767168
Flag: EXEMPT bugfix
Test: swipe PiP to home with 21:9 video from landscape to portrait
Change-Id: I5a1b3f79c338ece3e26682c2ae3a52d9a9a226ab
parent a312222c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -128,19 +128,20 @@ public class PipSurfaceTransactionHelper {
        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
        final float scale = sourceBounds.width() <= sourceBounds.height()
                ? (float) destinationBounds.width() / sourceBounds.width()
                : (float) destinationBounds.height() / sourceBounds.height();
        final float scale = Math.max((float) destinationBounds.width() / sourceBounds.width(),
                (float) destinationBounds.height() / sourceBounds.height());
        mTmpTransform.setRotate(degree, 0, 0);
        mTmpTransform.postScale(scale, scale);
        final float cornerRadius = getScaledCornerRadius(mTmpDestinationRect, destinationBounds);
        // adjust the positions, take account also the insets
        final float adjustedPositionX, adjustedPositionY;
        if (degree < 0) {
            adjustedPositionX = positionX + insets.top * scale;
            // Counter-clockwise rotation.
            adjustedPositionX = positionX - insets.top * scale;
            adjustedPositionY = positionY + insets.left * scale;
        } else {
            adjustedPositionX = positionX - insets.top * scale;
            // Clockwise rotation.
            adjustedPositionX = positionX + insets.top * scale;
            adjustedPositionY = positionY - insets.left * scale;
        }
        tx.setMatrix(leash, mTmpTransform, mTmpFloat9)