Skip to content

Commit fc48edc

Browse files
committed
SF: do not clear contentRequirement when render rate changes
There is no need to clear the contentRequirement when only the render rate changes. Bug: 377240935 Flag: EXEMPT bugfix Test: Running TouchLatency and expanding notification shade Change-Id: I0ce9222958358a4eb87b244ed70430b3105e0396
1 parent 968c9cc commit fc48edc

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

services/surfaceflinger/Scheduler/Scheduler.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ void Scheduler::onHdcpLevelsChanged(Cycle cycle, PhysicalDisplayId displayId,
436436

437437
#pragma clang diagnostic push
438438
#pragma clang diagnostic ignored "-Wunused-value" // b/369277774
439-
bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRateMode& mode) {
439+
bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRateMode& mode,
440+
bool clearContentRequirements) {
440441
const bool isPacesetter =
441442
FTL_FAKE_GUARD(kMainThreadContext,
442443
(std::scoped_lock(mDisplayLock), displayId == mPacesetterDisplayId));
@@ -445,9 +446,11 @@ bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRat
445446
std::lock_guard<std::mutex> lock(mPolicyLock);
446447
mPolicy.emittedModeOpt = mode;
447448

448-
// Invalidate content based refresh rate selection so it could be calculated
449-
// again for the new refresh rate.
450-
mPolicy.contentRequirements.clear();
449+
if (clearContentRequirements) {
450+
// Invalidate content based refresh rate selection so it could be calculated
451+
// again for the new refresh rate.
452+
mPolicy.contentRequirements.clear();
453+
}
451454
}
452455

453456
if (hasEventThreads()) {

services/surfaceflinger/Scheduler/Scheduler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class Scheduler : public IEventThreadCallback, android::impl::MessageQueue {
151151
void dispatchHotplugError(int32_t errorCode);
152152

153153
// Returns true if the PhysicalDisplayId is the pacesetter.
154-
bool onDisplayModeChanged(PhysicalDisplayId, const FrameRateMode&) EXCLUDES(mPolicyLock);
154+
bool onDisplayModeChanged(PhysicalDisplayId, const FrameRateMode&,
155+
bool clearContentRequirements) EXCLUDES(mPolicyLock);
155156

156157
void enableSyntheticVsync(bool = true) REQUIRES(kMainThreadContext);
157158
void omitVsyncDispatching(bool) REQUIRES(kMainThreadContext);

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,8 @@ void SurfaceFlinger::setDesiredMode(display::DisplayModeRequest&& desiredMode) {
13541354
mScheduler->updatePhaseConfiguration(displayId, mode.fps);
13551355

13561356
if (emitEvent) {
1357-
mScheduler->onDisplayModeChanged(displayId, mode);
1357+
mScheduler->onDisplayModeChanged(displayId, mode,
1358+
/*clearContentRequirements*/ false);
13581359
}
13591360
break;
13601361
case DesiredModeAction::None:
@@ -1449,7 +1450,7 @@ void SurfaceFlinger::finalizeDisplayModeChange(PhysicalDisplayId displayId) {
14491450
mScheduler->updatePhaseConfiguration(displayId, activeMode.fps);
14501451

14511452
if (pendingModeOpt->emitEvent) {
1452-
mScheduler->onDisplayModeChanged(displayId, activeMode);
1453+
mScheduler->onDisplayModeChanged(displayId, activeMode, /*clearContentRequirements*/ true);
14531454
}
14541455
}
14551456

@@ -7649,7 +7650,8 @@ status_t SurfaceFlinger::applyRefreshRateSelectorPolicy(
76497650
ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str());
76507651

76517652
if (const bool isPacesetter =
7652-
mScheduler->onDisplayModeChanged(displayId, selector.getActiveMode())) {
7653+
mScheduler->onDisplayModeChanged(displayId, selector.getActiveMode(),
7654+
/*clearContentRequirements*/ true)) {
76537655
mDisplayModeController.updateKernelIdleTimer(displayId);
76547656
}
76557657

services/surfaceflinger/tests/unittests/SchedulerTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ TEST_F(SchedulerTest, emitModeChangeEvent) {
222222
const auto selectorPtr =
223223
std::make_shared<RefreshRateSelector>(kDisplay1Modes, kDisplay1Mode120->getId());
224224
mScheduler->registerDisplay(kDisplayId1, selectorPtr);
225-
mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120);
225+
mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120, true);
226226

227227
mScheduler->setContentRequirements({kLayer});
228228

@@ -250,7 +250,7 @@ TEST_F(SchedulerTest, emitModeChangeEvent) {
250250
EXPECT_CALL(*mEventThread, onModeChanged(kDisplay1Mode120_120)).Times(1);
251251

252252
mScheduler->touchTimerCallback(TimerState::Reset);
253-
mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120);
253+
mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120, true);
254254
}
255255

256256
TEST_F(SchedulerTest, calculateMaxAcquiredBufferCount) {

0 commit comments

Comments
 (0)