Skip to content
Snippets Groups Projects
Commit 44fe91d5 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

implement fps log display within ShmRenderer

You need to uncomment the #define DEBUG_FPS line
in shmrenderer code to enable logging.

Refs #68901
parent b8c56f42
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,11 @@ ...@@ -40,6 +40,11 @@
#include "video/resolution.h" #include "video/resolution.h"
#include "private/videorenderer_p.h" #include "private/videorenderer_p.h"
//#define DEBUG_FPS
#ifdef DEBUG_FPS
#include <chrono>
#endif
///Shared memory object ///Shared memory object
struct SHMHeader { struct SHMHeader {
sem_t notification; sem_t notification;
...@@ -75,6 +80,11 @@ public: ...@@ -75,6 +80,11 @@ public:
int m_Fps ; int m_Fps ;
QTime m_CurrentTime; QTime m_CurrentTime;
#ifdef DEBUG_FPS
unsigned m_frameCount;
std::chrono::time_point<std::chrono::system_clock> m_lastFrameDebug;
#endif
//Constants //Constants
static const int TIMEOUT_SEC = 1; // 1 second static const int TIMEOUT_SEC = 1; // 1 second
...@@ -97,6 +107,10 @@ Video::ShmRendererPrivate::ShmRendererPrivate(Video::ShmRenderer* parent) : QObj ...@@ -97,6 +107,10 @@ Video::ShmRendererPrivate::ShmRendererPrivate(Video::ShmRenderer* parent) : QObj
fd(-1),m_fpsC(0),m_Fps(0), fd(-1),m_fpsC(0),m_Fps(0),
m_pShmArea((SHMHeader*)MAP_FAILED), m_ShmAreaLen(0), m_BufferGen(0), m_pShmArea((SHMHeader*)MAP_FAILED), m_ShmAreaLen(0), m_BufferGen(0),
m_pTimer(nullptr) m_pTimer(nullptr)
#ifdef DEBUG_FPS
, m_frameCount(0)
, m_lastFrameDebug(std::chrono::system_clock::now())
#endif
{ {
} }
...@@ -163,6 +177,17 @@ bool Video::ShmRendererPrivate::renderToBitmap() ...@@ -163,6 +177,17 @@ bool Video::ShmRendererPrivate::renderToBitmap()
static_cast<Video::Renderer*>(q_ptr)->d_ptr->updateFrameIndex(); static_cast<Video::Renderer*>(q_ptr)->d_ptr->updateFrameIndex();
shmUnlock(); shmUnlock();
#ifdef DEBUG_FPS
auto currentTime = std::chrono::system_clock::now();
const std::chrono::duration<double> seconds = currentTime - m_lastFrameDebug;
++m_frameCount;
if (seconds.count() > 1) {
qDebug() << this << ": FPS " << (m_frameCount / seconds.count());
m_frameCount = 0;
m_lastFrameDebug = currentTime;
}
#endif
return true; return true;
#else #else
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment