17SoftwareVsyncMonitor::SoftwareVsyncMonitor()
19 connect(&m_softwareClock, &QTimer::timeout,
this, &SoftwareVsyncMonitor::handleSyntheticVsync);
20 m_softwareClock.setSingleShot(
true);
33void SoftwareVsyncMonitor::handleSyntheticVsync()
41 return timestamp + ((alignment - (timestamp % alignment)) % alignment);
46 if (m_softwareClock.isActive()) {
50 const std::chrono::nanoseconds currentTime(std::chrono::steady_clock::now().time_since_epoch());
51 const std::chrono::nanoseconds vblankInterval(1'000'000'000'000ull / m_refreshRate);
55 m_softwareClock.start(std::chrono::duration_cast<std::chrono::milliseconds>(m_vblankTimestamp - currentTime));
60#include "moc_softwarevsyncmonitor.cpp"
static std::unique_ptr< SoftwareVsyncMonitor > create()
void setRefreshRate(int refreshRate)
void vblankOccurred(std::chrono::nanoseconds timestamp)
T alignTimestamp(const T ×tamp, const T &alignment)