animationmgr: Optimize CAnimationManager::scheduleTick a bit. (#3172)

* Optimize CAnimationManager::scheduleTick a bit.

* Use integer in wl_event_source_timer_update call.
This commit is contained in:
Dickby 2023-09-05 15:06:39 +02:00 committed by GitHub
parent db48f973fd
commit 28f1f035b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,15 +539,14 @@ void CAnimationManager::scheduleTick() {
const auto PMOSTHZ = g_pHyprRenderer->m_pMostHzMonitor;
float refreshRate = PMOSTHZ ? PMOSTHZ->refreshRate : 60.f;
float refreshDelayMs = std::floor(1000.0 / refreshRate);
if (!PMOSTHZ) {
wl_event_source_timer_update(m_pAnimationTick, refreshDelayMs);
wl_event_source_timer_update(m_pAnimationTick, 16);
return;
}
const float SINCEPRES = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - PMOSTHZ->lastPresentationTimer.chrono()).count() / 1000.0;
float refreshDelayMs = std::floor(1000.f / PMOSTHZ->refreshRate);
const float SINCEPRES = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - PMOSTHZ->lastPresentationTimer.chrono()).count() / 1000.f;
const auto TOPRES = std::clamp(refreshDelayMs - SINCEPRES, 1.1f, 1000.f); // we can't send 0, that will disarm it