Merge "Set sourceRectHint null if too small" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1bb7e3c6c
@@ -180,6 +180,35 @@ public class PipBoundsAlgorithm {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the source hint rect if it is valid (if provided and is contained by the current
|
||||
* task bounds, while not smaller than the destination bounds).
|
||||
*/
|
||||
@Nullable
|
||||
public static Rect getValidSourceHintRect(PictureInPictureParams params, Rect sourceBounds,
|
||||
Rect destinationBounds) {
|
||||
Rect sourceRectHint = getValidSourceHintRect(params, sourceBounds);
|
||||
if (!isSourceRectHintValidForEnterPip(sourceRectHint, destinationBounds)) {
|
||||
sourceRectHint = null;
|
||||
}
|
||||
return sourceRectHint;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a situation in which the source rect hint on at least one axis is smaller
|
||||
* than the destination bounds, which represents a problem because we would have to scale
|
||||
* up that axis to fit the bounds. So instead, just fallback to the non-source hint
|
||||
* animation in this case.
|
||||
*
|
||||
* @return {@code false} if the given source is too small to use for the entering animation.
|
||||
*/
|
||||
static boolean isSourceRectHintValidForEnterPip(Rect sourceRectHint, Rect destinationBounds) {
|
||||
return sourceRectHint != null
|
||||
&& sourceRectHint.width() > destinationBounds.width()
|
||||
&& sourceRectHint.height() > destinationBounds.height();
|
||||
}
|
||||
|
||||
public float getDefaultAspectRatio() {
|
||||
return mDefaultAspectRatio;
|
||||
}
|
||||
|
||||
@@ -1657,8 +1657,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
"%s: Abort animation, invalid leash", TAG);
|
||||
return null;
|
||||
}
|
||||
if (isInPipDirection(direction)
|
||||
&& !isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
|
||||
if (isInPipDirection(direction) && !PipBoundsAlgorithm
|
||||
.isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
|
||||
// The given source rect hint is too small for enter PiP animation, reset it to null.
|
||||
sourceHintRect = null;
|
||||
}
|
||||
@@ -1756,20 +1756,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
return sourceHintRect;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a situation in which the source rect hint on at least one axis is smaller
|
||||
* than the destination bounds, which represents a problem because we would have to scale
|
||||
* up that axis to fit the bounds. So instead, just fallback to the non-source hint
|
||||
* animation in this case.
|
||||
*
|
||||
* @return {@code false} if the given source is too small to use for the entering animation.
|
||||
*/
|
||||
private boolean isSourceRectHintValidForEnterPip(Rect sourceRectHint, Rect destinationBounds) {
|
||||
return sourceRectHint != null
|
||||
&& sourceRectHint.width() > destinationBounds.width()
|
||||
&& sourceRectHint.height() > destinationBounds.height();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync with {@link SplitScreenController} on destination bounds if PiP is going to
|
||||
* split screen.
|
||||
|
||||
@@ -764,7 +764,7 @@ public class PipTransition extends PipTransitionController {
|
||||
final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds();
|
||||
int rotationDelta = deltaRotation(startRotation, endRotation);
|
||||
Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
|
||||
taskInfo.pictureInPictureParams, currentBounds);
|
||||
taskInfo.pictureInPictureParams, currentBounds, destinationBounds);
|
||||
if (rotationDelta != Surface.ROTATION_0 && mInFixedRotation) {
|
||||
// Need to get the bounds of new rotation in old rotation for fixed rotation,
|
||||
computeEnterPipRotatedBounds(rotationDelta, startRotation, endRotation, taskInfo,
|
||||
|
||||
Reference in New Issue
Block a user