Adapt to new class hierarchy for AbstractTimelineModel

Change-Id: I432e334cee3cfc97970224c0f61213dc4f0a2cc2
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-08-26 12:57:29 +02:00
parent af151a0a68
commit e32fff5b5a
3 changed files with 106 additions and 105 deletions

View File

@@ -19,7 +19,6 @@
#include "memoryusagemodel.h" #include "memoryusagemodel.h"
#include "qmldebug/qmlprofilereventtypes.h" #include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/abstracttimelinemodel_p.h" #include "qmlprofiler/abstracttimelinemodel_p.h"
#include <QStack> #include <QStack>
@@ -29,13 +28,12 @@ namespace Internal {
using namespace QmlProfiler; using namespace QmlProfiler;
class MemoryUsageModel::MemoryUsageModelPrivate : class MemoryUsageModel::MemoryUsageModelPrivate : public AbstractTimelineModelPrivate
public SortedTimelineModel<MemoryAllocation,
AbstractTimelineModel::AbstractTimelineModelPrivate>
{ {
public: public:
static QString memoryTypeName(int type); static QString memoryTypeName(int type);
QVector<MemoryAllocation> data;
qint64 maxSize; qint64 maxSize;
private: private:
Q_DECLARE_PUBLIC(MemoryUsageModel) Q_DECLARE_PUBLIC(MemoryUsageModel)
@@ -62,7 +60,7 @@ int MemoryUsageModel::rowMaxValue(int rowNumber) const
int MemoryUsageModel::row(int index) const int MemoryUsageModel::row(int index) const
{ {
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
QmlDebug::MemoryType type = d->range(index).type; QmlDebug::MemoryType type = d->data[index].type;
if (type == QmlDebug::HeapPage || type == QmlDebug::LargeItem) if (type == QmlDebug::HeapPage || type == QmlDebug::LargeItem)
return 1; return 1;
else else
@@ -72,7 +70,7 @@ int MemoryUsageModel::row(int index) const
int MemoryUsageModel::eventId(int index) const int MemoryUsageModel::eventId(int index) const
{ {
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
return d->range(index).type; return d->data[index].type;
} }
QColor MemoryUsageModel::color(int index) const QColor MemoryUsageModel::color(int index) const
@@ -83,7 +81,7 @@ QColor MemoryUsageModel::color(int index) const
float MemoryUsageModel::height(int index) const float MemoryUsageModel::height(int index) const
{ {
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
return qMin(1.0f, (float)d->range(index).size / (float)d->maxSize); return qMin(1.0f, (float)d->data[index].size / (float)d->maxSize);
} }
QVariantMap MemoryUsageModel::location(int index) const QVariantMap MemoryUsageModel::location(int index) const
@@ -95,7 +93,7 @@ QVariantMap MemoryUsageModel::location(int index) const
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
QVariantMap result; QVariantMap result;
int originType = d->range(index).originTypeIndex; int originType = d->data[index].originTypeIndex;
if (originType > -1) { if (originType > -1) {
const QmlDebug::QmlEventLocation &location = const QmlDebug::QmlEventLocation &location =
d->modelManager->qmlModel()->getEventTypes().at(originType).location; d->modelManager->qmlModel()->getEventTypes().at(originType).location;
@@ -139,7 +137,7 @@ QVariantMap MemoryUsageModel::details(int index) const
Q_D(const MemoryUsageModel); Q_D(const MemoryUsageModel);
QVariantMap result; QVariantMap result;
const MemoryUsageModelPrivate::Range *ev = &d->range(index); const MemoryAllocation *ev = &d->data[index];
if (ev->allocated >= -ev->deallocated) if (ev->allocated >= -ev->deallocated)
result.insert(QLatin1String("displayName"), tr("Memory Allocated")); result.insert(QLatin1String("displayName"), tr("Memory Allocated"));
@@ -203,10 +201,10 @@ void MemoryUsageModel::loadData()
} }
if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) { if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) {
MemoryAllocation &last = currentUsageIndex > -1 ? d->data(currentUsageIndex) : dummy; MemoryAllocation &last = currentUsageIndex > -1 ? d->data[currentUsageIndex] : dummy;
if (!rangeStack.empty() && type.detailType == last.type && if (!rangeStack.empty() && type.detailType == last.type &&
last.originTypeIndex == rangeStack.top().originTypeIndex && last.originTypeIndex == rangeStack.top().originTypeIndex &&
rangeStack.top().startTime < d->range(currentUsageIndex).start) { rangeStack.top().startTime < range(currentUsageIndex).start) {
last.update(event.numericData1); last.update(event.numericData1);
currentUsage = last.size; currentUsage = last.size;
} else { } else {
@@ -216,18 +214,19 @@ void MemoryUsageModel::loadData()
currentUsage = allocation.size; currentUsage = allocation.size;
if (currentUsageIndex != -1) { if (currentUsageIndex != -1) {
d->insertEnd(currentUsageIndex, insertEnd(currentUsageIndex,
event.startTime - d->range(currentUsageIndex).start - 1); event.startTime - range(currentUsageIndex).start - 1);
} }
currentUsageIndex = d->insertStart(event.startTime, allocation); currentUsageIndex = insertStart(event.startTime);
d->data.insert(currentUsageIndex, allocation);
} }
} }
if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) { if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) {
MemoryAllocation &last = currentJSHeapIndex > -1 ? d->data(currentJSHeapIndex) : dummy; MemoryAllocation &last = currentJSHeapIndex > -1 ? d->data[currentJSHeapIndex] : dummy;
if (!rangeStack.empty() && type.detailType == last.type && if (!rangeStack.empty() && type.detailType == last.type &&
last.originTypeIndex == rangeStack.top().originTypeIndex && last.originTypeIndex == rangeStack.top().originTypeIndex &&
rangeStack.top().startTime < d->range(currentJSHeapIndex).start) { rangeStack.top().startTime < range(currentJSHeapIndex).start) {
last.update(event.numericData1); last.update(event.numericData1);
currentSize = last.size; currentSize = last.size;
} else { } else {
@@ -239,35 +238,33 @@ void MemoryUsageModel::loadData()
if (currentSize > d->maxSize) if (currentSize > d->maxSize)
d->maxSize = currentSize; d->maxSize = currentSize;
if (currentJSHeapIndex != -1) if (currentJSHeapIndex != -1)
d->insertEnd(currentJSHeapIndex, insertEnd(currentJSHeapIndex,
event.startTime - d->range(currentJSHeapIndex).start - 1); event.startTime - range(currentJSHeapIndex).start - 1);
currentJSHeapIndex = d->insertStart(event.startTime, allocation); currentJSHeapIndex = insertStart(event.startTime);
d->data.insert(currentJSHeapIndex, allocation);
} }
} }
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, count(),
simpleModel->getEvents().count());
} }
if (currentJSHeapIndex != -1) if (currentJSHeapIndex != -1)
d->insertEnd(currentJSHeapIndex, traceEndTime() - insertEnd(currentJSHeapIndex, traceEndTime() - range(currentJSHeapIndex).start - 1);
d->range(currentJSHeapIndex).start - 1);
if (currentUsageIndex != -1) if (currentUsageIndex != -1)
d->insertEnd(currentUsageIndex, traceEndTime() - insertEnd(currentUsageIndex, traceEndTime() - range(currentUsageIndex).start - 1);
d->range(currentUsageIndex).start - 1);
d->computeNesting(); computeNesting();
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
} }
void MemoryUsageModel::clear() void MemoryUsageModel::clear()
{ {
Q_D(MemoryUsageModel); Q_D(MemoryUsageModel);
d->SortedTimelineModel::clear(); d->data.clear();
d->expanded = false;
d->maxSize = 1; d->maxSize = 1;
AbstractTimelineModel::clear();
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }
QString MemoryUsageModel::MemoryUsageModelPrivate::memoryTypeName(int type) QString MemoryUsageModel::MemoryUsageModelPrivate::memoryTypeName(int type)

View File

@@ -19,7 +19,6 @@
#include "pixmapcachemodel.h" #include "pixmapcachemodel.h"
#include "qmldebug/qmlprofilereventtypes.h" #include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/abstracttimelinemodel_p.h" #include "qmlprofiler/abstracttimelinemodel_p.h"
#include <QDebug> #include <QDebug>
@@ -62,9 +61,7 @@ struct Pixmap {
QVector<PixmapState> sizes; QVector<PixmapState> sizes;
}; };
class PixmapCacheModel::PixmapCacheModelPrivate : class PixmapCacheModel::PixmapCacheModelPrivate : public AbstractTimelineModelPrivate
public SortedTimelineModel<PixmapCacheEvent,
AbstractTimelineModel::AbstractTimelineModelPrivate>
{ {
public: public:
void computeMaxCacheSize(); void computeMaxCacheSize();
@@ -73,6 +70,7 @@ public:
int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize, int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
PixmapCacheEvent &newEvent); PixmapCacheEvent &newEvent);
QVector<PixmapCacheEvent> data;
QVector<Pixmap> pixmaps; QVector<Pixmap> pixmaps;
int collapsedRowCount; int collapsedRowCount;
void addVP(QVariantList &l, QString label, qint64 time) const; void addVP(QVariantList &l, QString label, qint64 time) const;
@@ -116,20 +114,20 @@ int PixmapCacheModel::row(int index) const
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
if (d->expanded) if (d->expanded)
return eventId(index) + 1; return eventId(index) + 1;
return d->range(index).rowNumberCollapsed; return d->data[index].rowNumberCollapsed;
} }
int PixmapCacheModel::eventId(int index) const int PixmapCacheModel::eventId(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
return d->range(index).pixmapEventType == PixmapCacheCountChanged ? return d->data[index].pixmapEventType == PixmapCacheCountChanged ?
0 : d->range(index).urlIndex + 1; 0 : d->data[index].urlIndex + 1;
} }
QColor PixmapCacheModel::color(int index) const QColor PixmapCacheModel::color(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
if (d->range(index).pixmapEventType == PixmapCacheCountChanged) if (d->data[index].pixmapEventType == PixmapCacheCountChanged)
return colorByHue(PixmapCacheCountHue); return colorByHue(PixmapCacheCountHue);
return colorByEventId(index); return colorByEventId(index);
@@ -138,8 +136,8 @@ QColor PixmapCacheModel::color(int index) const
float PixmapCacheModel::height(int index) const float PixmapCacheModel::height(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
if (d->range(index).pixmapEventType == PixmapCacheCountChanged) if (d->data[index].pixmapEventType == PixmapCacheCountChanged)
return (float)d->range(index).cacheSize / (float)d->maxCacheSize; return (float)d->data[index].cacheSize / (float)d->maxCacheSize;
else else
return 1.0f; return 1.0f;
} }
@@ -194,7 +192,7 @@ QVariantMap PixmapCacheModel::details(int index) const
{ {
Q_D(const PixmapCacheModel); Q_D(const PixmapCacheModel);
QVariantMap result; QVariantMap result;
const PixmapCacheModelPrivate::Range *ev = &d->range(index); const PixmapCacheEvent *ev = &d->data[index];
if (ev->pixmapEventType == PixmapCacheCountChanged) { if (ev->pixmapEventType == PixmapCacheCountChanged) {
result.insert(QLatin1String("displayName"), tr("Image Cached")); result.insert(QLatin1String("displayName"), tr("Image Cached"));
@@ -204,7 +202,7 @@ QVariantMap PixmapCacheModel::details(int index) const
if (d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].loadState != Finished) if (d->pixmaps[ev->urlIndex].sizes[ev->sizeIndex].loadState != Finished)
result.insert(tr("Result"), tr("Load Error")); result.insert(tr("Result"), tr("Load Error"));
} }
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(ev->duration)); result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(range(index).duration));
} }
result.insert(tr("Cache Size"), QString::fromLatin1("%1 px").arg(ev->cacheSize)); result.insert(tr("Cache Size"), QString::fromLatin1("%1 px").arg(ev->cacheSize));
@@ -371,7 +369,7 @@ void PixmapCacheModel::loadData()
newEvent); newEvent);
break; break;
} }
case PixmapLoadingStarted: // Load case PixmapLoadingStarted: { // Load
// Look for a pixmap that hasn't been started, yet. There may have been a refcount // Look for a pixmap that hasn't been started, yet. There may have been a refcount
// event, which we ignore. // event, which we ignore.
for (QVector<PixmapState>::const_iterator i(pixmap.sizes.cbegin()); for (QVector<PixmapState>::const_iterator i(pixmap.sizes.cbegin());
@@ -385,9 +383,13 @@ void PixmapCacheModel::loadData()
newEvent.sizeIndex = pixmap.sizes.length(); newEvent.sizeIndex = pixmap.sizes.length();
pixmap.sizes << PixmapState(); pixmap.sizes << PixmapState();
} }
pixmap.sizes[newEvent.sizeIndex].started = d->insertStart(startTime, newEvent);
pixmap.sizes[newEvent.sizeIndex].loadState = Loading; PixmapState &state = pixmap.sizes[newEvent.sizeIndex];
state.loadState = Loading;
state.started = insertStart(startTime);
d->data.insert(state.started, newEvent);
break; break;
}
case PixmapLoadingFinished: case PixmapLoadingFinished:
case PixmapLoadingError: { case PixmapLoadingError: {
// First try to find one that has already started // First try to find one that has already started
@@ -428,7 +430,8 @@ void PixmapCacheModel::loadData()
// If the pixmap loading wasn't started, start it at traceStartTime() // If the pixmap loading wasn't started, start it at traceStartTime()
if (state.loadState == Initial) { if (state.loadState == Initial) {
newEvent.pixmapEventType = PixmapLoadingStarted; newEvent.pixmapEventType = PixmapLoadingStarted;
state.started = d->insert(traceStartTime(), startTime - traceStartTime(), newEvent); state.started = insert(traceStartTime(), startTime - traceStartTime());
d->data.insert(state.started, newEvent);
// All other indices are wrong now as we've prepended. Fix them ... // All other indices are wrong now as we've prepended. Fix them ...
if (lastCacheSizeEvent >= state.started) if (lastCacheSizeEvent >= state.started)
@@ -446,7 +449,7 @@ void PixmapCacheModel::loadData()
} }
} }
d->insertEnd(state.started, startTime - d->range(state.started).start); insertEnd(state.started, startTime - range(state.started).start);
if (newEvent.pixmapEventType == PixmapLoadingError) { if (newEvent.pixmapEventType == PixmapLoadingError) {
state.loadState = Error; state.loadState = Error;
switch (state.cacheState) { switch (state.cacheState) {
@@ -471,18 +474,18 @@ void PixmapCacheModel::loadData()
break; break;
} }
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), 2*simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, count(),
2 * simpleModel->getEvents().count());
} }
if (lastCacheSizeEvent != -1) { if (lastCacheSizeEvent != -1)
d->insertEnd(lastCacheSizeEvent, traceEndTime() - d->range(lastCacheSizeEvent).start); insertEnd(lastCacheSizeEvent, traceEndTime() - range(lastCacheSizeEvent).start);
}
d->resizeUnfinishedLoads(); d->resizeUnfinishedLoads();
d->computeMaxCacheSize(); d->computeMaxCacheSize();
d->flattenLoads(); d->flattenLoads();
d->computeNesting(); computeNesting();
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
} }
@@ -490,19 +493,17 @@ void PixmapCacheModel::loadData()
void PixmapCacheModel::clear() void PixmapCacheModel::clear()
{ {
Q_D(PixmapCacheModel); Q_D(PixmapCacheModel);
d->clear();
d->pixmaps.clear(); d->pixmaps.clear();
d->collapsedRowCount = 1; d->collapsedRowCount = 1;
d->maxCacheSize = 1; d->maxCacheSize = 1;
d->expanded = false; d->data.clear();
AbstractTimelineModel::clear();
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }
void PixmapCacheModel::PixmapCacheModelPrivate::computeMaxCacheSize() void PixmapCacheModel::PixmapCacheModelPrivate::computeMaxCacheSize()
{ {
maxCacheSize = 1; maxCacheSize = 1;
foreach (const PixmapCacheModel::PixmapCacheEvent &event, ranges) { foreach (const PixmapCacheModel::PixmapCacheEvent &event, data) {
if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) { if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) {
if (event.cacheSize > maxCacheSize) if (event.cacheSize > maxCacheSize)
maxCacheSize = event.cacheSize; maxCacheSize = event.cacheSize;
@@ -514,23 +515,24 @@ void PixmapCacheModel::PixmapCacheModelPrivate::resizeUnfinishedLoads()
{ {
Q_Q(PixmapCacheModel); Q_Q(PixmapCacheModel);
// all the "load start" events with duration 0 continue till the end of the trace // all the "load start" events with duration 0 continue till the end of the trace
for (int i = 0; i < count(); i++) { for (int i = 0; i < q->count(); i++) {
if (range(i).pixmapEventType == PixmapCacheModel::PixmapLoadingStarted && if (data[i].pixmapEventType == PixmapCacheModel::PixmapLoadingStarted &&
range(i).duration == 0) { q->range(i).duration == 0) {
insertEnd(i, q->traceEndTime() - range(i).start); q->insertEnd(i, q->traceEndTime() - q->range(i).start);
} }
} }
} }
void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads() void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads()
{ {
Q_Q(PixmapCacheModel);
collapsedRowCount = 0; collapsedRowCount = 0;
// computes "compressed row" // computes "compressed row"
QVector <qint64> eventEndTimes; QVector <qint64> eventEndTimes;
for (int i = 0; i < count(); i++) { for (int i = 0; i < q->count(); i++) {
PixmapCacheModel::PixmapCacheEvent &event = data(i); PixmapCacheModel::PixmapCacheEvent &event = data[i];
const Range &start = range(i); const Range &start = q->range(i);
if (event.pixmapEventType == PixmapCacheModel::PixmapLoadingStarted) { if (event.pixmapEventType == PixmapCacheModel::PixmapLoadingStarted) {
event.rowNumberCollapsed = 0; event.rowNumberCollapsed = 0;
while (eventEndTimes.count() > event.rowNumberCollapsed && while (eventEndTimes.count() > event.rowNumberCollapsed &&
@@ -555,17 +557,20 @@ void PixmapCacheModel::PixmapCacheModelPrivate::flattenLoads()
int PixmapCacheModel::PixmapCacheModelPrivate::updateCacheCount(int lastCacheSizeEvent, int PixmapCacheModel::PixmapCacheModelPrivate::updateCacheCount(int lastCacheSizeEvent,
qint64 startTime, qint64 pixSize, PixmapCacheEvent &newEvent) qint64 startTime, qint64 pixSize, PixmapCacheEvent &newEvent)
{ {
Q_Q(PixmapCacheModel);
newEvent.pixmapEventType = PixmapCacheCountChanged; newEvent.pixmapEventType = PixmapCacheCountChanged;
newEvent.rowNumberCollapsed = 1; newEvent.rowNumberCollapsed = 1;
qint64 prevSize = 0; qint64 prevSize = 0;
if (lastCacheSizeEvent != -1) { if (lastCacheSizeEvent != -1) {
prevSize = range(lastCacheSizeEvent).cacheSize; prevSize = data[lastCacheSizeEvent].cacheSize;
insertEnd(lastCacheSizeEvent, startTime - range(lastCacheSizeEvent).start); q->insertEnd(lastCacheSizeEvent, startTime - q->range(lastCacheSizeEvent).start);
} }
newEvent.cacheSize = prevSize + pixSize; newEvent.cacheSize = prevSize + pixSize;
return insertStart(startTime, newEvent); int index = q->insertStart(startTime);
data.insert(index, newEvent);
return index;
} }

View File

@@ -19,7 +19,6 @@
#include "scenegraphtimelinemodel.h" #include "scenegraphtimelinemodel.h"
#include "qmldebug/qmlprofilereventtypes.h" #include "qmldebug/qmlprofilereventtypes.h"
#include "qmlprofiler/qmlprofilermodelmanager.h" #include "qmlprofiler/qmlprofilermodelmanager.h"
#include "qmlprofiler/sortedtimelinemodel.h"
#include "qmlprofiler/abstracttimelinemodel_p.h" #include "qmlprofiler/abstracttimelinemodel_p.h"
#include <QCoreApplication> #include <QCoreApplication>
@@ -99,14 +98,14 @@ enum SceneGraphStage {
Q_STATIC_ASSERT(sizeof(StageLabels) == MaximumSceneGraphStage * sizeof(const char *)); Q_STATIC_ASSERT(sizeof(StageLabels) == MaximumSceneGraphStage * sizeof(const char *));
class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate : class SceneGraphTimelineModel::SceneGraphTimelineModelPrivate :
public SortedTimelineModel<SceneGraphTimelineModel::SceneGraphEvent, public AbstractTimelineModel::AbstractTimelineModelPrivate
AbstractTimelineModel::AbstractTimelineModelPrivate>
{ {
public: public:
SceneGraphTimelineModelPrivate(); SceneGraphTimelineModelPrivate();
int collapsedRowCount; int collapsedRowCount;
void flattenLoads(); void flattenLoads();
QVector<SceneGraphEvent> data;
private: private:
Q_DECLARE_PUBLIC(SceneGraphTimelineModel) Q_DECLARE_PUBLIC(SceneGraphTimelineModel)
}; };
@@ -133,13 +132,13 @@ int SceneGraphTimelineModel::rowCount() const
int SceneGraphTimelineModel::row(int index) const int SceneGraphTimelineModel::row(int index) const
{ {
Q_D(const SceneGraphTimelineModel); Q_D(const SceneGraphTimelineModel);
return expanded() ? (d->range(index).stage + 1) : d->range(index).rowNumberCollapsed; return expanded() ? (d->data[index].stage + 1) : d->data[index].rowNumberCollapsed;
} }
int SceneGraphTimelineModel::eventId(int index) const int SceneGraphTimelineModel::eventId(int index) const
{ {
Q_D(const SceneGraphTimelineModel); Q_D(const SceneGraphTimelineModel);
return d->range(index).stage; return d->data[index].stage;
} }
QColor SceneGraphTimelineModel::color(int index) const QColor SceneGraphTimelineModel::color(int index) const
@@ -170,14 +169,12 @@ QVariantMap SceneGraphTimelineModel::details(int index) const
{ {
Q_D(const SceneGraphTimelineModel); Q_D(const SceneGraphTimelineModel);
QVariantMap result; QVariantMap result;
const SortedTimelineModel<SceneGraphEvent, const SceneGraphEvent *ev = &d->data[index];
AbstractTimelineModel::AbstractTimelineModelPrivate>::Range *ev =
&d->range(index);
result.insert(QLatin1String("displayName"), tr(ThreadLabels[ev->stage < MaximumGUIThreadStage ? result.insert(QLatin1String("displayName"), tr(ThreadLabels[ev->stage < MaximumGUIThreadStage ?
SceneGraphGUIThread : SceneGraphRenderThread])); SceneGraphGUIThread : SceneGraphRenderThread]));
result.insert(tr("Stage"), tr(StageLabels[ev->stage])); result.insert(tr("Stage"), tr(StageLabels[ev->stage]));
result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(ev->duration)); result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(range(index).duration));
if (ev->glyphCount >= 0) if (ev->glyphCount >= 0)
result.insert(tr("Glyph Count"), QString::number(ev->glyphCount)); result.insert(tr("Glyph Count"), QString::number(ev->glyphCount));
@@ -203,99 +200,102 @@ void SceneGraphTimelineModel::loadData()
case QmlDebug::SceneGraphRendererFrame: { case QmlDebug::SceneGraphRendererFrame: {
qint64 startTime = event.startTime - event.numericData1 - event.numericData2 - qint64 startTime = event.startTime - event.numericData1 - event.numericData2 -
event.numericData3 - event.numericData4; event.numericData3 - event.numericData4;
d->insert(startTime, event.numericData1, SceneGraphEvent(RenderPreprocess)); d->data.insert(insert(startTime, event.numericData1),
SceneGraphEvent(RenderPreprocess));
startTime += event.numericData1; startTime += event.numericData1;
d->insert(startTime, event.numericData2, SceneGraphEvent(RenderUpdate)); d->data.insert(insert(startTime, event.numericData2), SceneGraphEvent(RenderUpdate));
startTime += event.numericData2; startTime += event.numericData2;
d->insert(startTime, event.numericData3, SceneGraphEvent(RenderBind)); d->data.insert(insert(startTime, event.numericData3), SceneGraphEvent(RenderBind));
startTime += event.numericData3; startTime += event.numericData3;
d->insert(startTime, event.numericData4, SceneGraphEvent(RenderRender)); d->data.insert(insert(startTime, event.numericData4), SceneGraphEvent(RenderRender));
break; break;
} }
case QmlDebug::SceneGraphAdaptationLayerFrame: { case QmlDebug::SceneGraphAdaptationLayerFrame: {
qint64 startTime = event.startTime - event.numericData2 - event.numericData3; qint64 startTime = event.startTime - event.numericData2 - event.numericData3;
d->insert(startTime, event.numericData2, d->data.insert(insert(startTime, event.numericData2),
SceneGraphEvent(GlyphRender, event.numericData1)); SceneGraphEvent(GlyphRender, event.numericData1));
startTime += event.numericData2; startTime += event.numericData2;
d->insert(startTime, event.numericData3, d->data.insert(insert(startTime, event.numericData3),
SceneGraphEvent(GlyphStore, event.numericData1)); SceneGraphEvent(GlyphStore, event.numericData1));
break; break;
} }
case QmlDebug::SceneGraphContextFrame: { case QmlDebug::SceneGraphContextFrame: {
d->insert(event.startTime - event.numericData1, event.numericData1, d->data.insert(insert(event.startTime - event.numericData1, event.numericData1),
SceneGraphEvent(Material)); SceneGraphEvent(Material));
break; break;
} }
case QmlDebug::SceneGraphRenderLoopFrame: { case QmlDebug::SceneGraphRenderLoopFrame: {
qint64 startTime = event.startTime - event.numericData1 - event.numericData2 - qint64 startTime = event.startTime - event.numericData1 - event.numericData2 -
event.numericData3; event.numericData3;
d->insert(startTime, event.numericData1, SceneGraphEvent(RenderThreadSync)); d->data.insert(insert(startTime, event.numericData1),
SceneGraphEvent(RenderThreadSync));
startTime += event.numericData1 + event.numericData2; startTime += event.numericData1 + event.numericData2;
// Skip actual rendering. We get a SceneGraphRendererFrame for that // Skip actual rendering. We get a SceneGraphRendererFrame for that
d->insert(startTime, event.numericData3, SceneGraphEvent(Swap)); d->data.insert(insert(startTime, event.numericData3), SceneGraphEvent(Swap));
break; break;
} }
case QmlDebug::SceneGraphTexturePrepare: { case QmlDebug::SceneGraphTexturePrepare: {
qint64 startTime = event.startTime - event.numericData1 - event.numericData2 - qint64 startTime = event.startTime - event.numericData1 - event.numericData2 -
event.numericData3 - event.numericData4 - event.numericData5; event.numericData3 - event.numericData4 - event.numericData5;
d->insert(startTime, event.numericData1, SceneGraphEvent(TextureBind)); d->data.insert(insert(startTime, event.numericData1), SceneGraphEvent(TextureBind));
startTime += event.numericData1; startTime += event.numericData1;
d->insert(startTime, event.numericData2, SceneGraphEvent(TextureConvert)); d->data.insert(insert(startTime, event.numericData2), SceneGraphEvent(TextureConvert));
startTime += event.numericData2; startTime += event.numericData2;
d->insert(startTime, event.numericData3, SceneGraphEvent(TextureSwizzle)); d->data.insert(insert(startTime, event.numericData3), SceneGraphEvent(TextureSwizzle));
startTime += event.numericData3; startTime += event.numericData3;
d->insert(startTime, event.numericData4, SceneGraphEvent(TextureUpload)); d->data.insert(insert(startTime, event.numericData4), SceneGraphEvent(TextureUpload));
startTime += event.numericData4; startTime += event.numericData4;
d->insert(startTime, event.numericData4, SceneGraphEvent(TextureMipmap)); d->data.insert(insert(startTime, event.numericData4), SceneGraphEvent(TextureMipmap));
break; break;
} }
case QmlDebug::SceneGraphPolishAndSync: { case QmlDebug::SceneGraphPolishAndSync: {
qint64 startTime = event.startTime - event.numericData1 - event.numericData2 - qint64 startTime = event.startTime - event.numericData1 - event.numericData2 -
event.numericData3 - event.numericData4; event.numericData3 - event.numericData4;
d->insert(startTime, event.numericData1, SceneGraphEvent(Polish)); d->data.insert(insert(startTime, event.numericData1), SceneGraphEvent(Polish));
startTime += event.numericData1; startTime += event.numericData1;
d->insert(startTime, event.numericData2, SceneGraphEvent(Wait)); d->data.insert(insert(startTime, event.numericData2), SceneGraphEvent(Wait));
startTime += event.numericData2; startTime += event.numericData2;
d->insert(startTime, event.numericData3, SceneGraphEvent(GUIThreadSync)); d->data.insert(insert(startTime, event.numericData3), SceneGraphEvent(GUIThreadSync));
startTime += event.numericData3; startTime += event.numericData3;
d->insert(startTime, event.numericData4, SceneGraphEvent(Animations)); d->data.insert(insert(startTime, event.numericData4), SceneGraphEvent(Animations));
break; break;
} }
case QmlDebug::SceneGraphWindowsAnimations: { case QmlDebug::SceneGraphWindowsAnimations: {
// GUI thread, separate animations stage // GUI thread, separate animations stage
d->insert(event.startTime - event.numericData1, event.numericData1, d->data.insert(insert(event.startTime - event.numericData1, event.numericData1),
SceneGraphEvent(Animations)); SceneGraphEvent(Animations));
break; break;
} }
case QmlDebug::SceneGraphPolishFrame: { case QmlDebug::SceneGraphPolishFrame: {
// GUI thread, separate polish stage // GUI thread, separate polish stage
d->insert(event.startTime - event.numericData1, event.numericData1, d->data.insert(insert(event.startTime - event.numericData1, event.numericData1),
SceneGraphEvent(Polish)); SceneGraphEvent(Polish));
break; break;
} }
default: break; default: break;
} }
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), simpleModel->getEvents().count()); d->modelManager->modelProxyCountUpdated(d->modelId, count(), simpleModel->getEvents().count());
} }
d->computeNesting(); computeNesting();
d->flattenLoads(); d->flattenLoads();
d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 1, 1);
} }
void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::flattenLoads() void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::flattenLoads()
{ {
Q_Q(SceneGraphTimelineModel);
collapsedRowCount = 0; collapsedRowCount = 0;
// computes "compressed row" // computes "compressed row"
QVector <qint64> eventEndTimes; QVector <qint64> eventEndTimes;
for (int i = 0; i < count(); i++) { for (int i = 0; i < q->count(); i++) {
SceneGraphEvent &event = data(i); SceneGraphEvent &event = data[i];
const Range &start = range(i); const Range &start = q->range(i);
// Don't try to put render thread events in GUI row and vice versa. // Don't try to put render thread events in GUI row and vice versa.
// Rows below those are free for all. // Rows below those are free for all.
event.rowNumberCollapsed = (event.stage < MaximumGUIThreadStage ? SceneGraphGUIThread : event.rowNumberCollapsed = (event.stage < MaximumGUIThreadStage ? SceneGraphGUIThread :
@@ -328,10 +328,9 @@ void SceneGraphTimelineModel::SceneGraphTimelineModelPrivate::flattenLoads()
void SceneGraphTimelineModel::clear() void SceneGraphTimelineModel::clear()
{ {
Q_D(SceneGraphTimelineModel); Q_D(SceneGraphTimelineModel);
d->clear();
d->expanded = false;
d->collapsedRowCount = 1; d->collapsedRowCount = 1;
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); d->data.clear();
AbstractTimelineModel::clear();
} }
SceneGraphTimelineModel::SceneGraphEvent::SceneGraphEvent(int stage, int glyphCount) : SceneGraphTimelineModel::SceneGraphEvent::SceneGraphEvent(int stage, int glyphCount) :