Polish round corner for auto-enter-pip
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/b47ErxSscLnZl9clVncSY6 Bug: 187834841 Test: manual, see video Change-Id: I59132ea50a3213a9caa2366c103fdddf642498e2
This commit is contained in:
@@ -628,8 +628,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
final Rect destinationBounds = mPipBoundsState.getBounds();
|
||||
final SurfaceControl swipeToHomeOverlay = mSwipePipToHomeOverlay;
|
||||
final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
|
||||
mSurfaceTransactionHelper.resetScale(tx, mLeash, destinationBounds);
|
||||
mSurfaceTransactionHelper.crop(tx, mLeash, destinationBounds);
|
||||
mSurfaceTransactionHelper
|
||||
.resetScale(tx, mLeash, destinationBounds)
|
||||
.crop(tx, mLeash, destinationBounds)
|
||||
.round(tx, mLeash, isInPip());
|
||||
// The animation is finished in the Launcher and here we directly apply the final touch.
|
||||
applyEnterPipSyncTransaction(destinationBounds, () -> {
|
||||
// Ensure menu's settled in its final bounds first.
|
||||
|
||||
@@ -46,12 +46,13 @@ public class PipSurfaceTransactionHelper {
|
||||
mTmpSourceRectF.set(sourceBounds);
|
||||
mTmpDestinationRectF.set(destinationBounds);
|
||||
mTmpTransform.setRectToRect(mTmpSourceRectF, mTmpDestinationRectF, Matrix.ScaleToFit.FILL);
|
||||
final float cornerRadius = getScaledCornerRadius(sourceBounds, destinationBounds);
|
||||
tx.setMatrix(leash, mTmpTransform, mTmpFloat9)
|
||||
.setPosition(leash, mTmpDestinationRectF.left, mTmpDestinationRectF.top)
|
||||
.setCornerRadius(leash, mCornerRadius);
|
||||
.setCornerRadius(leash, cornerRadius);
|
||||
return new PictureInPictureSurfaceTransaction(
|
||||
mTmpDestinationRectF.left, mTmpDestinationRectF.top,
|
||||
mTmpFloat9, 0 /* rotation */, mCornerRadius, sourceBounds);
|
||||
mTmpFloat9, 0 /* rotation */, cornerRadius, sourceBounds);
|
||||
}
|
||||
|
||||
public PictureInPictureSurfaceTransaction scale(
|
||||
@@ -62,11 +63,12 @@ public class PipSurfaceTransactionHelper {
|
||||
mTmpDestinationRectF.set(destinationBounds);
|
||||
mTmpTransform.setRectToRect(mTmpSourceRectF, mTmpDestinationRectF, Matrix.ScaleToFit.FILL);
|
||||
mTmpTransform.postRotate(degree, 0, 0);
|
||||
final float cornerRadius = getScaledCornerRadius(sourceBounds, destinationBounds);
|
||||
tx.setMatrix(leash, mTmpTransform, mTmpFloat9)
|
||||
.setPosition(leash, positionX, positionY)
|
||||
.setCornerRadius(leash, mCornerRadius);
|
||||
.setCornerRadius(leash, cornerRadius);
|
||||
return new PictureInPictureSurfaceTransaction(
|
||||
positionX, positionY, mTmpFloat9, degree, mCornerRadius, sourceBounds);
|
||||
positionX, positionY, mTmpFloat9, degree, cornerRadius, sourceBounds);
|
||||
}
|
||||
|
||||
public PictureInPictureSurfaceTransaction scaleAndCrop(
|
||||
@@ -83,12 +85,15 @@ public class PipSurfaceTransactionHelper {
|
||||
final float left = destinationBounds.left - insets.left * scale;
|
||||
final float top = destinationBounds.top - insets.top * scale;
|
||||
mTmpTransform.setScale(scale, scale);
|
||||
final Rect cornerRadiusRect = new Rect(destinationBounds);
|
||||
cornerRadiusRect.inset(insets);
|
||||
final float cornerRadius = getScaledCornerRadius(sourceBounds, cornerRadiusRect);
|
||||
tx.setMatrix(leash, mTmpTransform, mTmpFloat9)
|
||||
.setWindowCrop(leash, mTmpDestinationRect)
|
||||
.setPosition(leash, left, top)
|
||||
.setCornerRadius(leash, mCornerRadius);
|
||||
.setCornerRadius(leash, cornerRadius);
|
||||
return new PictureInPictureSurfaceTransaction(
|
||||
left, top, mTmpFloat9, 0 /* rotation */, mCornerRadius, mTmpDestinationRect);
|
||||
left, top, mTmpFloat9, 0 /* rotation */, cornerRadius, mTmpDestinationRect);
|
||||
}
|
||||
|
||||
public PictureInPictureSurfaceTransaction scaleAndRotate(
|
||||
@@ -105,12 +110,22 @@ public class PipSurfaceTransactionHelper {
|
||||
: (float) destinationBounds.height() / sourceBounds.height();
|
||||
mTmpTransform.setRotate(degree, 0, 0);
|
||||
mTmpTransform.postScale(scale, scale);
|
||||
final Rect cornerRadiusRect = new Rect(destinationBounds);
|
||||
cornerRadiusRect.inset(insets);
|
||||
final float cornerRadius = getScaledCornerRadius(sourceBounds, cornerRadiusRect);
|
||||
tx.setMatrix(leash, mTmpTransform, mTmpFloat9)
|
||||
.setWindowCrop(leash, mTmpDestinationRect)
|
||||
.setPosition(leash, positionX, positionY)
|
||||
.setCornerRadius(leash, mCornerRadius);
|
||||
.setCornerRadius(leash, cornerRadius);
|
||||
return new PictureInPictureSurfaceTransaction(
|
||||
positionX, positionY, mTmpFloat9, degree, mCornerRadius, mTmpDestinationRect);
|
||||
positionX, positionY, mTmpFloat9, degree, cornerRadius, mTmpDestinationRect);
|
||||
}
|
||||
|
||||
/** @return the round corner radius scaled by given from and to bounds */
|
||||
private float getScaledCornerRadius(Rect fromBounds, Rect toBounds) {
|
||||
final float scale = (float) (Math.hypot(fromBounds.width(), fromBounds.height())
|
||||
/ Math.hypot(toBounds.width(), toBounds.height()));
|
||||
return mCornerRadius * scale;
|
||||
}
|
||||
|
||||
/** @return {@link SurfaceControl.Transaction} instance with vsync-id */
|
||||
|
||||
Reference in New Issue
Block a user