Merge "Set window crop for TaskFragment open/close animation" into sc-v2-dev
This commit is contained in:
@@ -39,6 +39,8 @@ class TaskFragmentAnimationAdapter {
|
|||||||
|
|
||||||
final Transformation mTransformation = new Transformation();
|
final Transformation mTransformation = new Transformation();
|
||||||
final float[] mMatrix = new float[9];
|
final float[] mMatrix = new float[9];
|
||||||
|
final float[] mVecs = new float[4];
|
||||||
|
final Rect mRect = new Rect();
|
||||||
private boolean mIsFirstFrame = true;
|
private boolean mIsFirstFrame = true;
|
||||||
|
|
||||||
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
||||||
@@ -76,6 +78,22 @@ class TaskFragmentAnimationAdapter {
|
|||||||
mTarget.localBounds.left, mTarget.localBounds.top);
|
mTarget.localBounds.left, mTarget.localBounds.top);
|
||||||
t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
|
t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
|
||||||
t.setAlpha(mLeash, mTransformation.getAlpha());
|
t.setAlpha(mLeash, mTransformation.getAlpha());
|
||||||
|
|
||||||
|
// Open/close animation may scale up the surface. Apply an inverse scale to the window crop
|
||||||
|
// so that it will not be covering other windows.
|
||||||
|
mVecs[1] = mVecs[2] = 0;
|
||||||
|
mVecs[0] = mVecs[3] = 1;
|
||||||
|
mTransformation.getMatrix().mapVectors(mVecs);
|
||||||
|
mVecs[0] = 1.f / mVecs[0];
|
||||||
|
mVecs[3] = 1.f / mVecs[3];
|
||||||
|
final Rect clipRect = mTarget.localBounds;
|
||||||
|
mRect.left = (int) (clipRect.left * mVecs[0] + 0.5f);
|
||||||
|
mRect.right = (int) (clipRect.right * mVecs[0] + 0.5f);
|
||||||
|
mRect.top = (int) (clipRect.top * mVecs[3] + 0.5f);
|
||||||
|
mRect.bottom = (int) (clipRect.bottom * mVecs[3] + 0.5f);
|
||||||
|
mRect.offsetTo(Math.round(mTarget.localBounds.width() * (1 - mVecs[0]) / 2.f),
|
||||||
|
Math.round(mTarget.localBounds.height() * (1 - mVecs[3]) / 2.f));
|
||||||
|
t.setWindowCrop(mLeash, mRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called after animation finished. */
|
/** Called after animation finished. */
|
||||||
@@ -157,8 +175,6 @@ class TaskFragmentAnimationAdapter {
|
|||||||
* Should be used for the animation of the {@link RemoteAnimationTarget} that has size change.
|
* Should be used for the animation of the {@link RemoteAnimationTarget} that has size change.
|
||||||
*/
|
*/
|
||||||
static class BoundsChangeAdapter extends TaskFragmentAnimationAdapter {
|
static class BoundsChangeAdapter extends TaskFragmentAnimationAdapter {
|
||||||
private final float[] mVecs = new float[4];
|
|
||||||
private final Rect mRect = new Rect();
|
|
||||||
|
|
||||||
BoundsChangeAdapter(@NonNull Animation animation, @NonNull RemoteAnimationTarget target) {
|
BoundsChangeAdapter(@NonNull Animation animation, @NonNull RemoteAnimationTarget target) {
|
||||||
super(animation, target);
|
super(animation, target);
|
||||||
|
|||||||
Reference in New Issue
Block a user