Loading core/java/android/view/View.java +7 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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; core/tests/coretests/src/android/view/ViewFrameRateTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading
core/java/android/view/View.java +7 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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) { Loading @@ -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;
core/tests/coretests/src/android/view/ViewFrameRateTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -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. Loading