aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-03-07 16:20:23 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-18 12:02:39 +0100
commit5977fbfd16f4d2d268dfecc48b1120a1f0dcf004 (patch)
treea7a744047668acfa5ba2e9d2ced8184d1ab85b3c /src
parentb456fb1a11302557ac51ac47c635ba993d1653a3 (diff)
Register animation profiler callback also from render thread
The QUnifiedTimer in the GUI thread doesn't cover the render thread animations. We need a separate registration for those. We also need to keep track of which animation events are coming from which threads. Task-number: QTCREATORBUG-11659 Change-Id: I1fdd80a5630cc6a33e527b99be7347f3bd63510f Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp3
-rw-r--r--src/quick/util/qquickprofiler.cpp13
-rw-r--r--src/quick/util/qquickprofiler_p.h21
3 files changed, 29 insertions, 8 deletions
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index ba8c3a7fce..de126fe40b 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -59,6 +59,7 @@
#include <private/qquickanimatorcontroller_p.h>
#include <private/qquickprofiler_p.h>
+#include <private/qqmldebugservice_p.h>
/*
Overall design:
@@ -688,6 +689,8 @@ void QSGRenderThread::run()
animatorDriver = sgrc->sceneGraphContext()->createAnimationDriver(0);
animatorDriver->install();
QUnifiedTimer::instance(true)->setConsistentTiming(QSGRenderLoop::useConsistentTiming());
+ if (QQmlDebugService::isDebuggingEnabled())
+ QQuickProfiler::registerAnimationCallback();
while (active) {
diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp
index 0bd22d1d25..4418f6dd9c 100644
--- a/src/quick/util/qquickprofiler.cpp
+++ b/src/quick/util/qquickprofiler.cpp
@@ -72,7 +72,7 @@ void QQuickProfilerData::toByteArrays(QList<QByteArray> &messages) const
switch (decodedMessageType) {
case QQuickProfiler::Event:
if (decodedDetailType == (int)QQuickProfiler::AnimationFrame)
- ds << framerate << count;
+ ds << framerate << count << threadId;
break;
case QQuickProfiler::PixmapCacheEvent:
ds << detailUrl.toString();
@@ -137,7 +137,14 @@ void QQuickProfiler::initialize()
void animationTimerCallback(qint64 delta)
{
- Q_QUICK_PROFILE(animationFrame(delta));
+ Q_QUICK_PROFILE(animationFrame(delta,
+ QThread::currentThread() == QCoreApplication::instance()->thread() ?
+ QQuickProfiler::GuiThread : QQuickProfiler::RenderThread));
+}
+
+void QQuickProfiler::registerAnimationCallback()
+{
+ QUnifiedTimer::instance()->registerProfilerCallback(&animationTimerCallback);
}
class CallbackRegistrationHelper : public QObject {
@@ -145,7 +152,7 @@ class CallbackRegistrationHelper : public QObject {
public slots:
void registerAnimationTimerCallback()
{
- QUnifiedTimer::instance()->registerProfilerCallback(&animationTimerCallback);
+ QQuickProfiler::registerAnimationCallback();
delete this;
}
};
diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h
index 721560b9e5..03cef951b5 100644
--- a/src/quick/util/qquickprofiler_p.h
+++ b/src/quick/util/qquickprofiler_p.h
@@ -95,9 +95,9 @@ struct Q_AUTOTEST_EXPORT QQuickProfilerData
framerate(framerate), count(count) {}
QQuickProfilerData(qint64 time, int messageType, int detailType, int framerate = 0,
- int count = 0) :
+ int count = 0, int threadId = 0) :
time(time), messageType(messageType), detailType(detailType), framerate(framerate),
- count(count) {}
+ count(count), threadId(threadId) {}
// Special ctor for scenegraph frames. Note that it's missing the QString/QUrl params.
// This is slightly ugly, but makes it easier to disambiguate between int and qint64 params.
@@ -133,7 +133,10 @@ struct Q_AUTOTEST_EXPORT QQuickProfilerData
int count; //used by animation events and for pixmaps
};
- qint64 subtime_5;
+ union {
+ qint64 subtime_5;
+ int threadId;
+ };
void toByteArrays(QList<QByteArray> &messages) const;
};
@@ -144,6 +147,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickProfiler : public QQmlAbstractProfilerAdapter
Q_OBJECT
public:
+ enum AnimationThread {
+ GuiThread,
+ RenderThread
+ };
+
template<EventType DetailType>
static void addEvent()
{
@@ -151,13 +159,14 @@ public:
1 << DetailType));
}
- static void animationFrame(qint64 delta)
+ static void animationFrame(qint64 delta, AnimationThread threadId)
{
int animCount = QUnifiedTimer::instance()->runningAnimationCount();
if (animCount > 0 && delta > 0) {
s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 << Event,
- 1 << AnimationFrame, 1000 / (int)delta /* trim fps to integer */, animCount));
+ 1 << AnimationFrame, 1000 / (int)delta /* trim fps to integer */, animCount,
+ threadId));
}
}
@@ -191,6 +200,8 @@ public:
1 << PixmapCacheEvent, 1 << CountType, url, 0, 0, 0, count));
}
+ static void registerAnimationCallback();
+
qint64 timestamp() { return m_timer.nsecsElapsed(); }
qint64 sendMessages(qint64 until, QList<QByteArray> &messages);