summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/RefreshRateOverlay.cpp
diff options
context:
space:
mode:
author ramindani <ramindani@google.com> 2023-08-07 18:49:47 -0700
committer ramindani <ramindani@google.com> 2023-09-11 13:12:54 -0700
commita04b8a5e0864b1064538db4e6dd887d2fc58dfe5 (patch)
treed553e297b3469a2cb62ea9baeeaf10bb47b09ef9 /services/surfaceflinger/RefreshRateOverlay.cpp
parent70465c42c69b99720004d5db76f17045abea5ce5 (diff)
[SF] Update DisplayMode::Fps with PeakFps
Update to incorporate display refresh rate on DisplayMode With the addition of VRR, vsync period does not necessarily represent the refresh rate of the display, having a peakRefreshRate that represents the display peak refresh rate helps with separating the concern of vsync period being different from the peak refresh rate supported by the device. Test: atest libsurfaceflinger_unittest BUG: 286048920 BUG: 284845445 Change-Id: I9d90e4def4cf3efcd5a696a4ec43fbf7698abfe4
Diffstat (limited to 'services/surfaceflinger/RefreshRateOverlay.cpp')
-rw-r--r--services/surfaceflinger/RefreshRateOverlay.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp
index 577211f461..e918dc9045 100644
--- a/services/surfaceflinger/RefreshRateOverlay.cpp
+++ b/services/surfaceflinger/RefreshRateOverlay.cpp
@@ -27,7 +27,7 @@
namespace android {
-auto RefreshRateOverlay::draw(int displayFps, int renderFps, SkColor color,
+auto RefreshRateOverlay::draw(int vsyncRate, int renderFps, SkColor color,
ui::Transform::RotationFlags rotation, ftl::Flags<Features> features)
-> Buffers {
const size_t loopCount = features.test(Features::Spinner) ? 6 : 1;
@@ -70,7 +70,7 @@ auto RefreshRateOverlay::draw(int displayFps, int renderFps, SkColor color,
canvas->setMatrix(canvasTransform);
int left = 0;
- drawNumber(displayFps, left, color, *canvas);
+ drawNumber(vsyncRate, left, color, *canvas);
left += 3 * (kDigitWidth + kDigitSpace);
if (features.test(Features::Spinner)) {
switch (i) {
@@ -153,7 +153,7 @@ RefreshRateOverlay::RefreshRateOverlay(FpsRange fpsRange, ftl::Flags<Features> f
.apply();
}
-auto RefreshRateOverlay::getOrCreateBuffers(Fps displayFps, Fps renderFps) -> const Buffers& {
+auto RefreshRateOverlay::getOrCreateBuffers(Fps vsyncRate, Fps renderFps) -> const Buffers& {
static const Buffers kNoBuffers;
if (!mSurfaceControl) return kNoBuffers;
@@ -180,16 +180,16 @@ auto RefreshRateOverlay::getOrCreateBuffers(Fps displayFps, Fps renderFps) -> co
createTransaction().setTransform(mSurfaceControl->get(), transform).apply();
BufferCache::const_iterator it =
- mBufferCache.find({displayFps.getIntValue(), renderFps.getIntValue(), transformHint});
+ mBufferCache.find({vsyncRate.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 displayFps may be outside of this range if the display
+ // Clamp to the range. The current vsyncRate may be outside of this range if the display
// has changed its set of supported refresh rates.
- const int displayIntFps = std::clamp(displayFps.getIntValue(), minFps, maxFps);
+ const int displayIntFps = std::clamp(vsyncRate.getIntValue(), minFps, maxFps);
const int renderIntFps = renderFps.getIntValue();
// Ensure non-zero range to avoid division by zero.
@@ -242,17 +242,17 @@ void RefreshRateOverlay::setLayerStack(ui::LayerStack stack) {
createTransaction().setLayerStack(mSurfaceControl->get(), stack).apply();
}
-void RefreshRateOverlay::changeRefreshRate(Fps displayFps, Fps renderFps) {
- mDisplayFps = displayFps;
+void RefreshRateOverlay::changeRefreshRate(Fps vsyncRate, Fps renderFps) {
+ mVsyncRate = vsyncRate;
mRenderFps = renderFps;
- const auto buffer = getOrCreateBuffers(displayFps, renderFps)[mFrame];
+ const auto buffer = getOrCreateBuffers(vsyncRate, renderFps)[mFrame];
createTransaction().setBuffer(mSurfaceControl->get(), buffer).apply();
}
void RefreshRateOverlay::animate() {
- if (!mFeatures.test(Features::Spinner) || !mDisplayFps) return;
+ if (!mFeatures.test(Features::Spinner) || !mVsyncRate) return;
- const auto& buffers = getOrCreateBuffers(*mDisplayFps, *mRenderFps);
+ const auto& buffers = getOrCreateBuffers(*mVsyncRate, *mRenderFps);
mFrame = (mFrame + 1) % buffers.size();
const auto buffer = buffers[mFrame];
createTransaction().setBuffer(mSurfaceControl->get(), buffer).apply();