Merge "Don't offset snapshot surface position" into sc-v2-dev am: 1ee1dd38a0 am: 1a92fca57b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15899311 Change-Id: I7d82d4595da29028a15e021b5fac23fd8aef116a
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package androidx.window.extensions.embedding;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.Choreographer;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
@@ -24,6 +25,7 @@ import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Wrapper to handle the TaskFragment animation update in one {@link SurfaceControl.Transaction}.
|
||||
@@ -33,6 +35,7 @@ class TaskFragmentAnimationAdapter {
|
||||
private final RemoteAnimationTarget mTarget;
|
||||
private final SurfaceControl mLeash;
|
||||
private final boolean mSizeChanged;
|
||||
private final Point mPosition;
|
||||
private final Transformation mTransformation = new Transformation();
|
||||
private final float[] mMatrix = new float[9];
|
||||
private final float[] mVecs = new float[4];
|
||||
@@ -41,7 +44,7 @@ class TaskFragmentAnimationAdapter {
|
||||
|
||||
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
||||
@NonNull RemoteAnimationTarget target) {
|
||||
this(animation, target, target.leash, false /* sizeChanged */);
|
||||
this(animation, target, target.leash, false /* sizeChanged */, null /* position */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,11 +52,14 @@ class TaskFragmentAnimationAdapter {
|
||||
*/
|
||||
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
||||
@NonNull RemoteAnimationTarget target, @NonNull SurfaceControl leash,
|
||||
boolean sizeChanged) {
|
||||
boolean sizeChanged, @Nullable Point position) {
|
||||
mAnimation = animation;
|
||||
mTarget = target;
|
||||
mLeash = leash;
|
||||
mSizeChanged = sizeChanged;
|
||||
mPosition = position != null
|
||||
? position
|
||||
: new Point(target.localBounds.left, target.localBounds.top);
|
||||
}
|
||||
|
||||
/** Called on frame update. */
|
||||
@@ -65,8 +71,7 @@ class TaskFragmentAnimationAdapter {
|
||||
|
||||
currentPlayTime = Math.min(currentPlayTime, mAnimation.getDuration());
|
||||
mAnimation.getTransformation(currentPlayTime, mTransformation);
|
||||
mTransformation.getMatrix().postTranslate(
|
||||
mTarget.localBounds.left, mTarget.localBounds.top);
|
||||
mTransformation.getMatrix().postTranslate(mPosition.x, mPosition.y);
|
||||
t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
|
||||
t.setAlpha(mLeash, mTransformation.getAlpha());
|
||||
t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
|
||||
|
||||
@@ -23,6 +23,7 @@ import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_OPEN;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.Point;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
@@ -193,10 +194,12 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
|
||||
if (target.startBounds != null) {
|
||||
final Animation[] animations =
|
||||
mAnimationSpec.createChangeBoundsChangeAnimations(target);
|
||||
// The snapshot surface will always be at (0, 0) of its parent.
|
||||
adapters.add(new TaskFragmentAnimationAdapter(animations[0], target,
|
||||
target.startLeash, false /* sizeChanged */));
|
||||
target.startLeash, false /* sizeChanged */, new Point(0, 0)));
|
||||
// The end surface will have size change for scaling.
|
||||
adapters.add(new TaskFragmentAnimationAdapter(animations[1], target,
|
||||
target.leash, true /* sizeChanged */));
|
||||
target.leash, true /* sizeChanged */, null /* position */));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user