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

Commit fc74f9b5 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Polish PiP round corner" into sc-dev am: 7b8b7b5c am: 4e846b73"

parents 7e33f9ec 99069b70
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@
    <dimen name="pip_bottom_offset_buffer">1dp</dimen>

    <!-- The corner radius for PiP window. -->
    <dimen name="pip_corner_radius">8dp</dimen>
    <dimen name="pip_corner_radius">16dp</dimen>

    <!-- The bottom margin of the PIP drag to dismiss info text shown when moving a PIP. -->
    <dimen name="pip_dismiss_text_bottom_margin">24dp</dimen>
+15 −6
Original line number Diff line number Diff line
@@ -435,7 +435,8 @@ public class PipAnimationController {
                        SurfaceControl.Transaction tx, float fraction) {
                    final float alpha = getStartValue() * (1 - fraction) + getEndValue() * fraction;
                    setCurrentValue(alpha);
                    getSurfaceTransactionHelper().alpha(tx, leash, alpha);
                    getSurfaceTransactionHelper().alpha(tx, leash, alpha)
                            .round(tx, leash, shouldApplyCornerRadius());
                    tx.apply();
                }

@@ -526,16 +527,22 @@ public class PipAnimationController {
                    float angle = (1.0f - fraction) * startingAngle;
                    setCurrentValue(bounds);
                    if (inScaleTransition() || sourceHintRect == null) {

                        if (isOutPipDirection) {
                            getSurfaceTransactionHelper().scale(tx, leash, end, bounds);
                        } else {
                            getSurfaceTransactionHelper().scale(tx, leash, base, bounds, angle);
                            getSurfaceTransactionHelper().scale(tx, leash, base, bounds, angle)
                                    .round(tx, leash, base, bounds);
                        }
                    } else {
                        final Rect insets = computeInsets(fraction);
                        getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
                                initialSourceValue, bounds, insets);
                        if (shouldApplyCornerRadius()) {
                            final Rect destinationBounds = new Rect(bounds);
                            destinationBounds.inset(insets);
                            getSurfaceTransactionHelper().round(tx, leash,
                                    initialContainerRect, destinationBounds);
                        }
                    }
                    if (!handlePipTransaction(leash, tx, bounds)) {
                        tx.apply();
@@ -564,9 +571,11 @@ public class PipAnimationController {
                        x = fraction * (end.left - start.left) + start.left;
                        y = fraction * (end.bottom - start.top) + start.top;
                    }
                    getSurfaceTransactionHelper().rotateAndScaleWithCrop(tx, leash,
                            initialContainerRect, bounds, insets, degree, x, y, isOutPipDirection,
                            rotationDelta == ROTATION_270 /* clockwise */);
                    getSurfaceTransactionHelper()
                            .rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds,
                                    insets, degree, x, y, isOutPipDirection,
                                    rotationDelta == ROTATION_270 /* clockwise */)
                            .round(tx, leash, initialContainerRect, bounds);
                    tx.apply();
                }

+12 −0
Original line number Diff line number Diff line
@@ -185,6 +185,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;
    }

    /**
     * Re-parents the snapshot to the parent's surface control and shows it.
     */
+5 −1
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                mTaskOrganizer.applyTransaction(wct);
                // The final task bounds will be applied by onFixedRotationFinished so that all
                // coordinates are in new rotation.
                mSurfaceTransactionHelper.round(tx, mLeash, isInPip());
                mDeferredAnimEndTransaction = tx;
                return;
            }
@@ -1046,7 +1047,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        }

        final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
        mSurfaceTransactionHelper.scale(tx, mLeash, startBounds, toBounds, degrees);
        mSurfaceTransactionHelper
                .scale(tx, mLeash, startBounds, toBounds, degrees)
                .round(tx, mLeash, startBounds, toBounds);
        if (mPipMenuController.isMenuVisible()) {
            mPipMenuController.movePipMenu(mLeash, tx, toBounds);
        } else {
@@ -1221,6 +1224,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            // Just a resize in PIP
            taskBounds = destinationBounds;
        }
        mSurfaceTransactionHelper.round(tx, mLeash, isInPip());

        wct.setBounds(mToken, taskBounds);
        wct.setBoundsChangeTransaction(mToken, tx);
+3 −1
Original line number Diff line number Diff line
@@ -268,7 +268,9 @@ class PinnedTaskController {
                matrix.postRotate(90);
            }
            matrix.postTranslate(dx, dy);
            t.setMatrix(pinnedTask.getSurfaceControl(), matrix, new float[9]);
            final SurfaceControl leash = pinnedTask.getSurfaceControl();
            t.setMatrix(leash, matrix, new float[9])
                    .setCornerRadius(leash, pipTx.mCornerRadius);
            Slog.i(TAG, "Seamless rotation PiP tx=" + pipTx + " pos=" + dx + "," + dy);
            return;
        }