SF: Merge on{,Non}PrimaryDisplayModeChanged
Branch on the pacesetter rather than active display, though they are the
same display in practice for now.
Bug: 255635821
Flag: EXEMPT refactor
Test: presubmit
Change-Id: I40d73e79075893826492b85c27e35eed59b4b289
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c616a70..9633cc5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1358,7 +1358,7 @@
}
if (emitEvent) {
- dispatchDisplayModeChangeEvent(displayId, mode);
+ mScheduler->onDisplayModeChanged(displayId, mode);
}
break;
case DesiredModeAction::None:
@@ -1455,7 +1455,7 @@
}
if (pendingModeOpt->emitEvent) {
- dispatchDisplayModeChangeEvent(displayId, activeMode);
+ mScheduler->onDisplayModeChanged(displayId, activeMode);
}
}
@@ -3589,16 +3589,6 @@
mPhysicalDisplays.erase(displayId);
}
-void SurfaceFlinger::dispatchDisplayModeChangeEvent(PhysicalDisplayId displayId,
- const scheduler::FrameRateMode& mode) {
- // TODO(b/255635821): Merge code paths and move to Scheduler.
- const auto onDisplayModeChanged = displayId == mActiveDisplayId
- ? &scheduler::Scheduler::onPrimaryDisplayModeChanged
- : &scheduler::Scheduler::onNonPrimaryDisplayModeChanged;
-
- ((*mScheduler).*onDisplayModeChanged)(mode);
-}
-
sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
const wp<IBinder>& displayToken,
std::shared_ptr<compositionengine::Display> compositionDisplay,
@@ -7959,13 +7949,9 @@
const scheduler::RefreshRateSelector::Policy currentPolicy = selector.getCurrentPolicy();
ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str());
- // TODO(b/140204874): Leave the event in until we do proper testing with all apps that might
- // be depending in this callback.
- if (const auto activeMode = selector.getActiveMode(); displayId == mActiveDisplayId) {
- mScheduler->onPrimaryDisplayModeChanged(activeMode);
+ if (const bool isPacesetter =
+ mScheduler->onDisplayModeChanged(displayId, selector.getActiveMode())) {
toggleKernelIdleTimer();
- } else {
- mScheduler->onNonPrimaryDisplayModeChanged(activeMode);
}
auto preferredModeOpt = getPreferredDisplayMode(displayId, currentPolicy.defaultMode);