aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-03-07 17:35:56 +0100
committerUlf Hermann <ulf.hermann@digia.com>2014-03-11 10:14:03 +0100
commitcc4aae532d3f74bacaa46127a7a915fb8f283a7d (patch)
treedc95c9882904c5144c2b62eb4634c06ded319a95 /src/plugins/qmlprofiler
parent14dc364c2ebcddf8922f1db15ae9900b4cddf799 (diff)
QmlProfiler: Show multiple rows for animations from different threads
Task-number: QTCREATORBUG-11659 Change-Id: I40ed0ff755b5583947de08207993325dc1039d87 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp94
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h1
2 files changed, 51 insertions, 44 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
index 29837a61d2d..c973ba500bd 100644
--- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
@@ -32,6 +32,7 @@
#include "qmlprofilerdatamodel.h"
#include "sortedtimelinemodel.h"
#include "singlecategorytimelinemodel_p.h"
+#include <utils/qtcassert.h>
#include <QCoreApplication>
#include <QVector>
@@ -50,10 +51,9 @@ class PaintEventsModelProxy::PaintEventsModelProxyPrivate :
SingleCategoryTimelineModel::SingleCategoryTimelineModelPrivate>
{
public:
- void computeAnimationCountLimit();
- int minAnimationCount;
- int maxAnimationCount;
+ int maxGuiThreadAnimations;
+ int maxRenderThreadAnimations;
bool seenForeignPaintEvent;
private:
@@ -67,8 +67,7 @@ PaintEventsModelProxy::PaintEventsModelProxy(QObject *parent)
{
Q_D(PaintEventsModelProxy);
d->seenForeignPaintEvent = false;
- d->minAnimationCount = 1;
- d->maxAnimationCount = 1;
+ d->maxGuiThreadAnimations = d->maxRenderThreadAnimations = 0;
}
@@ -76,8 +75,7 @@ void PaintEventsModelProxy::clear()
{
Q_D(PaintEventsModelProxy);
d->SortedTimelineModel::clear();
- d->minAnimationCount = 1;
- d->maxAnimationCount = 1;
+ d->maxGuiThreadAnimations = d->maxRenderThreadAnimations = 0;
d->expanded = false;
d->seenForeignPaintEvent = false;
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
@@ -101,7 +99,7 @@ void PaintEventsModelProxy::loadData()
const QVector<QmlProfilerDataModel::QmlEventData> referenceList = simpleModel->getEvents();
QmlPaintEventData lastEvent;
- qint64 minNextStartTime = 0;
+ qint64 minNextStartTimes[] = {0, 0};
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) {
if (!eventAccepted(event)) {
@@ -110,6 +108,8 @@ void PaintEventsModelProxy::loadData()
continue;
}
+ lastEvent.threadId = (QmlDebug::AnimationThread)event.numericData3;
+
// initial estimation of the event duration: 1/framerate
qint64 estimatedDuration = event.numericData1 > 0 ? 1e9/event.numericData1 : 1;
@@ -117,7 +117,7 @@ void PaintEventsModelProxy::loadData()
qint64 realEndTime = event.startTime;
// ranges should not overlap. If they do, our estimate wasn't accurate enough
- qint64 realStartTime = qMax(event.startTime - estimatedDuration, minNextStartTime);
+ qint64 realStartTime = qMax(event.startTime - estimatedDuration, minNextStartTimes[lastEvent.threadId]);
// Sometimes our estimate is far off or the server has miscalculated the frame rate
if (realStartTime >= realEndTime)
@@ -127,14 +127,21 @@ void PaintEventsModelProxy::loadData()
// The server should know better after all and if it doesn't we want to see that.
lastEvent.framerate = (int)event.numericData1;
lastEvent.animationcount = (int)event.numericData2;
+ QTC_ASSERT(lastEvent.animationcount > 0, continue);
+
d->insert(realStartTime, realEndTime - realStartTime, lastEvent);
- minNextStartTime = event.startTime + 1;
+ if (lastEvent.threadId == QmlDebug::GuiThread)
+ d->maxGuiThreadAnimations = qMax(lastEvent.animationcount, d->maxGuiThreadAnimations);
+ else
+ d->maxRenderThreadAnimations =
+ qMax(lastEvent.animationcount, d->maxRenderThreadAnimations);
+
+ minNextStartTimes[lastEvent.threadId] = event.startTime + 1;
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), referenceList.count());
}
- d->computeAnimationCountLimit();
d->computeNesting();
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
@@ -144,25 +151,25 @@ void PaintEventsModelProxy::loadData()
int PaintEventsModelProxy::categoryDepth(int categoryIndex) const
{
- Q_D(const PaintEventsModelProxy);
Q_UNUSED(categoryIndex);
+ Q_D(const PaintEventsModelProxy);
if (isEmpty())
return d->seenForeignPaintEvent ? 0 : 1;
else
- return 2;
+ return (d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3;
}
int PaintEventsModelProxy::getEventRow(int index) const
{
- Q_UNUSED(index);
- return 1;
+ Q_D(const PaintEventsModelProxy);
+ QmlDebug::AnimationThread threadId = d->range(index).threadId;
+ return (threadId == QmlDebug::GuiThread || d->maxGuiThreadAnimations == 0) ? 1 : 2;
}
int PaintEventsModelProxy::getEventId(int index) const
{
- // there is only one event Id for all painting events
- Q_UNUSED(index);
- return 0;
+ Q_D(const PaintEventsModelProxy);
+ return d->range(index).threadId;
}
QColor PaintEventsModelProxy::getColor(int index) const
@@ -179,44 +186,34 @@ QColor PaintEventsModelProxy::getColor(int index) const
float PaintEventsModelProxy::getHeight(int index) const
{
Q_D(const PaintEventsModelProxy);
- float scale = d->maxAnimationCount - d->minAnimationCount;
- float fraction = 1.0f;
- if (scale > 1)
- fraction = (float)(d->range(index).animationcount -
- d->minAnimationCount) / scale;
-
- return fraction * 0.85f + 0.15f;
+ const PaintEventsModelProxyPrivate::Range &range = d->range(index);
+ return (float)range.animationcount / (float)(range.threadId == QmlDebug::GuiThread ?
+ d->maxGuiThreadAnimations : d->maxRenderThreadAnimations) * 0.85f + 0.15f;
}
const QVariantList PaintEventsModelProxy::getLabelsForCategory(int category) const
{
Q_UNUSED(category);
+ Q_D(const PaintEventsModelProxy);
QVariantList result;
- if (!isEmpty()) {
+ if (d->maxGuiThreadAnimations > 0) {
QVariantMap element;
- element.insert(QLatin1String("displayName"), QVariant(QLatin1String("Animations")));
- element.insert(QLatin1String("description"), QVariant(QLatin1String("Animations")));
- element.insert(QLatin1String("id"), QVariant(0));
+ element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
+ element.insert(QLatin1String("description"), QVariant(tr("GUI Thread")));
+ element.insert(QLatin1String("id"), QVariant(QmlDebug::GuiThread));
result << element;
}
- return result;
-}
-
-void PaintEventsModelProxy::PaintEventsModelProxyPrivate::computeAnimationCountLimit()
-{
- minAnimationCount = 1;
- maxAnimationCount = 1;
- if (count() == 0)
- return;
-
- for (int i=0; i < count(); i++) {
- if (range(i).animationcount < minAnimationCount)
- minAnimationCount = range(i).animationcount;
- else if (range(i).animationcount > maxAnimationCount)
- maxAnimationCount = range(i).animationcount;
+ if (d->maxRenderThreadAnimations > 0) {
+ QVariantMap element;
+ element.insert(QLatin1String("displayName"), QVariant(tr("Animations")));
+ element.insert(QLatin1String("description"), QVariant(tr("Render Thread")));
+ element.insert(QLatin1String("id"), QVariant(QmlDebug::RenderThread));
+ result << element;
}
+
+ return result;
}
const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
@@ -253,6 +250,15 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
result << valuePair;
}
+ {
+ QVariantMap valuePair;
+ valuePair.insert(QCoreApplication::translate(trContext, "Context:"),
+ QCoreApplication::translate(trContext,
+ d->range(index).threadId == QmlDebug::GuiThread ?
+ "GUI Thread" : "Render Thread"));
+ result << valuePair;
+ }
+
return result;
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
index 2e7fd45c135..1a811ff4b47 100644
--- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
+++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
@@ -56,6 +56,7 @@ public:
struct QmlPaintEventData {
int framerate;
int animationcount;
+ QmlDebug::AnimationThread threadId;
};
PaintEventsModelProxy(QObject *parent = 0);