SurfaceFlinger: optimize frame rate override
On devices that frame rate override cannot be supported
as the device doesn't support refresh rates that are divisors of
each other, there is no point in trying to find a a frame rate override.
Bug: 170502573
Test: atest FrameRateOverrideHostTest
Change-Id: Idfce2573ee58fa695e81a00c85206990baad978e
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index 1f0fc98..d032b6d 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -226,6 +226,10 @@
}
bool Scheduler::isVsyncValid(nsecs_t expectedVsyncTimestamp, uid_t uid) const {
+ if (!mRefreshRateConfigs.supportsFrameRateOverride()) {
+ return true;
+ }
+
const auto frameRate = getFrameRateOverride(uid);
if (!frameRate.has_value()) {
return true;
@@ -239,14 +243,22 @@
return mVsyncSchedule.tracker->isVSyncInPhase(expectedVsyncTimestamp, divider);
}
+impl::EventThread::ThrottleVsyncCallback Scheduler::makeThrottleVsyncCallback() const {
+ if (!mRefreshRateConfigs.supportsFrameRateOverride()) {
+ return {};
+ }
+
+ return [this](nsecs_t expectedVsyncTimestamp, uid_t uid) {
+ return !isVsyncValid(expectedVsyncTimestamp, uid);
+ };
+}
+
Scheduler::ConnectionHandle Scheduler::createConnection(
const char* connectionName, frametimeline::TokenManager* tokenManager,
std::chrono::nanoseconds workDuration, std::chrono::nanoseconds readyDuration,
impl::EventThread::InterceptVSyncsCallback interceptCallback) {
auto vsyncSource = makePrimaryDispSyncSource(connectionName, workDuration, readyDuration);
- auto throttleVsync = [this](nsecs_t expectedVsyncTimestamp, uid_t uid) {
- return !isVsyncValid(expectedVsyncTimestamp, uid);
- };
+ auto throttleVsync = makeThrottleVsyncCallback();
auto eventThread = std::make_unique<impl::EventThread>(std::move(vsyncSource), tokenManager,
std::move(interceptCallback),
std::move(throttleVsync));
@@ -744,6 +756,10 @@
bool Scheduler::updateFrameRateOverrides(
scheduler::RefreshRateConfigs::GlobalSignals consideredSignals, Fps displayRefreshRate) {
+ if (!mRefreshRateConfigs.supportsFrameRateOverride()) {
+ return false;
+ }
+
if (consideredSignals.touch) {
std::lock_guard lock(mFrameRateOverridesMutex);
const bool changed = !mFrameRateOverridesByContent.empty();