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

Commit 7cecb68d authored by Ikram Gabiyev's avatar Ikram Gabiyev Committed by Android (Google) Code Review
Browse files

Merge changes I3b4dcdea,I8a4a55ab into main

* changes:
  [PiP2] Properly scale corner radii while animating
  [PiP2] Add start delay to app icon overlay fadeout
parents df7b8f37 ad27226a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -133,6 +133,18 @@ public class PipSurfaceTransactionHelper {
        return this;
    }

    /**
     * Operates the round corner radius on a given transaction and leash, scaled by bounds
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
     */
    public PipSurfaceTransactionHelper round(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect fromBounds, Rect toBounds) {
        final float scale = (float) (Math.hypot(fromBounds.width(), fromBounds.height())
                / Math.hypot(toBounds.width(), toBounds.height()));
        tx.setCornerRadius(leash, mCornerRadius * scale);
        return this;
    }

    /**
     * Operates the shadow radius on a given transaction and leash
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ public class PipResizeAnimator extends ValueAnimator {
        transformTensor.postRotate(degrees, targetBounds.centerX(), targetBounds.centerY());

        tx.setMatrix(leash, transformTensor, mMatrixTmp)
                .setCornerRadius(leash, cornerRadius)
                .setCornerRadius(leash, cornerRadius / scaleX)
                .setShadowRadius(leash, shadowRadius);
    }

+4 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class PipScheduler {
    private PipTransitionController mPipTransitionController;
    private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
            mSurfaceControlTransactionFactory;
    private final PipSurfaceTransactionHelper mPipSurfaceTransactionHelper;

    @Nullable private Runnable mUpdateMovementBoundsRunnable;

@@ -75,6 +76,7 @@ public class PipScheduler {

        mSurfaceControlTransactionFactory =
                new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory();
        mPipSurfaceTransactionHelper = new PipSurfaceTransactionHelper(mContext);
        mPipAlphaAnimatorSupplier = PipAlphaAnimator::new;
    }

@@ -214,6 +216,8 @@ public class PipScheduler {
        transformTensor.postTranslate(toBounds.left, toBounds.top);
        transformTensor.postRotate(degrees, toBounds.centerX(), toBounds.centerY());

        mPipSurfaceTransactionHelper.round(tx, leash, mPipBoundsState.getBounds(), toBounds);

        tx.setMatrix(leash, transformTensor, mMatrixTmp);
        tx.apply();
    }
+7 −2
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemProperties;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.window.TransitionInfo;
@@ -105,7 +106,10 @@ public class PipTransition extends PipTransitionController implements
     * The fixed start delay in ms when fading out the content overlay from bounds animation.
     * The fadeout animation is guaranteed to start after the client has drawn under the new config.
     */
    private static final int CONTENT_OVERLAY_FADE_OUT_DELAY_MS = 500;
    private static final int EXTRA_CONTENT_OVERLAY_FADE_OUT_DELAY_MS =
            SystemProperties.getInt(
                    "persist.wm.debug.extra_content_overlay_fade_out_delay_ms", 400);
    private static final int CONTENT_OVERLAY_FADE_OUT_DURATION_MS = 500;

    //
    // Dependencies
@@ -551,7 +555,8 @@ public class PipTransition extends PipTransitionController implements
            @NonNull Runnable onAnimationEnd) {
        PipAlphaAnimator animator = new PipAlphaAnimator(mContext, overlayLeash,
                null /* startTx */, null /* finishTx */, PipAlphaAnimator.FADE_OUT);
        animator.setDuration(CONTENT_OVERLAY_FADE_OUT_DELAY_MS);
        animator.setDuration(CONTENT_OVERLAY_FADE_OUT_DURATION_MS);
        animator.setStartDelay(EXTRA_CONTENT_OVERLAY_FADE_OUT_DELAY_MS);
        animator.setAnimationEndCallback(onAnimationEnd);
        animator.start();
    }