Skip to content

Commit 164d006

Browse files
Ram IndaniAndroid (Google) Code Review
authored andcommitted
Merge "Adds getSupportedRefreshRates support" into main
2 parents 5199366 + bee1902 commit 164d006

6 files changed

Lines changed: 33 additions & 0 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,11 @@ void SurfaceComposerClient::getDynamicDisplayInfoInternal(gui::DynamicDisplayInf
28732873
outInfo->hasArrSupport = ginfo.hasArrSupport;
28742874
outInfo->frameRateCategoryRate = ui::FrameRateCategoryRate(ginfo.frameRateCategoryRate.normal,
28752875
ginfo.frameRateCategoryRate.high);
2876+
outInfo->supportedRefreshRates.clear();
2877+
outInfo->supportedRefreshRates.reserve(ginfo.supportedRefreshRates.size());
2878+
for (const auto rate : ginfo.supportedRefreshRates) {
2879+
outInfo->supportedRefreshRates.push_back(static_cast<float>(rate));
2880+
}
28762881
}
28772882

28782883
status_t SurfaceComposerClient::getDynamicDisplayInfoFromId(int64_t displayId,

libs/gui/aidl/android/gui/DynamicDisplayInfo.aidl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ parcelable DynamicDisplayInfo {
5050

5151
// Represents frame rate for FrameRateCategory Normal and High.
5252
FrameRateCategoryRate frameRateCategoryRate;
53+
54+
// All the refresh rates supported for the default display mode.
55+
float[] supportedRefreshRates;
5356
}

libs/ui/include/ui/DynamicDisplayInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ struct DynamicDisplayInfo {
5959

6060
// Represents frame rate for FrameRateCategory Normal and High.
6161
ui::FrameRateCategoryRate frameRateCategoryRate;
62+
63+
// All the refresh rates supported for the default display mode.
64+
std::vector<float> supportedRefreshRates;
6265
};
6366

6467
} // namespace android::ui

services/surfaceflinger/Scheduler/RefreshRateSelector.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,19 @@ Fps RefreshRateSelector::findClosestKnownFrameRate(Fps frameRate) const {
15571557
return distance1 < distance2 ? *lowerBound : *std::prev(lowerBound);
15581558
}
15591559

1560+
std::vector<float> RefreshRateSelector::getSupportedFrameRates() const {
1561+
std::scoped_lock lock(mLock);
1562+
// TODO(b/356986687) Remove the limit once we have the anchor list implementation.
1563+
const size_t frameRatesSize = std::min<size_t>(11, mPrimaryFrameRates.size());
1564+
std::vector<float> supportedFrameRates;
1565+
supportedFrameRates.reserve(frameRatesSize);
1566+
std::transform(mPrimaryFrameRates.rbegin(),
1567+
mPrimaryFrameRates.rbegin() + static_cast<int>(frameRatesSize),
1568+
std::back_inserter(supportedFrameRates),
1569+
[](FrameRateMode mode) { return mode.fps.getValue(); });
1570+
return supportedFrameRates;
1571+
}
1572+
15601573
auto RefreshRateSelector::getIdleTimerAction() const -> KernelIdleTimerAction {
15611574
std::lock_guard lock(mLock);
15621575

services/surfaceflinger/Scheduler/RefreshRateSelector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ class RefreshRateSelector {
441441

442442
std::pair<Fps, Fps> getFrameRateCategoryRates() const { return kFrameRateCategoryRates; }
443443

444+
std::vector<float> getSupportedFrameRates() const EXCLUDES(mLock);
445+
444446
private:
445447
friend struct TestableRefreshRateSelector;
446448

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ void SurfaceFlinger::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo*& info
12311231
const auto [normal, high] = display->refreshRateSelector().getFrameRateCategoryRates();
12321232
ui::FrameRateCategoryRate frameRateCategoryRate(normal.getValue(), high.getValue());
12331233
info->frameRateCategoryRate = frameRateCategoryRate;
1234+
1235+
info->supportedRefreshRates = display->refreshRateSelector().getSupportedFrameRates();
12341236
info->activeColorMode = display->getCompositionDisplay()->getState().colorMode;
12351237
info->hdrCapabilities = filterOut4k30(display->getHdrCapabilities());
12361238

@@ -8643,6 +8645,11 @@ void SurfaceComposerAIDL::getDynamicDisplayInfoInternal(ui::DynamicDisplayInfo&
86438645
gui::FrameRateCategoryRate& frameRateCategoryRate = outInfo->frameRateCategoryRate;
86448646
frameRateCategoryRate.normal = info.frameRateCategoryRate.getNormal();
86458647
frameRateCategoryRate.high = info.frameRateCategoryRate.getHigh();
8648+
outInfo->supportedRefreshRates.clear();
8649+
outInfo->supportedRefreshRates.reserve(info.supportedRefreshRates.size());
8650+
for (float supportedRefreshRate : info.supportedRefreshRates) {
8651+
outInfo->supportedRefreshRates.push_back(supportedRefreshRate);
8652+
}
86468653

86478654
outInfo->supportedColorModes.clear();
86488655
outInfo->supportedColorModes.reserve(info.supportedColorModes.size());

0 commit comments

Comments
 (0)