[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
diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp
index b40f332..9527a99 100644
--- a/services/surfaceflinger/RefreshRateOverlay.cpp
+++ b/services/surfaceflinger/RefreshRateOverlay.cpp
@@ -200,19 +200,13 @@
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 @@
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;
}