Loading services/surfaceflinger/Scheduler/VSyncReactor.cpp +29 −14 Original line number Diff line number Diff line Loading @@ -51,6 +51,25 @@ VSyncReactor::VSyncReactor(PhysicalDisplayId id, std::unique_ptr<Clock> clock, VSyncReactor::~VSyncReactor() = default; bool VSyncReactor::updateTrackerWithSignaledFences() { bool timestampAccepted = true; for (auto it = mUnfiredFences.begin(); it != mUnfiredFences.end();) { auto const time = FlagManager::getInstance().reset_model_flushes_fence() ? (*it)->getSignalTime() : (*it)->getCachedSignalTime(); if (time == Fence::SIGNAL_TIME_PENDING) { it++; } else if (time == Fence::SIGNAL_TIME_INVALID) { it = mUnfiredFences.erase(it); } else { timestampAccepted &= mTracker.addVsyncTimestamp(time); it = mUnfiredFences.erase(it); } } return timestampAccepted; } bool VSyncReactor::addPresentFence(std::shared_ptr<FenceTime> fence) { SFTRACE_CALL(); Loading @@ -70,20 +89,7 @@ bool VSyncReactor::addPresentFence(std::shared_ptr<FenceTime> fence) { return true; } bool timestampAccepted = true; for (auto it = mUnfiredFences.begin(); it != mUnfiredFences.end();) { auto const time = (*it)->getCachedSignalTime(); if (time == Fence::SIGNAL_TIME_PENDING) { it++; } else if (time == Fence::SIGNAL_TIME_INVALID) { it = mUnfiredFences.erase(it); } else { timestampAccepted &= mTracker.addVsyncTimestamp(time); it = mUnfiredFences.erase(it); } } bool timestampAccepted = updateTrackerWithSignaledFences(); if (signalTime == Fence::SIGNAL_TIME_PENDING) { if (mPendingLimit == mUnfiredFences.size()) { mUnfiredFences.erase(mUnfiredFences.begin()); Loading Loading @@ -115,6 +121,9 @@ void VSyncReactor::setIgnorePresentFencesInternal(bool ignore) { void VSyncReactor::updateIgnorePresentFencesInternal() { if (mExternalIgnoreFences || mInternalIgnoreFences) { if (FlagManager::getInstance().reset_model_flushes_fence()) { updateTrackerWithSignaledFences(); } mUnfiredFences.clear(); } } Loading Loading @@ -233,6 +242,12 @@ void VSyncReactor::setDisplayPowerMode(hal::PowerMode powerMode) { mDisplayPowerMode = powerMode; } void VSyncReactor::resetModel() { std::lock_guard lock(mMutex); updateTrackerWithSignaledFences(); mTracker.resetModel(); } void VSyncReactor::dump(std::string& result) const { std::lock_guard lock(mMutex); StringAppendF(&result, "VsyncReactor in use\n"); Loading services/surfaceflinger/Scheduler/VSyncReactor.h +3 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ public: void setDisplayPowerMode(hal::PowerMode powerMode) final; void resetModel() final; void dump(std::string& result) const final; private: Loading @@ -62,6 +64,7 @@ private: void endPeriodTransition() REQUIRES(mMutex); bool periodConfirmed(nsecs_t vsync_timestamp, std::optional<nsecs_t> hwcVsyncPeriod) REQUIRES(mMutex); bool updateTrackerWithSignaledFences() REQUIRES(mMutex); const PhysicalDisplayId mId; std::unique_ptr<Clock> const mClock; Loading services/surfaceflinger/Scheduler/VsyncController.h +5 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,11 @@ public: */ virtual void setDisplayPowerMode(hal::PowerMode powerMode) = 0; /* * Resets the vsync model */ virtual void resetModel() = 0; virtual void dump(std::string& result) const = 0; protected: Loading services/surfaceflinger/Scheduler/VsyncSchedule.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,11 @@ void VsyncSchedule::enableHardwareVsync() { void VsyncSchedule::enableHardwareVsyncLocked() { SFTRACE_CALL(); if (mHwVsyncState == HwVsyncState::Disabled) { if (FlagManager::getInstance().reset_model_flushes_fence()) { mController->resetModel(); } else { getTracker().resetModel(); } mRequestHardwareVsync(mId, true); mHwVsyncState = HwVsyncState::Enabled; } Loading services/surfaceflinger/tests/unittests/mock/MockVsyncController.h +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ public: MOCK_METHOD(void, onDisplayModeChanged, (ftl::NonNull<DisplayModePtr>, bool), (override)); MOCK_METHOD(void, setIgnorePresentFences, (bool), (override)); MOCK_METHOD(void, setDisplayPowerMode, (hal::PowerMode), (override)); MOCK_METHOD(void, resetModel, (), (override)); MOCK_METHOD(void, dump, (std::string&), (const, override)); }; Loading Loading
services/surfaceflinger/Scheduler/VSyncReactor.cpp +29 −14 Original line number Diff line number Diff line Loading @@ -51,6 +51,25 @@ VSyncReactor::VSyncReactor(PhysicalDisplayId id, std::unique_ptr<Clock> clock, VSyncReactor::~VSyncReactor() = default; bool VSyncReactor::updateTrackerWithSignaledFences() { bool timestampAccepted = true; for (auto it = mUnfiredFences.begin(); it != mUnfiredFences.end();) { auto const time = FlagManager::getInstance().reset_model_flushes_fence() ? (*it)->getSignalTime() : (*it)->getCachedSignalTime(); if (time == Fence::SIGNAL_TIME_PENDING) { it++; } else if (time == Fence::SIGNAL_TIME_INVALID) { it = mUnfiredFences.erase(it); } else { timestampAccepted &= mTracker.addVsyncTimestamp(time); it = mUnfiredFences.erase(it); } } return timestampAccepted; } bool VSyncReactor::addPresentFence(std::shared_ptr<FenceTime> fence) { SFTRACE_CALL(); Loading @@ -70,20 +89,7 @@ bool VSyncReactor::addPresentFence(std::shared_ptr<FenceTime> fence) { return true; } bool timestampAccepted = true; for (auto it = mUnfiredFences.begin(); it != mUnfiredFences.end();) { auto const time = (*it)->getCachedSignalTime(); if (time == Fence::SIGNAL_TIME_PENDING) { it++; } else if (time == Fence::SIGNAL_TIME_INVALID) { it = mUnfiredFences.erase(it); } else { timestampAccepted &= mTracker.addVsyncTimestamp(time); it = mUnfiredFences.erase(it); } } bool timestampAccepted = updateTrackerWithSignaledFences(); if (signalTime == Fence::SIGNAL_TIME_PENDING) { if (mPendingLimit == mUnfiredFences.size()) { mUnfiredFences.erase(mUnfiredFences.begin()); Loading Loading @@ -115,6 +121,9 @@ void VSyncReactor::setIgnorePresentFencesInternal(bool ignore) { void VSyncReactor::updateIgnorePresentFencesInternal() { if (mExternalIgnoreFences || mInternalIgnoreFences) { if (FlagManager::getInstance().reset_model_flushes_fence()) { updateTrackerWithSignaledFences(); } mUnfiredFences.clear(); } } Loading Loading @@ -233,6 +242,12 @@ void VSyncReactor::setDisplayPowerMode(hal::PowerMode powerMode) { mDisplayPowerMode = powerMode; } void VSyncReactor::resetModel() { std::lock_guard lock(mMutex); updateTrackerWithSignaledFences(); mTracker.resetModel(); } void VSyncReactor::dump(std::string& result) const { std::lock_guard lock(mMutex); StringAppendF(&result, "VsyncReactor in use\n"); Loading
services/surfaceflinger/Scheduler/VSyncReactor.h +3 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,8 @@ public: void setDisplayPowerMode(hal::PowerMode powerMode) final; void resetModel() final; void dump(std::string& result) const final; private: Loading @@ -62,6 +64,7 @@ private: void endPeriodTransition() REQUIRES(mMutex); bool periodConfirmed(nsecs_t vsync_timestamp, std::optional<nsecs_t> hwcVsyncPeriod) REQUIRES(mMutex); bool updateTrackerWithSignaledFences() REQUIRES(mMutex); const PhysicalDisplayId mId; std::unique_ptr<Clock> const mClock; Loading
services/surfaceflinger/Scheduler/VsyncController.h +5 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,11 @@ public: */ virtual void setDisplayPowerMode(hal::PowerMode powerMode) = 0; /* * Resets the vsync model */ virtual void resetModel() = 0; virtual void dump(std::string& result) const = 0; protected: Loading
services/surfaceflinger/Scheduler/VsyncSchedule.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -184,7 +184,11 @@ void VsyncSchedule::enableHardwareVsync() { void VsyncSchedule::enableHardwareVsyncLocked() { SFTRACE_CALL(); if (mHwVsyncState == HwVsyncState::Disabled) { if (FlagManager::getInstance().reset_model_flushes_fence()) { mController->resetModel(); } else { getTracker().resetModel(); } mRequestHardwareVsync(mId, true); mHwVsyncState = HwVsyncState::Enabled; } Loading
services/surfaceflinger/tests/unittests/mock/MockVsyncController.h +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ public: MOCK_METHOD(void, onDisplayModeChanged, (ftl::NonNull<DisplayModePtr>, bool), (override)); MOCK_METHOD(void, setIgnorePresentFences, (bool), (override)); MOCK_METHOD(void, setDisplayPowerMode, (hal::PowerMode), (override)); MOCK_METHOD(void, resetModel, (), (override)); MOCK_METHOD(void, dump, (std::string&), (const, override)); }; Loading