SF: Move ownership of VsyncModulator to Scheduler
...as a prerequisite for calculating the VSYNC deadline of the leader
display (and deriving per-display state from it, e.g. present fences,
traces) in the Scheduler.
Bug: 241285475
Bug: 241285191
Test: Boot
Change-Id: Ieea136616435464dd0756525f94441b8e82ad06a
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index bc465ce..1fc1519 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -60,8 +60,12 @@
namespace android::scheduler {
-Scheduler::Scheduler(ICompositor& compositor, ISchedulerCallback& callback, FeatureFlags features)
- : impl::MessageQueue(compositor), mFeatures(features), mSchedulerCallback(callback) {}
+Scheduler::Scheduler(ICompositor& compositor, ISchedulerCallback& callback, FeatureFlags features,
+ sp<VsyncModulator> modulatorPtr)
+ : impl::MessageQueue(compositor),
+ mFeatures(features),
+ mVsyncModulator(std::move(modulatorPtr)),
+ mSchedulerCallback(callback) {}
Scheduler::~Scheduler() {
// MessageQueue depends on VsyncSchedule, so first destroy it.
@@ -186,17 +190,19 @@
};
}
-ConnectionHandle Scheduler::createConnection(const char* connectionName,
- frametimeline::TokenManager* tokenManager,
- std::chrono::nanoseconds workDuration,
- std::chrono::nanoseconds readyDuration) {
- auto throttleVsync = makeThrottleVsyncCallback();
- auto getVsyncPeriod = makeGetVsyncPeriodFunction();
- auto eventThread =
- std::make_unique<impl::EventThread>(connectionName, *mVsyncSchedule, tokenManager,
- std::move(throttleVsync), std::move(getVsyncPeriod),
- workDuration, readyDuration);
- return createConnection(std::move(eventThread));
+ConnectionHandle Scheduler::createEventThread(Cycle cycle,
+ frametimeline::TokenManager* tokenManager,
+ std::chrono::nanoseconds workDuration,
+ std::chrono::nanoseconds readyDuration) {
+ auto eventThread = std::make_unique<impl::EventThread>(cycle == Cycle::Render ? "app" : "appSf",
+ *mVsyncSchedule, tokenManager,
+ makeThrottleVsyncCallback(),
+ makeGetVsyncPeriodFunction(),
+ workDuration, readyDuration);
+
+ auto& handle = cycle == Cycle::Render ? mAppConnectionHandle : mSfConnectionHandle;
+ handle = createConnection(std::move(eventThread));
+ return handle;
}
ConnectionHandle Scheduler::createConnection(std::unique_ptr<EventThread> eventThread) {
@@ -356,6 +362,20 @@
thread->setDuration(workDuration, readyDuration);
}
+void Scheduler::setVsyncConfigSet(const VsyncConfigSet& configs, Period vsyncPeriod) {
+ setVsyncConfig(mVsyncModulator->setVsyncConfigSet(configs), vsyncPeriod);
+}
+
+void Scheduler::setVsyncConfig(const VsyncConfig& config, Period vsyncPeriod) {
+ setDuration(mAppConnectionHandle,
+ /* workDuration */ config.appWorkDuration,
+ /* readyDuration */ config.sfWorkDuration);
+ setDuration(mSfConnectionHandle,
+ /* workDuration */ vsyncPeriod,
+ /* readyDuration */ config.sfWorkDuration);
+ setDuration(config.sfWorkDuration);
+}
+
void Scheduler::enableHardwareVsync() {
std::lock_guard<std::mutex> lock(mHWVsyncLock);
if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) {