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;
|
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() {
|
public float getDefaultAspectRatio() {
|
||||||
return mDefaultAspectRatio;
|
return mDefaultAspectRatio;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1657,8 +1657,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
"%s: Abort animation, invalid leash", TAG);
|
"%s: Abort animation, invalid leash", TAG);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (isInPipDirection(direction)
|
if (isInPipDirection(direction) && !PipBoundsAlgorithm
|
||||||
&& !isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
|
.isSourceRectHintValidForEnterPip(sourceHintRect, destinationBounds)) {
|
||||||
// The given source rect hint is too small for enter PiP animation, reset it to null.
|
// The given source rect hint is too small for enter PiP animation, reset it to null.
|
||||||
sourceHintRect = null;
|
sourceHintRect = null;
|
||||||
}
|
}
|
||||||
@@ -1756,20 +1756,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
return sourceHintRect;
|
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
|
* Sync with {@link SplitScreenController} on destination bounds if PiP is going to
|
||||||
* split screen.
|
* split screen.
|
||||||
|
|||||||
@@ -764,7 +764,7 @@ public class PipTransition extends PipTransitionController {
|
|||||||
final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds();
|
final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds();
|
||||||
int rotationDelta = deltaRotation(startRotation, endRotation);
|
int rotationDelta = deltaRotation(startRotation, endRotation);
|
||||||
Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
|
Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
|
||||||
taskInfo.pictureInPictureParams, currentBounds);
|
taskInfo.pictureInPictureParams, currentBounds, destinationBounds);
|
||||||
if (rotationDelta != Surface.ROTATION_0 && mInFixedRotation) {
|
if (rotationDelta != Surface.ROTATION_0 && mInFixedRotation) {
|
||||||
// Need to get the bounds of new rotation in old rotation for fixed rotation,
|
// Need to get the bounds of new rotation in old rotation for fixed rotation,
|
||||||
computeEnterPipRotatedBounds(rotationDelta, startRotation, endRotation, taskInfo,
|
computeEnterPipRotatedBounds(rotationDelta, startRotation, endRotation, taskInfo,
|
||||||
|
|||||||
Reference in New Issue
Block a user