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 "asyncrenderloop.h"
|
||||||
#include <QDateTime>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
namespace QH {
|
namespace QH {
|
||||||
|
|
||||||
AsyncRenderLoop::AsyncRenderLoop(QThread *thread, QObject *ptr): Async(thread, ptr) {
|
AsyncRenderLoop::AsyncRenderLoop(QThread *thread, QObject *ptr): Async(thread, ptr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncRenderLoop::~AsyncRenderLoop() {
|
AsyncRenderLoop::~AsyncRenderLoop() {
|
||||||
@ -43,7 +41,7 @@ bool AsyncRenderLoop::isRun() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QH::AsyncRenderLoop::renderLoopPrivate() {
|
void QH::AsyncRenderLoop::renderLoopPrivate() {
|
||||||
quint64 currentTime = QDateTime::currentMSecsSinceEpoch();
|
auto&& currentTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
_lastIterationTime = currentTime;
|
_lastIterationTime = currentTime;
|
||||||
int iterationTime = 0;
|
int iterationTime = 0;
|
||||||
@ -51,8 +49,8 @@ void QH::AsyncRenderLoop::renderLoopPrivate() {
|
|||||||
while (m_run) {
|
while (m_run) {
|
||||||
renderIteration(iterationTime);
|
renderIteration(iterationTime);
|
||||||
|
|
||||||
currentTime = QDateTime::currentMSecsSinceEpoch();
|
currentTime = std::chrono::high_resolution_clock::now();
|
||||||
iterationTime = currentTime - _lastIterationTime;
|
iterationTime = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - _lastIterationTime).count();
|
||||||
_lastIterationTime = currentTime;
|
_lastIterationTime = currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,18 +64,18 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* @brief renderIteration This method is called in each iteration of the render loop.
|
* @brief renderIteration This method is called in each iteration of the render loop.
|
||||||
* This method must be implemented in the derived class.
|
* 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 stop
|
||||||
* @see run
|
* @see run
|
||||||
*/
|
*/
|
||||||
virtual void renderIteration(int msec) = 0;
|
virtual void renderIteration(int mmsec) = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void renderLoopPrivate();
|
void renderLoopPrivate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_run = false;
|
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