mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-07 15:09:43 +00:00
update render loop iterations msec to mmsec
This commit is contained in:
parent
880c91320a
commit
cd6da9b177
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user