From b8d35d105324777191a00b5fb616f34775c29208 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Mon, 14 Dec 2020 13:27:58 -0800 Subject: [PATCH] Provide vsync id for PiP animation The vsync-id is attached to every SurfaceControl.Transaction within PipAnimationController and therefore it's available to onAnimationStart, onAnimationEnd as well as onAnimationUpdate. What's next: may need to provide vsync id for PiP animation running in Launcher process as well. Bug: 166302754 Test: atest PipAnimationControllerTest Change-Id: I5d413320f435e65d7e3e375bb2266e1bba23e0d7 --- .../android/wm/shell/pip/PipAnimationController.java | 11 +++++++++-- .../wm/shell/pip/PipAnimationControllerTest.java | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java index fe018115408a8..3362d2a1ad349 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java @@ -22,6 +22,7 @@ import android.animation.RectEvaluator; import android.animation.ValueAnimator; import android.annotation.IntDef; import android.graphics.Rect; +import android.view.Choreographer; import android.view.SurfaceControl; import com.android.internal.annotations.VisibleForTesting; @@ -327,8 +328,14 @@ public class PipAnimationController { mEndValue = endValue; } - SurfaceControl.Transaction newSurfaceControlTransaction() { - return mSurfaceControlTransactionFactory.getTransaction(); + /** + * @return {@link SurfaceControl.Transaction} instance with vsync-id. + */ + protected SurfaceControl.Transaction newSurfaceControlTransaction() { + final SurfaceControl.Transaction tx = + mSurfaceControlTransactionFactory.getTransaction(); + tx.setFrameTimelineVsync(Choreographer.getSfInstance().getVsyncId()); + return tx; } @VisibleForTesting diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java index 7f280cd124d21..d30fa3830cf3d 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java @@ -196,6 +196,11 @@ public class PipAnimationControllerTest extends ShellTestCase { return this; } + @Override + public SurfaceControl.Transaction setFrameTimelineVsync(long frameTimelineVsyncId) { + return this; + } + @Override public void apply() {} }