Move params for ClipAnimationHelper#applyTransform into TransformParams

This will help keep the code clean when we add more params, e.g. for
live tiles and for the scrolling gesture.

Bug: 111699315
Change-Id: Ia9df40ae85fe29911b957bd9b06b8c8a31f3be39
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 61bb75f..a3207f5 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -343,14 +343,15 @@
             clipHelper.updateTargetRect(targetRect);
             clipHelper.prepareAnimation(false /* isOpening */);
 
-            SyncRtSurfaceTransactionApplier syncTransactionApplier =
-                    new SyncRtSurfaceTransactionApplier(rootView);
+            ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
+                    .setSyncTransactionApplier(new SyncRtSurfaceTransactionApplier(rootView));
             ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
             valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
             valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
-            valueAnimator.addUpdateListener((v) ->
-                    clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue(),
-                            syncTransactionApplier));
+            valueAnimator.addUpdateListener((v) -> {
+                params.setProgress((float) v.getAnimatedValue());
+                clipHelper.applyTransform(targetSet, params);
+            });
 
             if (targetSet.isAnimatingHome()) {
                 // If we are animating home, fade in the opening targets
diff --git a/quickstep/src/com/android/quickstep/TaskUtils.java b/quickstep/src/com/android/quickstep/TaskUtils.java
index 4b86a7f..cf46b09 100644
--- a/quickstep/src/com/android/quickstep/TaskUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskUtils.java
@@ -145,8 +145,8 @@
      */
     public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges,
             RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
-        SyncRtSurfaceTransactionApplier syncTransactionApplier =
-                new SyncRtSurfaceTransactionApplier(v);
+        ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
+                .setSyncTransactionApplier(new SyncRtSurfaceTransactionApplier(v));
         final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
         appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
         appAnimator.addUpdateListener(new MultiValueUpdateListener() {
@@ -174,8 +174,8 @@
 
             @Override
             public void onUpdate(float percent) {
-                RectF taskBounds = inOutHelper.applyTransform(mTargetSet, 1 - percent,
-                        syncTransactionApplier);
+                params.setProgress(1 - percent);
+                RectF taskBounds = inOutHelper.applyTransform(mTargetSet, params);
                 if (!skipViewChanges) {
                     float scale = taskBounds.width() / mThumbnailRect.width();
                     v.setScaleX(scale);
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 98e26ef..e1ffcf0 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -52,6 +52,7 @@
 import androidx.annotation.AnyThread;
 import androidx.annotation.UiThread;
 import androidx.annotation.WorkerThread;
+
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.BaseDraggingActivity;
 import com.android.launcher3.DeviceProfile;
@@ -176,6 +177,7 @@
             Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
 
     private final ClipAnimationHelper mClipAnimationHelper;
+    private final ClipAnimationHelper.TransformParams mTransformParams;
 
     protected Runnable mGestureEndCallback;
     protected boolean mIsGoingToHome;
@@ -256,6 +258,7 @@
         mRecentsAnimationWrapper = new RecentsAnimationWrapper(inputConsumer,
                 this::createNewTouchProxyHandler);
         mClipAnimationHelper = new ClipAnimationHelper(context);
+        mTransformParams = new ClipAnimationHelper.TransformParams();
 
         initStateCallbacks();
     }
@@ -584,11 +587,13 @@
 
         RecentsAnimationControllerCompat controller = mRecentsAnimationWrapper.getController();
         if (controller != null) {
-
-            mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet, shift,
-                    Looper.myLooper() == mMainThreadHandler.getLooper()
+            SyncRtSurfaceTransactionApplier syncTransactionApplier
+                    = Looper.myLooper() == mMainThreadHandler.getLooper()
                             ? mSyncTransactionApplier
-                            : null);
+                            : null;
+            mTransformParams.setProgress(shift).setSyncTransactionApplier(syncTransactionApplier);
+            mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet,
+                    mTransformParams);
 
             boolean passedThreshold = shift > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
             mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold);
diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
index 8c9cead..898de97 100644
--- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -151,14 +151,13 @@
         mBoostModeTargetLayers = isOpening ? MODE_OPENING : MODE_CLOSING;
     }
 
-    public RectF applyTransform(RemoteAnimationTargetSet targetSet, float progress,
-            @Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier) {
+    public RectF applyTransform(RemoteAnimationTargetSet targetSet, TransformParams params) {
         RectF currentRect;
         mTmpRectF.set(mTargetRect);
         Utilities.scaleRectFAboutCenter(mTmpRectF, mTargetScale);
-        float offsetYProgress = mOffsetYInterpolator.getInterpolation(progress);
-        progress = mInterpolator.getInterpolation(progress);
-        currentRect =  mRectFEvaluator.evaluate(progress, mSourceRect, mTmpRectF);
+        float offsetYProgress = mOffsetYInterpolator.getInterpolation(params.progress);
+        float progress = mInterpolator.getInterpolation(params.progress);
+        currentRect = mRectFEvaluator.evaluate(progress, mSourceRect, mTmpRectF);
 
         synchronized (mTargetOffset) {
             // Stay lined up with the center of the target, since it moves for quick scrub.
@@ -173,7 +172,7 @@
         mClipRectF.bottom =
                 mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress);
 
-        SurfaceParams[] params = new SurfaceParams[targetSet.unfilteredApps.length];
+        SurfaceParams[] surfaceParams = new SurfaceParams[targetSet.unfilteredApps.length];
         for (int i = 0; i < targetSet.unfilteredApps.length; i++) {
             RemoteAnimationTargetCompat app = targetSet.unfilteredApps[i];
             mTmpMatrix.setTranslate(app.position.x, app.position.y);
@@ -206,10 +205,10 @@
 
             // Since radius is in Surface space, but we draw the rounded corners in screen space, we
             // have to undo the scale.
-            params[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer,
+            surfaceParams[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer,
                     cornerRadius / scale);
         }
-        applyParams(syncTransactionApplier, params);
+        applySurfaceParams(params.syncTransactionApplier, surfaceParams);
         return currentRect;
     }
 
@@ -218,8 +217,8 @@
         return mCurrentRectWithInsets;
     }
 
-    private void applyParams(@Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier,
-            SurfaceParams[] params) {
+    private void applySurfaceParams(@Nullable SyncRtSurfaceTransactionApplier
+            syncTransactionApplier, SurfaceParams[] params) {
         if (syncTransactionApplier != null) {
             syncTransactionApplier.scheduleApply(params);
         } else {
@@ -350,4 +349,23 @@
     public float getCurrentCornerRadius() {
         return mCurrentCornerRadius;
     }
+
+    public static class TransformParams {
+        float progress;
+        SyncRtSurfaceTransactionApplier syncTransactionApplier;
+
+        public TransformParams() {
+            progress = 0;
+        }
+
+        public TransformParams setProgress(float progress) {
+            this.progress = progress;
+            return this;
+        }
+
+        public TransformParams setSyncTransactionApplier(SyncRtSurfaceTransactionApplier applier) {
+            this.syncTransactionApplier = applier;
+            return this;
+        }
+    }
 }