From 11fdefebdd26e5cef4736384f2f3ad0cafc2db1e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 3 Apr 2009 17:34:09 -0700 Subject: Add some timing capabilities Add some frames-per-second output for debugging when QT_DIRECTFB_TIMING is defined. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 1 + src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 18 +++++++++++++++++- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 96eb536..399044e 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -12,6 +12,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers #DEFINES += QT_NO_DIRECTFB_PREALLOCATED #DEFINES += QT_NO_DIRECTFB_MOUSE #DEFINES += QT_NO_DIRECTFB_KEYBOARD +#DEFINES += QT_DIRECTFB_TIMING target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index c495805..ef208af 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -58,6 +58,10 @@ QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr) , engine(0) { setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif } QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget) @@ -72,6 +76,10 @@ QDirectFBSurface::QDirectFBSurface(QDirectFBScreen* scr, QWidget *widget) setSurfaceFlags(Opaque | RegionReserved); else setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif } QDirectFBSurface::~QDirectFBSurface() @@ -307,7 +315,6 @@ inline bool isWidgetOpaque(const QWidget *w) return false; } - void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { @@ -350,6 +357,15 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC); } #endif +#ifdef QT_DIRECTFB_TIMING + enum { Secs = 3 }; + ++frames; + if (timer.elapsed() >= Secs * 1000) { + qDebug("%d fps", int(double(frames) / double(Secs))); + frames = 0; + timer.restart(); + } +#endif } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h index a9cdb7d..9e2791c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h @@ -50,6 +50,10 @@ #include #include +#ifdef QT_DIRECTFB_TIMING +#include +#endif + QT_BEGIN_HEADER QT_MODULE(Gui) @@ -95,6 +99,10 @@ private: bool onscreen; QList bufferImages; +#ifdef QT_DIRECTFB_TIMING + int frames; + QTime timer; +#endif }; QT_END_HEADER -- cgit v0.12