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

Commit c71b48c6 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Transfer coordinate into new Rect instead of in-place

Other parts of the animation rely on currentRectF to remain stable, therefore we shouldn't modify the RectF object in place.

Bug: 323628523
Flag: NONE
Test: Manual, i.e. verifying that widget close (and app close) animation animates correctly regardless of device orientation
Change-Id: I48e9ed047b956db654192eef39e5d94fbac53553
parent 51c09ed1
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -2049,7 +2049,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        private final RemoteAnimationTarget[] mAppTargets;
        private final RemoteAnimationTarget[] mAppTargets;
        private final Matrix mMatrix = new Matrix();
        private final Matrix mMatrix = new Matrix();
        private final Point mTmpPos = new Point();
        private final Point mTmpPos = new Point();
        private final Rect mCurrentRect = new Rect();
        private final RectF mCurrentRectF = new RectF();
        private final float mStartRadius;
        private final float mStartRadius;
        private final float mEndRadius;
        private final float mEndRadius;
        private final SurfaceTransactionApplier mSurfaceApplier;
        private final SurfaceTransactionApplier mSurfaceApplier;
@@ -2116,25 +2116,24 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
                }
                }


                if (target.mode == MODE_CLOSING) {
                if (target.mode == MODE_CLOSING) {
                    transferRectToTargetCoordinate(target, currentRectF, false, currentRectF);
                    transferRectToTargetCoordinate(target, currentRectF, false, mCurrentRectF);
                    currentRectF.round(mCurrentRect);


                    // Scale the target window to match the currentRectF.
                    // Scale the target window to match the currentRectF.
                    final float scale;
                    final float scale;


                    // We need to infer the crop (we crop the window to match the currentRectF).
                    // We need to infer the crop (we crop the window to match the currentRectF).
                    if (mWindowStartBounds.height() > mWindowStartBounds.width()) {
                    if (mWindowStartBounds.height() > mWindowStartBounds.width()) {
                        scale = Math.min(1f, currentRectF.width() / mWindowOriginalBounds.width());
                        scale = Math.min(1f, mCurrentRectF.width() / mWindowOriginalBounds.width());


                        int unscaledHeight = (int) (mCurrentRect.height() * (1f / scale));
                        int unscaledHeight = (int) (mCurrentRectF.height() * (1f / scale));
                        int croppedHeight = mWindowStartBounds.height() - unscaledHeight;
                        int croppedHeight = mWindowStartBounds.height() - unscaledHeight;
                        mTmpRect.set(0, 0, mWindowOriginalBounds.width(),
                        mTmpRect.set(0, 0, mWindowOriginalBounds.width(),
                                mWindowStartBounds.height() - croppedHeight);
                                mWindowStartBounds.height() - croppedHeight);
                    } else {
                    } else {
                        scale = Math.min(1f, currentRectF.height()
                        scale = Math.min(1f, mCurrentRectF.height()
                                / mWindowOriginalBounds.height());
                                / mWindowOriginalBounds.height());


                        int unscaledWidth = (int) (mCurrentRect.width() * (1f / scale));
                        int unscaledWidth = (int) (mCurrentRectF.width() * (1f / scale));
                        int croppedWidth = mWindowStartBounds.width() - unscaledWidth;
                        int croppedWidth = mWindowStartBounds.width() - unscaledWidth;
                        mTmpRect.set(0, 0, mWindowStartBounds.width() - croppedWidth,
                        mTmpRect.set(0, 0, mWindowStartBounds.width() - croppedWidth,
                                mWindowOriginalBounds.height());
                                mWindowOriginalBounds.height());
@@ -2142,7 +2141,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener


                    // Match size and position of currentRect.
                    // Match size and position of currentRect.
                    mMatrix.setScale(scale, scale);
                    mMatrix.setScale(scale, scale);
                    mMatrix.postTranslate(mCurrentRect.left, mCurrentRect.top);
                    mMatrix.postTranslate(mCurrentRectF.left, mCurrentRectF.top);


                    builder.setMatrix(mMatrix)
                    builder.setMatrix(mMatrix)
                            .setWindowCrop(mTmpRect)
                            .setWindowCrop(mTmpRect)