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

Commit 0382dd76 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Releasing SurfaceControl when they are no longer needed

Bug: 123874711
Change-Id: I9c06723a3e5d4a23b8a6c60352806bb12daba598
parent 34c630bf
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -51,9 +51,16 @@ public class SwipeSharedState implements SwipeAnimationListener {
        mLastAnimationRunning = true;
    }

    private void clearAnimationTarget() {
        if (mLastAnimationTarget != null) {
            mLastAnimationTarget.release();
            mLastAnimationTarget = null;
        }
    }

    @Override
    public final void onRecentsAnimationCanceled() {
        mLastAnimationTarget = null;
        clearAnimationTarget();

        mLastAnimationCancelled = true;
        mLastAnimationRunning = false;
@@ -64,7 +71,7 @@ public class SwipeSharedState implements SwipeAnimationListener {
            mRecentsAnimationListener.removeListener(this);
        }
        mRecentsAnimationListener = null;
        mLastAnimationTarget = null;
        clearAnimationTarget();
        mLastAnimationCancelled = false;
        mLastAnimationRunning = false;
    }
+17 −5
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.ComponentName;
import android.graphics.RectF;
@@ -109,8 +111,14 @@ public final class TaskViewUtils {
     */
    public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges,
            RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
        SyncRtSurfaceTransactionApplierCompat applier =
                new SyncRtSurfaceTransactionApplierCompat(v);
        ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
                .setSyncTransactionApplier(new SyncRtSurfaceTransactionApplierCompat(v));
                .setSyncTransactionApplier(applier);

        final RemoteAnimationTargetSet targetSet =
                new RemoteAnimationTargetSet(targets, MODE_OPENING);
        targetSet.addDependentTransactionApplier(applier);

        final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
        appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
@@ -120,17 +128,15 @@ public final class TaskViewUtils {
            final FloatProp mViewAlpha = new FloatProp(1f, 0f, 75, 75, LINEAR);
            final FloatProp mTaskAlpha = new FloatProp(0f, 1f, 0, 75, LINEAR);

            final RemoteAnimationTargetSet mTargetSet;

            final RectF mThumbnailRect;

            {
                mTargetSet = new RemoteAnimationTargetSet(targets, MODE_OPENING);
                inOutHelper.setTaskAlphaCallback((t, alpha) -> mTaskAlpha.value);

                inOutHelper.prepareAnimation(true /* isOpening */);
                inOutHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(),
                        mTargetSet.apps.length == 0 ? null : mTargetSet.apps[0]);
                        targetSet.apps.length == 0 ? null : targetSet.apps[0]);

                mThumbnailRect = new RectF(inOutHelper.getTargetRect());
                mThumbnailRect.offset(-v.getTranslationX(), -v.getTranslationY());
@@ -140,7 +146,7 @@ public final class TaskViewUtils {
            @Override
            public void onUpdate(float percent) {
                params.setProgress(1 - percent);
                RectF taskBounds = inOutHelper.applyTransform(mTargetSet, params);
                RectF taskBounds = inOutHelper.applyTransform(targetSet, params);
                if (!skipViewChanges) {
                    float scale = taskBounds.width() / mThumbnailRect.width();
                    v.setScaleX(scale);
@@ -151,6 +157,12 @@ public final class TaskViewUtils {
                }
            }
        });
        appAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                targetSet.release();
            }
        });
        return appAnimator;
    }
}
+7 −7
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    private T mActivity;
    private RecentsView mRecentsView;
    private SyncRtSurfaceTransactionApplierCompat mSyncTransactionApplier;
    private AnimationFactory mAnimationFactory = (t) -> { };
    private LiveTileOverlay mLiveTileOverlay = new LiveTileOverlay();

@@ -405,8 +404,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
        }

        mRecentsView = activity.getOverviewPanel();
        SyncRtSurfaceTransactionApplierCompat.create(mRecentsView,
                applier ->  mSyncTransactionApplier = applier );
        SyncRtSurfaceTransactionApplierCompat.create(mRecentsView, applier -> {
            mTransformParams.setSyncTransactionApplier(applier);
            mRecentsAnimationWrapper.runOnInit(() ->
                    mRecentsAnimationWrapper.targetSet.addDependentTransactionApplier(applier));
            });
        mRecentsView.setEnableFreeScroll(false);

        mRecentsView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
@@ -648,8 +650,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
            }
            float offsetScale = getTaskCurveScaleForOffsetX(offsetX,
                    mClipAnimationHelper.getTargetRect().width());
            mTransformParams.setProgress(shift).setOffsetX(offsetX).setOffsetScale(offsetScale)
                    .setSyncTransactionApplier(mSyncTransactionApplier);
            mTransformParams.setProgress(shift).setOffsetX(offsetX).setOffsetScale(offsetScale);
            mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet,
                    mTransformParams);
            mRecentsAnimationWrapper.setWindowThresholdCrossed(
@@ -1047,8 +1048,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

            float iconAlpha = Utilities.mapToRange(interpolatedProgress, 0,
                    windowAlphaThreshold, 0f, 1f, Interpolators.LINEAR);
            mTransformParams.setCurrentRectAndTargetAlpha(currentRect, 1f - iconAlpha)
                    .setSyncTransactionApplier(mSyncTransactionApplier);
            mTransformParams.setCurrentRectAndTargetAlpha(currentRect, 1f - iconAlpha);
            mClipAnimationHelper.applyTransform(targetSet, mTransformParams,
                    false /* launcherOnTop */);

+0 −5
Original line number Diff line number Diff line
@@ -95,9 +95,4 @@ public class SwipeAnimationTargetSet extends RemoteAnimationTargetSet {

        void onRecentsAnimationCanceled();
    }

    public interface SwipeAnimationFinishListener {

        void onSwipeAnimationFinished(SwipeAnimationTargetSet targetSet);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -416,10 +416,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans

        RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(targets,
                MODE_OPENING);
        RemoteAnimationTargetSet closingTargets = new RemoteAnimationTargetSet(targets,
                MODE_CLOSING);
        SyncRtSurfaceTransactionApplierCompat surfaceApplier =
                new SyncRtSurfaceTransactionApplierCompat(mFloatingView);
        openingTargets.addDependentTransactionApplier(surfaceApplier);

        // Scale the app icon to take up the entire screen. This simplifies the math when
        // animating the app window position / scale.
@@ -470,6 +469,7 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
                if (v instanceof BubbleTextView) {
                    ((BubbleTextView) v).setStayPressed(false);
                }
                openingTargets.release();
            }
        });

Loading