Merge "Change surface crop/visibilty on to-fullscreen animations" into udc-dev

This commit is contained in:
Jorge Gil
2023-04-24 20:02:31 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 19 deletions

View File

@@ -193,8 +193,11 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
// This Transition animates a task to fullscreen after being dragged from the status
// bar and then released back into the status bar area
final SurfaceControl sc = change.getLeash();
startT.setWindowCrop(sc, null);
startT.apply();
// Hide the first (fullscreen) frame because the animation will start from the smaller
// scale size.
startT.hide(sc)
.setWindowCrop(sc, endBounds.width(), endBounds.height())
.apply();
final ValueAnimator animator = new ValueAnimator();
animator.setFloatValues(DRAG_FREEFORM_SCALE, 1f);
@@ -202,10 +205,10 @@ public class EnterDesktopTaskTransitionHandler implements Transitions.Transition
final SurfaceControl.Transaction t = mTransactionSupplier.get();
animator.addUpdateListener(animation -> {
final float scale = animation.getAnimatedFraction();
t.setPosition(sc, mStartPosition.x * (1 - scale),
mStartPosition.y * (1 - scale));
t.setScale(sc, scale, scale);
t.apply();
t.setPosition(sc, mStartPosition.x * (1 - scale), mStartPosition.y * (1 - scale))
.setScale(sc, scale, scale)
.show(sc)
.apply();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override

View File

@@ -129,8 +129,12 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
final int screenWidth = metrics.widthPixels;
final int screenHeight = metrics.heightPixels;
final SurfaceControl sc = change.getLeash();
startT.setCrop(sc, null);
startT.apply();
final Rect endBounds = change.getEndAbsBounds();
// Hide the first (fullscreen) frame because the animation will start from the freeform
// size.
startT.hide(sc)
.setWindowCrop(sc, endBounds.width(), endBounds.height())
.apply();
final ValueAnimator animator = new ValueAnimator();
animator.setFloatValues(0f, 1f);
animator.setDuration(FULLSCREEN_ANIMATION_DURATION);
@@ -144,9 +148,10 @@ public class ExitDesktopTaskTransitionHandler implements Transitions.TransitionH
float fraction = animation.getAnimatedFraction();
float currentScaleX = scaleX + ((1 - scaleX) * fraction);
float currentScaleY = scaleY + ((1 - scaleY) * fraction);
t.setPosition(sc, startPos.x * (1 - fraction), startPos.y * (1 - fraction));
t.setScale(sc, currentScaleX, currentScaleY);
t.apply();
t.setPosition(sc, startPos.x * (1 - fraction), startPos.y * (1 - fraction))
.setScale(sc, currentScaleX, currentScaleY)
.show(sc)
.apply();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override

View File

@@ -71,12 +71,6 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
@Mock
Resources mResources;
@Mock
SurfaceControl.Transaction mStartT;
@Mock
SurfaceControl.Transaction mFinishT;
@Mock
SurfaceControl.Transaction mAnimationT;
@Mock
Transitions.TransitionFinishCallback mTransitionFinishCallback;
@Mock
ShellExecutor mExecutor;
@@ -88,7 +82,7 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
MockitoAnnotations.initMocks(this);
doReturn(mExecutor).when(mTransitions).getMainExecutor();
doReturn(mAnimationT).when(mTransactionFactory).get();
doReturn(new SurfaceControl.Transaction()).when(mTransactionFactory).get();
doReturn(mResources).when(mContext).getResources();
doReturn(mDisplayMetrics).when(mResources).getDisplayMetrics();
when(mResources.getDisplayMetrics())
@@ -115,7 +109,9 @@ public class ExitDesktopTaskTransitionHandlerTest extends ShellTestCase {
runOnUiThread(() -> {
try {
assertTrue(mExitDesktopTaskTransitionHandler
.startAnimation(mToken, info, mStartT, mFinishT,
.startAnimation(mToken, info,
new SurfaceControl.Transaction(),
new SurfaceControl.Transaction(),
mTransitionFinishCallback));
} catch (Exception e) {
exceptions.add(e);