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

Commit 2e3c31d0 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Lock free app animations (5/n): Reimplement skip first frame

Test: go/wm-smoke
Test: Close app, inspect transition with WindowScope, make sure
first frame of animation is skipped
Bug:

Change-Id: I68c135621df47c50696e318c4394da36ce806922
parent 988f6688
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -86,8 +86,11 @@ class AppWindowThumbnail implements Animatable {
    void startAnimation(Transaction t, Animation anim) {
        anim.restrictDuration(MAX_ANIMATION_DURATION);
        anim.scaleCurrentDuration(mAppToken.mService.getTransitionAnimationScaleLocked());
        mSurfaceAnimator.startAnimation(t, new LocalAnimationAdapter(new WindowAnimationSpec(anim,
                        new Point()), mAppToken.mService.mSurfaceAnimationRunner),
        mSurfaceAnimator.startAnimation(t,
                new LocalAnimationAdapter(
                        new WindowAnimationSpec(anim, new Point(),
                                mAppToken.mService.mAppTransition.canSkipFirstFrame()),
                        mAppToken.mService.mSurfaceAnimationRunner),
                false /* hidden */);
    }

@@ -95,6 +98,7 @@ class AppWindowThumbnail implements Animatable {
    }

    void setShowing(Transaction pendingTransaction, boolean show) {
        // TODO: Not needed anymore once thumbnail is attached to the app.
        if (show) {
            pendingTransaction.show(mSurfaceControl);
        } else {
@@ -129,6 +133,9 @@ class AppWindowThumbnail implements Animatable {

    @Override
    public void onAnimationLeashDestroyed(Transaction t) {

        // TODO: Once attached to app token, we don't need to hide it immediately if thumbnail
        // became visible.
        t.hide(mSurfaceControl);
    }

+3 −1
Original line number Diff line number Diff line
@@ -1526,7 +1526,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            final Animation a = loadAnimation(lp, transit, enter, isVoiceInteraction);
            if (a != null) {
                final AnimationAdapter adapter = new LocalAnimationAdapter(
                        new WindowAnimationSpec(a, new Point()), mService.mSurfaceAnimationRunner);
                        new WindowAnimationSpec(a, new Point(),
                                mService.mAppTransition.canSkipFirstFrame()),
                        mService.mSurfaceAnimationRunner);
                startAnimation(getPendingTransaction(), adapter, !isVisible());
                if (a.getZAdjustment() == Animation.ZORDER_TOP) {
                    mAppAnimator.animLayerAdjustment = 1;
+7 −0
Original line number Diff line number Diff line
@@ -108,5 +108,12 @@ class LocalAnimationAdapter implements AnimationAdapter {
         * @param currentPlayTime The current time of the animation.
         */
        void apply(Transaction t, SurfaceControl leash, long currentPlayTime);

        /**
         * @see AppTransition#canSkipFirstFrame
         */
        default boolean canSkipFirstFrame() {
            return false;
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -142,6 +142,11 @@ class SurfaceAnimationRunner {
            // Transaction will be applied in the commit phase.
            scheduleApplyTransaction();
        });

        if (a.mAnimSpec.canSkipFirstFrame()) {
            anim.setCurrentPlayTime(Choreographer.getFrameDelay());
        }

        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
+8 −1
Original line number Diff line number Diff line
@@ -38,10 +38,12 @@ public class WindowAnimationSpec implements AnimationSpec {
    private Animation mAnimation;
    private final Point mPosition = new Point();
    private final ThreadLocal<TmpValues> mThreadLocalTmps = ThreadLocal.withInitial(TmpValues::new);
    private final boolean mCanSkipFirstFrame;

    public WindowAnimationSpec(Animation animation, Point position)  {
    public WindowAnimationSpec(Animation animation, Point position, boolean canSkipFirstFrame)  {
        mAnimation = animation;
        mPosition.set(position.x, position.y);
        mCanSkipFirstFrame = canSkipFirstFrame;
    }

    @Override
@@ -88,6 +90,11 @@ public class WindowAnimationSpec implements AnimationSpec {
        }
    }

    @Override
    public boolean canSkipFirstFrame() {
        return mCanSkipFirstFrame;
    }

    /**
     * Tries to find a {@link TranslateAnimation} inside the {@code animation}.
     *
Loading