mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 21:42:13 +02:00
Make getPaintDelayUsecs threadsafe
This commit is contained in:
parent
4711c23d9d
commit
dd6a4dd091
2 changed files with 7 additions and 2 deletions
|
@ -25,13 +25,17 @@ void DisplayPlugin::deactivate() {
|
|||
}
|
||||
|
||||
int64_t DisplayPlugin::getPaintDelayUsecs() const {
|
||||
std::lock_guard<std::mutex> lock(_paintDelayMutex);
|
||||
return _paintDelayTimer.isValid() ? _paintDelayTimer.nsecsElapsed() / NSECS_PER_USEC : 0;
|
||||
}
|
||||
|
||||
void DisplayPlugin::incrementPresentCount() {
|
||||
#ifdef DEBUG_PAINT_DELAY
|
||||
// Avoid overhead if we are not debugging
|
||||
_paintDelayTimer.start();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_paintDelayMutex);
|
||||
_paintDelayTimer.start();
|
||||
}
|
||||
#endif
|
||||
|
||||
++_presentedFrameIndex;
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
// Rate at which rendered frames are being skipped
|
||||
virtual float droppedFrameRate() const { return -1.0f; }
|
||||
uint32_t presentCount() const { return _presentedFrameIndex; }
|
||||
// Time since last call to incrementPresentCount. Only valid if DEBUG_PAINT_DELAY is defined
|
||||
// Time since last call to incrementPresentCount (only valid if DEBUG_PAINT_DELAY is defined)
|
||||
int64_t getPaintDelayUsecs() const;
|
||||
|
||||
virtual void cycleDebugOutput() {}
|
||||
|
@ -176,6 +176,7 @@ protected:
|
|||
|
||||
private:
|
||||
std::atomic<uint32_t> _presentedFrameIndex;
|
||||
mutable std::mutex _paintDelayMutex;
|
||||
QElapsedTimer _paintDelayTimer;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue