diff options
author | 2024-05-07 16:42:51 -0700 | |
---|---|---|
committer | 2024-05-24 04:04:21 +0000 | |
commit | c6e522e2af6734ac2f9f7d5d469583c5b0fff9f6 (patch) | |
tree | 71d0b4504fb015c96a0c1ae3ad5ba9ac499fd0bf | |
parent | a48361eb933c2d5074e2ff72ff8d515d794738fe (diff) |
[SF] Use Render rate for Refresh rate
When VRR device does not support refresh rate debug indicator callback
Use the render rate as the refresh rate on the indicator.
Test: Manually tested refresh rate indicator on device that supports the
callback and device that doesn't
BUG: 326137213
Change-Id: Ifd0d34909b831991d4525f2b5138e71e4a76c4d6
-rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/RefreshRateOverlay.cpp | 18 | ||||
-rw-r--r-- | services/surfaceflinger/RefreshRateOverlay.h | 2 |
3 files changed, 10 insertions, 14 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 38cf05327f..a57e626224 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -474,7 +474,6 @@ void DisplayDevice::enableRefreshRateOverlay(bool enable, bool setByHwc, bool sh features |= RefreshRateOverlay::Features::SetByHwc; } - // TODO(b/296636258) Update to use the render rate range in VRR mode. const auto fpsRange = mRefreshRateSelector->getSupportedRefreshRateRange(); mRefreshRateOverlay = RefreshRateOverlay::create(fpsRange, features); if (mRefreshRateOverlay) { @@ -489,6 +488,9 @@ void DisplayDevice::updateRefreshRateOverlayRate(Fps refreshRate, Fps renderFps, ATRACE_CALL(); if (mRefreshRateOverlay) { if (!mRefreshRateOverlay->isSetByHwc() || setByHwc) { + if (mRefreshRateSelector->isVrrDevice() && !mRefreshRateOverlay->isSetByHwc()) { + refreshRate = renderFps; + } mRefreshRateOverlay->changeRefreshRate(refreshRate, renderFps); } else { mRefreshRateOverlay->changeRenderRate(renderFps); diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp index b40f3323bc..9527a997df 100644 --- a/services/surfaceflinger/RefreshRateOverlay.cpp +++ b/services/surfaceflinger/RefreshRateOverlay.cpp @@ -200,19 +200,13 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps refreshRate, Fps renderFps) -> c BufferCache::const_iterator it = mBufferCache.find({refreshRate.getIntValue(), renderFps.getIntValue(), transformHint}); if (it == mBufferCache.end()) { - // HWC minFps is not known by the framework in order - // to consider lower rates we set minFps to 0. - const int minFps = isSetByHwc() ? 0 : mFpsRange.min.getIntValue(); const int maxFps = mFpsRange.max.getIntValue(); - // Clamp to the range. The current refreshRate may be outside of this range if the display - // has changed its set of supported refresh rates. - const int displayIntFps = std::clamp(refreshRate.getIntValue(), minFps, maxFps); + // Clamp to supported refresh rate range: the current refresh rate may be outside of this + // range if the display has changed its set of supported refresh rates. + const int refreshIntFps = std::clamp(refreshRate.getIntValue(), 0, maxFps); const int renderIntFps = renderFps.getIntValue(); - - // Ensure non-zero range to avoid division by zero. - const float fpsScale = - static_cast<float>(displayIntFps - minFps) / std::max(1, maxFps - minFps); + const float fpsScale = static_cast<float>(refreshIntFps) / maxFps; constexpr SkColor kMinFpsColor = SK_ColorRED; constexpr SkColor kMaxFpsColor = SK_ColorGREEN; @@ -228,9 +222,9 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps refreshRate, Fps renderFps) -> c const SkColor color = colorBase.toSkColor(); - auto buffers = draw(displayIntFps, renderIntFps, color, transformHint, mFeatures); + auto buffers = draw(refreshIntFps, renderIntFps, color, transformHint, mFeatures); it = mBufferCache - .try_emplace({displayIntFps, renderIntFps, transformHint}, std::move(buffers)) + .try_emplace({refreshIntFps, renderIntFps, transformHint}, std::move(buffers)) .first; } diff --git a/services/surfaceflinger/RefreshRateOverlay.h b/services/surfaceflinger/RefreshRateOverlay.h index 93ec36e7f8..b2896f07dd 100644 --- a/services/surfaceflinger/RefreshRateOverlay.h +++ b/services/surfaceflinger/RefreshRateOverlay.h @@ -65,7 +65,7 @@ private: using Buffers = std::vector<sp<GraphicBuffer>>; - static Buffers draw(int vsyncRate, int renderFps, SkColor, ui::Transform::RotationFlags, + static Buffers draw(int refreshRate, int renderFps, SkColor, ui::Transform::RotationFlags, ftl::Flags<Features>); static void drawNumber(int number, int left, SkColor, SkCanvas&); |