From da706bdce88107c4d5fe0ca492b94e67466862e6 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 12 Aug 2009 15:51:01 +1000 Subject: Basic framerate measurement, until we have something more useful. --- src/declarative/util/qfxview.cpp | 16 ++++++++++++++++ src/declarative/util/qfxview.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 0f129d8..bb436cd 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE +DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) + static QVariant stringToPixmap(const QString &str) { //XXX need to use correct paths @@ -98,6 +100,7 @@ public: QSize initialSize; bool resizable; + QTime frameTimer; void init(); @@ -492,6 +495,19 @@ void QFxView::resizeEvent(QResizeEvent *e) QGraphicsView::resizeEvent(e); } +/*! + \reimp +*/ +void QFxView::paintEvent(QPaintEvent *event) +{ + int time = 0; + if (frameRateDebug()) + time = d->frameTimer.restart(); + QGraphicsView::paintEvent(event); + if (frameRateDebug()) + qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; +} + /*! \fn void QFxView::focusInEvent(QFocusEvent *e) This virtual function does nothing with the event \a e in this class. diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h index b423749..03557a3 100644 --- a/src/declarative/util/qfxview.h +++ b/src/declarative/util/qfxview.h @@ -95,6 +95,7 @@ private Q_SLOTS: protected: virtual void resizeEvent(QResizeEvent *); + virtual void paintEvent(QPaintEvent *event); void focusInEvent(QFocusEvent *); void focusOutEvent(QFocusEvent *); void timerEvent(QTimerEvent*); -- cgit v0.12