[thanos] Switched frame time tracking from QElapsedTimer to crl::now.

This commit is contained in:
23rd
2026-05-22 13:09:54 +03:00
parent 0a7e4e6665
commit dd2a3bda91
2 changed files with 7 additions and 7 deletions
@@ -103,7 +103,6 @@ ThanosEffectRenderer::ThanosEffectRenderer(
) | rpl::on_next([=, this](float64 value) {
_factor = value;
}, _lifetime);
_elapsed.start();
}
ThanosEffectRenderer::~ThanosEffectRenderer() {
@@ -189,7 +188,7 @@ void ThanosEffectRenderer::initialize(
cb->resourceUpdate(rub);
_initialized = true;
_lastFrameTime = double(_elapsed.elapsed()) / 1000.0;
_lastFrameTime = crl::now();
LOG(("ThanosEffect: initialized, backend=%1 device=%2")
.arg(rhi->backendName())
@@ -311,9 +310,12 @@ void ThanosEffectRenderer::render(
}
_rhi = rhi;
const auto now = float64(_elapsed.elapsed()) / 1000.;
const auto now = crl::now();
// Cap to ~15 FPS so a single slow frame cannot teleport particles.
const auto dt = std::clamp(now - _lastFrameTime, 0.001, 0.066);
const auto dt = std::clamp(
now - _lastFrameTime,
crl::time(1),
crl::time(66)) / 1000.;
_lastFrameTime = now;
addPendingItems(cb);
@@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rhi/rhi_renderer.h"
#include "ui/gl/gl_surface.h"
#include <QElapsedTimer>
#include <QImage>
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
@@ -111,8 +110,7 @@ private:
std::vector<AnimatingItem> _items;
std::vector<ThanosItem> _pendingItems;
QElapsedTimer _elapsed;
double _lastFrameTime = 0.;
crl::time _lastFrameTime = 0;
bool _initialized = false;
bool _creationFailed = false;
uint32_t _seedCounter = 0;