diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 3caff35c8a9db..9b0bf015617ef 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -43,7 +43,7 @@ 1dp - 8dp + 16dp 24dp diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java index a2c6567137241..c46b5590bab6c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java @@ -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(); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java index 48a15d8686b45..9fa3f69b5f60b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java @@ -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. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 00494611420d3..b40c651e9a2ea 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -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; } @@ -1037,7 +1038,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 { @@ -1212,6 +1215,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); diff --git a/services/core/java/com/android/server/wm/PinnedTaskController.java b/services/core/java/com/android/server/wm/PinnedTaskController.java index 7b4b23ec8c84e..31e2edec2601d 100644 --- a/services/core/java/com/android/server/wm/PinnedTaskController.java +++ b/services/core/java/com/android/server/wm/PinnedTaskController.java @@ -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; }