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

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

Merge "[VRR] Vote for category when view properties change" into main

parents 07b38431 371a1fe6
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -33984,7 +33984,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    && ((View) parent).mFrameContentVelocity <= 0) {
                viewRootImpl.votePreferredFrameRate(MAX_FRAME_RATE, FRAME_RATE_COMPATIBILITY_GTE);
            }
            if (!willNotDraw() && viewRootImpl.shouldCheckFrameRateCategory()) {
            if (viewRootImpl.shouldCheckFrameRateCategory()) {
                int frameRateCategory = calculateFrameRateCategory();
                int category = frameRateCategory & ~FRAME_RATE_CATEGORY_REASON_MASK;
                int reason = frameRateCategory & FRAME_RATE_CATEGORY_REASON_MASK;
@@ -34026,7 +34026,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
        }
        if (!willNotDraw() && viewRootImpl.shouldCheckFrameRateCategory()) {
        if (viewRootImpl.shouldCheckFrameRateCategory()) {
            if (sToolkitMetricsForFrameRateDecisionFlagValue) {
                int width = mRight - mLeft;
                int height = mBottom - mTop;
@@ -34034,7 +34034,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                viewRootImpl.recordViewPercentage(sizePercentage);
            }
            int frameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE;
            int frameRateCategory;
            if (Float.isNaN(frameRate)) {
                frameRateCategory = calculateFrameRateCategory();
            } else if (frameRate < 0) {
@@ -34059,6 +34059,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                                | FRAME_RATE_CATEGORY_REASON_INVALID;
                    }
                }
            } else {
                // Category doesn't control it. It is directly controlled by frame rate
                frameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE
                        | FRAME_RATE_CATEGORY_REASON_REQUESTED;
            }
            int category = frameRateCategory & ~FRAME_RATE_CATEGORY_REASON_MASK;
+27 −0
Original line number Diff line number Diff line
@@ -436,6 +436,33 @@ public class ViewFrameRateTest {
        waitForAfterDraw();
    }

    @Test
    @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY,
            FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY
    })
    public void willNotDrawUsesCategory() throws Throwable {
        mActivityRule.runOnUiThread(() -> {
            mMovingView.setWillNotDraw(true);
            mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_LOW);
        });
        waitForFrameRateCategoryToSettle();
        mActivityRule.runOnUiThread(() -> {
            mMovingView.invalidate();
            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_LOW,
                    mViewRoot.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();
        mActivityRule.runOnUiThread(() -> {
            mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NORMAL);
            mMovingView.setAlpha(0.9f);
            runAfterDraw(() -> {
                assertEquals(FRAME_RATE_CATEGORY_NORMAL,
                        mViewRoot.getLastPreferredFrameRateCategory());
            });
        });
        waitForAfterDraw();
    }

    /**
     * A common behavior is for two different views to be invalidated in succession, but
     * intermittently. We want to treat this as an intermittent invalidation.