diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/scenegraph/qsgthreadedrenderloop.cpp | 3 | ||||
-rw-r--r-- | src/quick/util/qquickprofiler.cpp | 13 | ||||
-rw-r--r-- | src/quick/util/qquickprofiler_p.h | 21 |
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); |