Merge "Don't offset snapshot surface position" into sc-v2-dev
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package androidx.window.extensions.embedding;
|
package androidx.window.extensions.embedding;
|
||||||
|
|
||||||
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.Choreographer;
|
import android.view.Choreographer;
|
||||||
import android.view.RemoteAnimationTarget;
|
import android.view.RemoteAnimationTarget;
|
||||||
@@ -24,6 +25,7 @@ import android.view.animation.Animation;
|
|||||||
import android.view.animation.Transformation;
|
import android.view.animation.Transformation;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper to handle the TaskFragment animation update in one {@link SurfaceControl.Transaction}.
|
* Wrapper to handle the TaskFragment animation update in one {@link SurfaceControl.Transaction}.
|
||||||
@@ -33,6 +35,7 @@ class TaskFragmentAnimationAdapter {
|
|||||||
private final RemoteAnimationTarget mTarget;
|
private final RemoteAnimationTarget mTarget;
|
||||||
private final SurfaceControl mLeash;
|
private final SurfaceControl mLeash;
|
||||||
private final boolean mSizeChanged;
|
private final boolean mSizeChanged;
|
||||||
|
private final Point mPosition;
|
||||||
private final Transformation mTransformation = new Transformation();
|
private final Transformation mTransformation = new Transformation();
|
||||||
private final float[] mMatrix = new float[9];
|
private final float[] mMatrix = new float[9];
|
||||||
private final float[] mVecs = new float[4];
|
private final float[] mVecs = new float[4];
|
||||||
@@ -41,7 +44,7 @@ class TaskFragmentAnimationAdapter {
|
|||||||
|
|
||||||
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
||||||
@NonNull RemoteAnimationTarget target) {
|
@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,
|
TaskFragmentAnimationAdapter(@NonNull Animation animation,
|
||||||
@NonNull RemoteAnimationTarget target, @NonNull SurfaceControl leash,
|
@NonNull RemoteAnimationTarget target, @NonNull SurfaceControl leash,
|
||||||
boolean sizeChanged) {
|
boolean sizeChanged, @Nullable Point position) {
|
||||||
mAnimation = animation;
|
mAnimation = animation;
|
||||||
mTarget = target;
|
mTarget = target;
|
||||||
mLeash = leash;
|
mLeash = leash;
|
||||||
mSizeChanged = sizeChanged;
|
mSizeChanged = sizeChanged;
|
||||||
|
mPosition = position != null
|
||||||
|
? position
|
||||||
|
: new Point(target.localBounds.left, target.localBounds.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called on frame update. */
|
/** Called on frame update. */
|
||||||
@@ -65,8 +71,7 @@ class TaskFragmentAnimationAdapter {
|
|||||||
|
|
||||||
currentPlayTime = Math.min(currentPlayTime, mAnimation.getDuration());
|
currentPlayTime = Math.min(currentPlayTime, mAnimation.getDuration());
|
||||||
mAnimation.getTransformation(currentPlayTime, mTransformation);
|
mAnimation.getTransformation(currentPlayTime, mTransformation);
|
||||||
mTransformation.getMatrix().postTranslate(
|
mTransformation.getMatrix().postTranslate(mPosition.x, mPosition.y);
|
||||||
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());
|
||||||
t.setFrameTimelineVsync(Choreographer.getInstance().getVsyncId());
|
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.Animator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -193,10 +194,12 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub {
|
|||||||
if (target.startBounds != null) {
|
if (target.startBounds != null) {
|
||||||
final Animation[] animations =
|
final Animation[] animations =
|
||||||
mAnimationSpec.createChangeBoundsChangeAnimations(target);
|
mAnimationSpec.createChangeBoundsChangeAnimations(target);
|
||||||
|
// The snapshot surface will always be at (0, 0) of its parent.
|
||||||
adapters.add(new TaskFragmentAnimationAdapter(animations[0], target,
|
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,
|
adapters.add(new TaskFragmentAnimationAdapter(animations[1], target,
|
||||||
target.leash, true /* sizeChanged */));
|
target.leash, true /* sizeChanged */, null /* position */));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user