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

Commit 96d1428c authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Fix ViewFrameRateTest" into main

parents 1d9fb990 7a84b190
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -33942,7 +33942,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return; // can't vote if not connected
            return; // can't vote if not connected
        }
        }
        float velocity = mFrameContentVelocity;
        float velocity = mFrameContentVelocity;
        float frameRate = mPreferredFrameRate;
        final float frameRate = mPreferredFrameRate;
        ViewParent parent = mParent;
        ViewParent parent = mParent;
        if (velocity <= 0 && Float.isNaN(frameRate)) {
        if (velocity <= 0 && Float.isNaN(frameRate)) {
            // The most common case is when nothing is set, so this special case is called
            // The most common case is when nothing is set, so this special case is called
@@ -33982,13 +33982,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            }
            if (velocityFrameRate > 0f || frameRate > 0f) {
            if (velocityFrameRate > 0f || frameRate > 0f) {
                int compatibility;
                int compatibility;
                float frameRateToSet;
                if (frameRate >= velocityFrameRate) {
                if (frameRate >= velocityFrameRate) {
                    compatibility = FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
                    compatibility = FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
                    frameRateToSet = frameRate;
                } else {
                } else {
                    compatibility = FRAME_RATE_COMPATIBILITY_GTE;
                    compatibility = FRAME_RATE_COMPATIBILITY_GTE;
                    frameRate = velocityFrameRate;
                    frameRateToSet = velocityFrameRate;
                }
                }
                viewRootImpl.votePreferredFrameRate(frameRate, compatibility);
                viewRootImpl.votePreferredFrameRate(frameRateToSet, compatibility);
            }
            }
        }
        }
@@ -34052,7 +34054,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    public void setFrameContentVelocity(float pixelsPerSecond) {
    public void setFrameContentVelocity(float pixelsPerSecond) {
        if (viewVelocityApi()) {
        if (mAttachInfo != null && mAttachInfo.mViewVelocityApi) {
            mFrameContentVelocity = Math.abs(pixelsPerSecond);
            mFrameContentVelocity = Math.abs(pixelsPerSecond);
            if (sToolkitMetricsForFrameRateDecisionFlagValue) {
            if (sToolkitMetricsForFrameRateDecisionFlagValue) {
@@ -34070,8 +34072,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
     */
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    @FlaggedApi(FLAG_VIEW_VELOCITY_API)
    public float getFrameContentVelocity() {
    public float getFrameContentVelocity() {
        if (viewVelocityApi()) {
        if (mAttachInfo != null && mAttachInfo.mViewVelocityApi) {
            return (mFrameContentVelocity < 0f) ? 0f : mFrameContentVelocity;
            return Math.max(mFrameContentVelocity, 0f);
        }
        }
        return 0;
        return 0;
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -183,6 +183,7 @@ public class ViewFrameRateTest {
        mActivityRule.runOnUiThread(() -> {
        mActivityRule.runOnUiThread(() -> {
            frameLayout.setFrameContentVelocity(1f);
            frameLayout.setFrameContentVelocity(1f);
            mMovingView.offsetTopAndBottom(100);
            mMovingView.offsetTopAndBottom(100);
            frameLayout.invalidate();
            runAfterDraw(() -> assertEquals(60f, mViewRoot.getLastPreferredFrameRate(), 0f));
            runAfterDraw(() -> assertEquals(60f, mViewRoot.getLastPreferredFrameRate(), 0f));
        });
        });
        waitForAfterDraw();
        waitForAfterDraw();