Merge "Polish PiP round corner" into sc-dev
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
<dimen name="pip_bottom_offset_buffer">1dp</dimen>
|
<dimen name="pip_bottom_offset_buffer">1dp</dimen>
|
||||||
|
|
||||||
<!-- The corner radius for PiP window. -->
|
<!-- 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. -->
|
<!-- 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>
|
<dimen name="pip_dismiss_text_bottom_margin">24dp</dimen>
|
||||||
|
|||||||
@@ -435,7 +435,8 @@ public class PipAnimationController {
|
|||||||
SurfaceControl.Transaction tx, float fraction) {
|
SurfaceControl.Transaction tx, float fraction) {
|
||||||
final float alpha = getStartValue() * (1 - fraction) + getEndValue() * fraction;
|
final float alpha = getStartValue() * (1 - fraction) + getEndValue() * fraction;
|
||||||
setCurrentValue(alpha);
|
setCurrentValue(alpha);
|
||||||
getSurfaceTransactionHelper().alpha(tx, leash, alpha);
|
getSurfaceTransactionHelper().alpha(tx, leash, alpha)
|
||||||
|
.round(tx, leash, shouldApplyCornerRadius());
|
||||||
tx.apply();
|
tx.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,16 +527,22 @@ public class PipAnimationController {
|
|||||||
float angle = (1.0f - fraction) * startingAngle;
|
float angle = (1.0f - fraction) * startingAngle;
|
||||||
setCurrentValue(bounds);
|
setCurrentValue(bounds);
|
||||||
if (inScaleTransition() || sourceHintRect == null) {
|
if (inScaleTransition() || sourceHintRect == null) {
|
||||||
|
|
||||||
if (isOutPipDirection) {
|
if (isOutPipDirection) {
|
||||||
getSurfaceTransactionHelper().scale(tx, leash, end, bounds);
|
getSurfaceTransactionHelper().scale(tx, leash, end, bounds);
|
||||||
} else {
|
} else {
|
||||||
getSurfaceTransactionHelper().scale(tx, leash, base, bounds, angle);
|
getSurfaceTransactionHelper().scale(tx, leash, base, bounds, angle)
|
||||||
|
.round(tx, leash, base, bounds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final Rect insets = computeInsets(fraction);
|
final Rect insets = computeInsets(fraction);
|
||||||
getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
|
getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
|
||||||
initialSourceValue, bounds, insets);
|
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)) {
|
if (!handlePipTransaction(leash, tx, bounds)) {
|
||||||
tx.apply();
|
tx.apply();
|
||||||
@@ -564,9 +571,11 @@ public class PipAnimationController {
|
|||||||
x = fraction * (end.left - start.left) + start.left;
|
x = fraction * (end.left - start.left) + start.left;
|
||||||
y = fraction * (end.bottom - start.top) + start.top;
|
y = fraction * (end.bottom - start.top) + start.top;
|
||||||
}
|
}
|
||||||
getSurfaceTransactionHelper().rotateAndScaleWithCrop(tx, leash,
|
getSurfaceTransactionHelper()
|
||||||
initialContainerRect, bounds, insets, degree, x, y, isOutPipDirection,
|
.rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds,
|
||||||
rotationDelta == ROTATION_270 /* clockwise */);
|
insets, degree, x, y, isOutPipDirection,
|
||||||
|
rotationDelta == ROTATION_270 /* clockwise */)
|
||||||
|
.round(tx, leash, initialContainerRect, bounds);
|
||||||
tx.apply();
|
tx.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,18 @@ public class PipSurfaceTransactionHelper {
|
|||||||
return this;
|
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.
|
* Re-parents the snapshot to the parent's surface control and shows it.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
mTaskOrganizer.applyTransaction(wct);
|
mTaskOrganizer.applyTransaction(wct);
|
||||||
// The final task bounds will be applied by onFixedRotationFinished so that all
|
// The final task bounds will be applied by onFixedRotationFinished so that all
|
||||||
// coordinates are in new rotation.
|
// coordinates are in new rotation.
|
||||||
|
mSurfaceTransactionHelper.round(tx, mLeash, isInPip());
|
||||||
mDeferredAnimEndTransaction = tx;
|
mDeferredAnimEndTransaction = tx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1041,7 +1042,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
|
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()) {
|
if (mPipMenuController.isMenuVisible()) {
|
||||||
mPipMenuController.movePipMenu(mLeash, tx, toBounds);
|
mPipMenuController.movePipMenu(mLeash, tx, toBounds);
|
||||||
} else {
|
} else {
|
||||||
@@ -1216,6 +1219,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
// Just a resize in PIP
|
// Just a resize in PIP
|
||||||
taskBounds = destinationBounds;
|
taskBounds = destinationBounds;
|
||||||
}
|
}
|
||||||
|
mSurfaceTransactionHelper.round(tx, mLeash, isInPip());
|
||||||
|
|
||||||
wct.setBounds(mToken, taskBounds);
|
wct.setBounds(mToken, taskBounds);
|
||||||
wct.setBoundsChangeTransaction(mToken, tx);
|
wct.setBoundsChangeTransaction(mToken, tx);
|
||||||
|
|||||||
@@ -268,7 +268,9 @@ class PinnedTaskController {
|
|||||||
matrix.postRotate(90);
|
matrix.postRotate(90);
|
||||||
}
|
}
|
||||||
matrix.postTranslate(dx, dy);
|
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);
|
Slog.i(TAG, "Seamless rotation PiP tx=" + pipTx + " pos=" + dx + "," + dy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user