Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5a34c4c authored by Jian-Syuan (Shane) Wong's avatar Jian-Syuan (Shane) Wong Committed by Android (Google) Code Review
Browse files

Merge "[VRR] Boost frame rate when calling ApplyLegacyAnimation" into main

parents c4ea9875 c91e4c26
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY;
import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API;
import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout;
import static android.view.flags.Flags.sensitiveContentAppProtection;
import static android.view.flags.Flags.toolkitFrameRateAnimationBugfix25q1;
import static android.view.flags.Flags.toolkitFrameRateBySizeReadOnly;
import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly;
import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly;
@@ -2458,13 +2459,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            toolkitFrameRateDefaultNormalReadOnly();
    private static final boolean sToolkitFrameRateBySizeReadOnlyFlagValue =
            toolkitFrameRateBySizeReadOnly();
    private static final boolean sToolkitFrameRateSmallUsesPercentReadOnlyFlagValue =
            toolkitFrameRateSmallUsesPercentReadOnly();
    private static final boolean sToolkitFrameRateViewEnablingReadOnlyFlagValue =
            toolkitFrameRateViewEnablingReadOnly();
    private static boolean sToolkitFrameRateVelocityMappingReadOnlyFlagValue =
            toolkitFrameRateVelocityMappingReadOnly();
    private static boolean sToolkitFrameRateAnimationBugfix25q1FlagValue =
            toolkitFrameRateAnimationBugfix25q1();
    // Used to set frame rate compatibility.
    @Surface.FrameRateCompatibility int mFrameRateCompatibility =
@@ -24429,6 +24431,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            invalidationTransform = t;
        }
        // Increase the frame rate if there is a transformation that applies a matrix.
        if (sToolkitFrameRateAnimationBugfix25q1FlagValue
                && ((t.getTransformationType() & Transformation.TYPE_MATRIX) != 0)) {
            mPrivateFlags4 |= PFLAG4_HAS_VIEW_PROPERTY_INVALIDATION;
            mPrivateFlags4 |= PFLAG4_HAS_MOVED;
        }
        if (more) {
            if (!a.willChangeBounds()) {
                if ((flags & (ViewGroup.FLAG_OPTIMIZE_INVALIDATE | ViewGroup.FLAG_ANIMATION_DONE)) ==
+8 −0
Original line number Diff line number Diff line
@@ -112,3 +112,11 @@ flag {
    bug: "335874198"
    is_fixed_read_only: true
}

flag {
    name: "toolkit_frame_rate_animation_bugfix_25q1"
    namespace: "toolkit"
    description: "Feature flag to enable the fix for applyLegacyAnimation for VRR V QPR2"
    bug: "335874198"
    is_fixed_read_only: true
}
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_LOW;
import static android.view.Surface.FRAME_RATE_CATEGORY_NORMAL;
import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1;
import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY;
import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY;
import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY;
@@ -46,6 +47,8 @@ import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.sysprop.ViewProperties;
import android.util.DisplayMetrics;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ProgressBar;

@@ -1023,6 +1026,30 @@ public class ViewFrameRateTest {
        });
    }

    @Test
    @RequiresFlagsEnabled(FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1)
    public void boostWhenApplyLegacyAnimation() throws Throwable {
        if (!ViewProperties.vrr_enabled().orElse(true)) {
            return;
        }
        waitForFrameRateCategoryToSettle();
        mActivityRule.runOnUiThread(() -> {
            TranslateAnimation translateAnimation = new TranslateAnimation(
                    Animation.RELATIVE_TO_PARENT, 0f, // fromXDelta
                    Animation.RELATIVE_TO_PARENT, 0f, // toXDelta
                    Animation.RELATIVE_TO_PARENT, 1f, // fromYDelta (100%p)
                    Animation.RELATIVE_TO_PARENT, 0f  // toYDelta
            );
            translateAnimation.setDuration(600);

            mMovingView.startAnimation(translateAnimation);

            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_HIGH_HINT,
                    mViewRoot.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();
    }

    private void runAfterDraw(@NonNull Runnable runnable) {
        Handler handler = new Handler(Looper.getMainLooper());
        mAfterDrawLatch = new CountDownLatch(1);