Merge "Fixing stagger animation not getting initialized properly" into ub-launcher3-rvc-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java
index 0bc021b..9781300 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -57,6 +57,7 @@
 
     private final Rect mTmpCropRect = new Rect();
     private final RectF mTempRectF = new RectF();
+    private final float[] mTempPoint = new float[2];
 
     private final RecentsOrientedState mOrientationState;
     private final Context mContext;
@@ -267,7 +268,7 @@
                     builder.withAlpha(alpha)
                             .withMatrix(mMatrix)
                             .withWindowCrop(mTmpCropRect)
-                            .withCornerRadius(mCurrentFullscreenParams.mCurrentDrawnCornerRadius);
+                            .withCornerRadius(getCurrentCornerRadius());
                 } else if (params.getTargetSet().hasRecents) {
                     // If home has a different target then recents, reverse anim the home target.
                     builder.withAlpha(fullScreenProgress.value * params.getTargetAlpha());
@@ -285,6 +286,20 @@
     }
 
     /**
+     * Returns the corner radius that should be applied to the target so that it matches the
+     * TaskView
+     */
+    public float getCurrentCornerRadius() {
+        float visibleRadius = mCurrentFullscreenParams.mCurrentDrawnCornerRadius;
+        mTempPoint[0] = visibleRadius;
+        mTempPoint[1] = 0;
+        mInversePositionMatrix.mapVectors(mTempPoint);
+
+        // Ideally we should use square-root. This is an optimization as one of the dimension is 0.
+        return Math.max(Math.abs(mTempPoint[0]), Math.abs(mTempPoint[1]));
+    }
+
+    /**
      * Interface for calculating taskSize
      */
     public interface TaskSizeProvider {