summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-05-27 05:21:28 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-05-27 05:21:28 (GMT)
commitf1603f8a4bd3027be201920fa99c9370264bee03 (patch)
tree802dc659bf52592e6da581d02b11c45896bfa986 /src/declarative/util
parent5a6a5b1b83e2196b4cad11fbb0f175682b6f7e8e (diff)
downloadQt-f1603f8a4bd3027be201920fa99c9370264bee03.zip
Qt-f1603f8a4bd3027be201920fa99c9370264bee03.tar.gz
Qt-f1603f8a4bd3027be201920fa99c9370264bee03.tar.bz2
Improve QML framerate debugging
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qdeclarativeview.cpp98
1 files changed, 51 insertions, 47 deletions
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index b7ce9c9..d2dab76 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -45,11 +45,11 @@
#include <qdeclarativeitem.h>
#include <qdeclarativeengine.h>
#include <qdeclarativecontext.h>
-#include <qdeclarativedebug_p.h>
-#include <qdeclarativedebugservice_p.h>
#include <qdeclarativeglobal_p.h>
#include <qdeclarativeguard_p.h>
+#include <private/qdeclarativedebugtiming_p.h>
+
#include <qscriptvalueiterator.h>
#include <qdebug.h>
#include <qtimer.h>
@@ -66,66 +66,64 @@
#include <QtCore/qabstractanimation.h>
#include <private/qgraphicsview_p.h>
#include <private/qdeclarativeitem_p.h>
+#include <private/qabstractanimation_p.h>
#include <private/qdeclarativeitemchangelistener_p.h>
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
-class QDeclarativeViewDebugServer;
-class FrameBreakAnimation : public QAbstractAnimation
+class QDeclarativeScene : public QGraphicsScene
{
public:
- FrameBreakAnimation(QDeclarativeViewDebugServer *s)
- : QAbstractAnimation((QObject*)s), server(s)
- {
- start();
- }
+ QDeclarativeScene();
- virtual int duration() const { return -1; }
- virtual void updateCurrentTime(int msecs);
+protected:
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void keyReleaseEvent(QKeyEvent *);
-private:
- QDeclarativeViewDebugServer *server;
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
};
-class QDeclarativeViewDebugServer : public QDeclarativeDebugService
+QDeclarativeScene::QDeclarativeScene()
{
-public:
- QDeclarativeViewDebugServer(QObject *parent = 0) : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0)
- {
- timer.start();
- new FrameBreakAnimation(this);
- }
+}
- void addTiming(int pe, int tbf)
- {
- if (!isEnabled())
- return;
-
- bool isFrameBreak = breaks > 1;
- breaks = 0;
- int e = timer.elapsed();
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)pe << (int)tbf << (int)e
- << (bool)isFrameBreak;
- sendMessage(data);
- }
+void QDeclarativeScene::keyPressEvent(QKeyEvent *e)
+{
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::Key);
- void frameBreak() { ++breaks; }
+ QGraphicsScene::keyPressEvent(e);
+}
-private:
- QElapsedTimer timer;
- int breaks;
-};
+void QDeclarativeScene::keyReleaseEvent(QKeyEvent *e)
+{
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::Key);
-Q_GLOBAL_STATIC(QDeclarativeViewDebugServer, qfxViewDebugServer);
+ QGraphicsScene::keyReleaseEvent(e);
+}
-void FrameBreakAnimation::updateCurrentTime(int msecs)
+void QDeclarativeScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
- Q_UNUSED(msecs);
- server->frameBreak();
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::Mouse);
+
+ QGraphicsScene::mouseMoveEvent(e);
+}
+
+void QDeclarativeScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
+{
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::Mouse);
+
+ QGraphicsScene::mousePressEvent(e);
+}
+
+void QDeclarativeScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
+{
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::Mouse);
+
+ QGraphicsScene::mouseReleaseEvent(e);
}
class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener
@@ -156,7 +154,7 @@ public:
void init();
- QGraphicsScene scene;
+ QDeclarativeScene scene;
};
void QDeclarativeViewPrivate::execute()
@@ -676,12 +674,18 @@ void QDeclarativeView::resizeEvent(QResizeEvent *e)
void QDeclarativeView::paintEvent(QPaintEvent *event)
{
Q_D(QDeclarativeView);
+
+ QDeclarativeDebugTiming::addEvent(QDeclarativeDebugTiming::FramePaint);
+ QDeclarativeDebugTiming::startRange(QDeclarativeDebugTiming::Painting);
+
int time = 0;
- if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled())
+ if (frameRateDebug())
time = d->frameTimer.restart();
+
QGraphicsView::paintEvent(event);
- if (QDeclarativeViewDebugServer::isDebuggingEnabled())
- qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time);
+
+ QDeclarativeDebugTiming::endRange(QDeclarativeDebugTiming::Painting);
+
if (frameRateDebug())
qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time;
}