update render loop iterations msec to mmsec
Some checks failed
buildbot/DocsGenerator Build finished.
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.

This commit is contained in:
Andrei Yankovich 2025-01-30 10:40:56 +01:00
parent 880c91320a
commit cd6da9b177
2 changed files with 6 additions and 8 deletions

View File

@ -6,13 +6,11 @@
*/
#include "asyncrenderloop.h"
#include <QDateTime>
#include <QThread>
namespace QH {
AsyncRenderLoop::AsyncRenderLoop(QThread *thread, QObject *ptr): Async(thread, ptr) {
}
AsyncRenderLoop::~AsyncRenderLoop() {
@ -43,7 +41,7 @@ bool AsyncRenderLoop::isRun() const {
}
void QH::AsyncRenderLoop::renderLoopPrivate() {
quint64 currentTime = QDateTime::currentMSecsSinceEpoch();
auto&& currentTime = std::chrono::high_resolution_clock::now();
_lastIterationTime = currentTime;
int iterationTime = 0;
@ -51,8 +49,8 @@ void QH::AsyncRenderLoop::renderLoopPrivate() {
while (m_run) {
renderIteration(iterationTime);
currentTime = QDateTime::currentMSecsSinceEpoch();
iterationTime = currentTime - _lastIterationTime;
currentTime = std::chrono::high_resolution_clock::now();
iterationTime = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - _lastIterationTime).count();
_lastIterationTime = currentTime;
}
}

View File

@ -64,18 +64,18 @@ protected:
/**
* @brief renderIteration This method is called in each iteration of the render loop.
* This method must be implemented in the derived class.
* @param msec time in milliseconds from the last iteration.
* @param mmsec time in microseconds from the last iteration.
* @see stop
* @see run
*/
virtual void renderIteration(int msec) = 0;
virtual void renderIteration(int mmsec) = 0;
private slots:
void renderLoopPrivate();
private:
bool m_run = false;
quint64 _lastIterationTime = 0;
std::chrono::time_point<std::chrono::high_resolution_clock> _lastIterationTime;
};
}