From b398ccb7387f9020f46284a139c677167b381501 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 28 Oct 2014 14:30:04 +0100 Subject: Adapt to switching of typeId and selectionId Change-Id: I2aa918232b688bb84690fb8ee10753aa04804d7c Reviewed-by: Kai Koehne --- plugins/qmlprofilerextension/inputeventsmodel.cpp | 21 ++++++++--- plugins/qmlprofilerextension/inputeventsmodel.h | 8 ++++- plugins/qmlprofilerextension/memoryusagemodel.cpp | 42 +++++++++++----------- plugins/qmlprofilerextension/memoryusagemodel.h | 7 ++-- plugins/qmlprofilerextension/pixmapcachemodel.cpp | 17 +++++---- plugins/qmlprofilerextension/pixmapcachemodel.h | 3 +- .../scenegraphtimelinemodel.cpp | 32 +++++++++-------- .../qmlprofilerextension/scenegraphtimelinemodel.h | 6 ++-- 8 files changed, 80 insertions(+), 56 deletions(-) diff --git a/plugins/qmlprofilerextension/inputeventsmodel.cpp b/plugins/qmlprofilerextension/inputeventsmodel.cpp index 90623c949c..59fc1448d2 100644 --- a/plugins/qmlprofilerextension/inputeventsmodel.cpp +++ b/plugins/qmlprofilerextension/inputeventsmodel.cpp @@ -27,7 +27,8 @@ using namespace QmlProfiler; InputEventsModel::InputEventsModel(QObject *parent) : AbstractTimelineModel(tr(QmlProfilerModelManager::featureName(QmlDebug::ProfileInputEvents)), - QmlDebug::Event, QmlDebug::MaximumRangeType, parent) + QmlDebug::Event, QmlDebug::MaximumRangeType, parent), + m_keyTypeId(-1), m_mouseTypeId(-1) { } @@ -36,9 +37,9 @@ quint64 InputEventsModel::features() const return 1 << QmlDebug::ProfileInputEvents; } -int InputEventsModel::selectionId(int index) const +int InputEventsModel::typeId(int index) const { - return modelManager()->qmlModel()->getEventTypes()[typeId(index)].detailType; + return selectionId(index) == QmlDebug::Mouse ? m_mouseTypeId : m_keyTypeId; } QColor InputEventsModel::color(int index) const @@ -97,7 +98,13 @@ void InputEventsModel::loadData() const QmlProfilerDataModel::QmlEventTypeData &type = types[event.typeIndex]; if (!accepted(type)) continue; - insert(event.startTime, 0, event.typeIndex); + insert(event.startTime, 0, type.detailType); + if (type.detailType == QmlDebug::Mouse) { + if (m_mouseTypeId == -1) + m_mouseTypeId = event.typeIndex; + } else if (m_keyTypeId == -1) { + m_keyTypeId = event.typeIndex; + } updateProgress(count(), simpleModel->getEvents().count()); } setCollapsedRowCount(2); @@ -105,6 +112,12 @@ void InputEventsModel::loadData() updateProgress(1, 1); } +void InputEventsModel::clear() +{ + m_keyTypeId = m_mouseTypeId = -1; + AbstractTimelineModel::clear(); +} + bool InputEventsModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const { return AbstractTimelineModel::accepted(event) && diff --git a/plugins/qmlprofilerextension/inputeventsmodel.h b/plugins/qmlprofilerextension/inputeventsmodel.h index 49fd36687e..d85865733b 100644 --- a/plugins/qmlprofilerextension/inputeventsmodel.h +++ b/plugins/qmlprofilerextension/inputeventsmodel.h @@ -35,12 +35,18 @@ public: InputEventsModel(QObject *parent = 0); quint64 features() const; - int selectionId(int index) const; + int typeId(int index) const; QColor color(int index) const; QVariantList labels() const; QVariantMap details(int index) const; int row(int index) const; void loadData(); + void clear(); + +private: + int m_keyTypeId; + int m_mouseTypeId; + }; } diff --git a/plugins/qmlprofilerextension/memoryusagemodel.cpp b/plugins/qmlprofilerextension/memoryusagemodel.cpp index bb07c9eb7a..7fdc08c051 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.cpp +++ b/plugins/qmlprofilerextension/memoryusagemodel.cpp @@ -47,16 +47,16 @@ int MemoryUsageModel::rowMaxValue(int rowNumber) const int MemoryUsageModel::row(int index) const { - QmlDebug::MemoryType type = m_data[index].type; + int type = selectionId(index); if (type == QmlDebug::HeapPage || type == QmlDebug::LargeItem) return 1; else return 2; } -int MemoryUsageModel::selectionId(int index) const +int MemoryUsageModel::typeId(int index) const { - return m_data[index].type; + return m_data[index].typeId; } QColor MemoryUsageModel::color(int index) const @@ -134,7 +134,7 @@ QVariantMap MemoryUsageModel::details(int index) const result.insert(tr("Deallocated"), QString::fromLatin1("%1 bytes").arg(-ev->deallocated)); result.insert(tr("Deallocations"), QString::number(ev->deallocations)); } - result.insert(tr("Type"), QVariant(memoryTypeName(ev->type))); + result.insert(tr("Type"), QVariant(memoryTypeName(selectionId(index)))); if (ev->originTypeIndex != -1) { result.insert(tr("Location"), @@ -165,7 +165,6 @@ void MemoryUsageModel::loadData() int currentJSHeapIndex = -1; QStack rangeStack; - MemoryAllocation dummy; const QVector &types = simpleModel->getEventTypes(); foreach (const QmlProfilerDataModel::QmlEventData &event, simpleModel->getEvents()) { @@ -181,14 +180,14 @@ void MemoryUsageModel::loadData() } if (type.detailType == QmlDebug::SmallItem || type.detailType == QmlDebug::LargeItem) { - MemoryAllocation &last = currentUsageIndex > -1 ? m_data[currentUsageIndex] : dummy; - if (!rangeStack.empty() && type.detailType == last.type && - last.originTypeIndex == rangeStack.top().originTypeIndex && + if (!rangeStack.empty() && currentUsageIndex > -1 && + type.detailType == selectionId(currentUsageIndex) && + m_data[currentUsageIndex].originTypeIndex == rangeStack.top().originTypeIndex && rangeStack.top().startTime < startTime(currentUsageIndex)) { - last.update(event.numericData1); - currentUsage = last.size; + m_data[currentUsageIndex].update(event.numericData1); + currentUsage = m_data[currentUsageIndex].size; } else { - MemoryAllocation allocation(QmlDebug::SmallItem, currentUsage, + MemoryAllocation allocation(event.typeIndex, currentUsage, rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex); allocation.update(event.numericData1); currentUsage = allocation.size; @@ -197,20 +196,21 @@ void MemoryUsageModel::loadData() insertEnd(currentUsageIndex, event.startTime - startTime(currentUsageIndex) - 1); } - currentUsageIndex = insertStart(event.startTime, event.typeIndex); + currentUsageIndex = insertStart(event.startTime, QmlDebug::SmallItem); m_data.insert(currentUsageIndex, allocation); } } if (type.detailType == QmlDebug::HeapPage || type.detailType == QmlDebug::LargeItem) { - MemoryAllocation &last = currentJSHeapIndex > -1 ? m_data[currentJSHeapIndex] : dummy; - if (!rangeStack.empty() && type.detailType == last.type && - last.originTypeIndex == rangeStack.top().originTypeIndex && + if (!rangeStack.empty() && currentJSHeapIndex > -1 && + type.detailType == selectionId(currentJSHeapIndex) && + m_data[currentJSHeapIndex].originTypeIndex == + rangeStack.top().originTypeIndex && rangeStack.top().startTime < startTime(currentJSHeapIndex)) { - last.update(event.numericData1); - currentSize = last.size; + m_data[currentJSHeapIndex].update(event.numericData1); + currentSize = m_data[currentJSHeapIndex].size; } else { - MemoryAllocation allocation((QmlDebug::MemoryType)type.detailType, currentSize, + MemoryAllocation allocation(event.typeIndex, currentSize, rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex); allocation.update(event.numericData1); currentSize = allocation.size; @@ -220,7 +220,7 @@ void MemoryUsageModel::loadData() if (currentJSHeapIndex != -1) insertEnd(currentJSHeapIndex, event.startTime - startTime(currentJSHeapIndex) - 1); - currentJSHeapIndex = insertStart(event.startTime, event.typeIndex); + currentJSHeapIndex = insertStart(event.startTime, type.detailType); m_data.insert(currentJSHeapIndex, allocation); } } @@ -260,9 +260,9 @@ QString MemoryUsageModel::memoryTypeName(int type) } } -MemoryUsageModel::MemoryAllocation::MemoryAllocation(QmlDebug::MemoryType type, qint64 baseAmount, +MemoryUsageModel::MemoryAllocation::MemoryAllocation(int type, qint64 baseAmount, int originTypeIndex) : - type(type), size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0), + typeId(type), size(baseAmount), allocated(0), deallocated(0), allocations(0), deallocations(0), originTypeIndex(originTypeIndex) { } diff --git a/plugins/qmlprofilerextension/memoryusagemodel.h b/plugins/qmlprofilerextension/memoryusagemodel.h index 4c4d1d8f00..2d8d535ecd 100644 --- a/plugins/qmlprofilerextension/memoryusagemodel.h +++ b/plugins/qmlprofilerextension/memoryusagemodel.h @@ -34,7 +34,7 @@ class MemoryUsageModel : public QmlProfiler::AbstractTimelineModel public: struct MemoryAllocation { - QmlDebug::MemoryType type; + int typeId; qint64 size; qint64 allocated; qint64 deallocated; @@ -42,8 +42,7 @@ public: int deallocations; int originTypeIndex; - MemoryAllocation(QmlDebug::MemoryType type = QmlDebug::MaximumMemoryType, - qint64 baseAmount = 0, int originTypeIndex = -1); + MemoryAllocation(int typeId = -1, qint64 baseAmount = 0, int originTypeIndex = -1); void update(qint64 amount); }; @@ -53,7 +52,7 @@ public: int rowMaxValue(int rowNumber) const; int row(int index) const; - int selectionId(int index) const; + int typeId(int index) const; QColor color(int index) const; float relativeHeight(int index) const; diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.cpp b/plugins/qmlprofilerextension/pixmapcachemodel.cpp index d77741326b..21ffb912c2 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.cpp +++ b/plugins/qmlprofilerextension/pixmapcachemodel.cpp @@ -53,10 +53,9 @@ int PixmapCacheModel::row(int index) const return m_data[index].rowNumberCollapsed; } -int PixmapCacheModel::selectionId(int index) const +int PixmapCacheModel::typeId(int index) const { - return m_data[index].pixmapEventType == PixmapCacheCountChanged ? - 0 : m_data[index].urlIndex + 1; + return m_data[index].typeId; } QColor PixmapCacheModel::color(int index) const @@ -309,7 +308,8 @@ void PixmapCacheModel::loadData() PixmapState &state = pixmap.sizes[newEvent.sizeIndex]; state.loadState = Loading; - state.started = insertStart(pixmapStartTime, event.typeIndex); + newEvent.typeId = event.typeIndex; + state.started = insertStart(pixmapStartTime, newEvent.urlIndex + 1); m_data.insert(state.started, newEvent); break; } @@ -353,8 +353,10 @@ void PixmapCacheModel::loadData() // If the pixmap loading wasn't started, start it at traceStartTime() if (state.loadState == Initial) { newEvent.pixmapEventType = PixmapLoadingStarted; - state.started = insert(modelManager()->traceTime()->startTime(), pixmapStartTime - - modelManager()->traceTime()->startTime(), event.typeIndex); + newEvent.typeId = event.typeIndex; + qint64 traceStart = modelManager()->traceTime()->startTime(); + state.started = insert(traceStart, pixmapStartTime - traceStart, + newEvent.urlIndex + 1); m_data.insert(state.started, newEvent); // All other indices are wrong now as we've prepended. Fix them ... @@ -487,7 +489,8 @@ int PixmapCacheModel::updateCacheCount(int lastCacheSizeEvent, } newEvent.cacheSize = prevSize + pixSize; - int index = insertStart(pixmapStartTime, typeId); + newEvent.typeId = typeId; + int index = insertStart(pixmapStartTime, 0); m_data.insert(index, newEvent); return index; } diff --git a/plugins/qmlprofilerextension/pixmapcachemodel.h b/plugins/qmlprofilerextension/pixmapcachemodel.h index 78ce3cfd42..7b932ed825 100644 --- a/plugins/qmlprofilerextension/pixmapcachemodel.h +++ b/plugins/qmlprofilerextension/pixmapcachemodel.h @@ -77,6 +77,7 @@ public: }; struct PixmapCacheEvent { + int typeId; PixmapEventType pixmapEventType; int urlIndex; int sizeIndex; @@ -90,7 +91,7 @@ public: int rowMaxValue(int rowNumber) const; int row(int index) const; - int selectionId(int index) const; + int typeId(int index) const; QColor color(int index) const; float relativeHeight(int index) const; diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp index 37f64abb0f..1ae51244cb 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.cpp @@ -81,12 +81,12 @@ quint64 SceneGraphTimelineModel::features() const int SceneGraphTimelineModel::row(int index) const { - return expanded() ? (m_data[index].stage + 1) : m_data[index].rowNumberCollapsed; + return expanded() ? (selectionId(index) + 1) : m_data[index].rowNumberCollapsed; } -int SceneGraphTimelineModel::selectionId(int index) const +int SceneGraphTimelineModel::typeId(int index) const { - return m_data[index].stage; + return m_data[index].typeId; } QColor SceneGraphTimelineModel::color(int index) const @@ -115,14 +115,15 @@ QVariantList SceneGraphTimelineModel::labels() const QVariantMap SceneGraphTimelineModel::details(int index) const { QVariantMap result; - const SceneGraphEvent *ev = &m_data[index]; + const SceneGraphStage stage = static_cast(selectionId(index)); - result.insert(QLatin1String("displayName"), - tr(threadLabel(static_cast(ev->stage)))); - result.insert(tr("Stage"), tr(StageLabels[ev->stage])); + result.insert(QLatin1String("displayName"), tr(threadLabel(stage))); + result.insert(tr("Stage"), tr(StageLabels[stage])); result.insert(tr("Duration"), QmlProfilerBaseModel::formatTime(duration(index))); - if (ev->glyphCount >= 0) - result.insert(tr("Glyphs"), QString::number(ev->glyphCount)); + + const int glyphCount = m_data[index].glyphCount; + if (glyphCount >= 0) + result.insert(tr("Glyphs"), QString::number(glyphCount)); return result; } @@ -234,11 +235,12 @@ void SceneGraphTimelineModel::flattenLoads() for (int i = 0; i < count(); i++) { SceneGraphEvent &event = m_data[i]; + int stage = selectionId(i); // Don't try to put render thread events in GUI row and vice versa. // Rows below those are free for all. - if (event.stage < MaximumGUIThreadStage) + if (stage < MaximumGUIThreadStage) event.rowNumberCollapsed = SceneGraphGUIThread; - else if (event.stage < MaximumRenderThreadStage) + else if (stage < MaximumRenderThreadStage) event.rowNumberCollapsed = SceneGraphRenderThread; else event.rowNumberCollapsed = SceneGraphRenderThreadDetails; @@ -273,8 +275,8 @@ qint64 SceneGraphTimelineModel::insert(qint64 start, qint64 duration, int typeIn if (duration <= 0) return 0; - m_data.insert(AbstractTimelineModel::insert(start, duration, typeIndex), - SceneGraphEvent(stage, glyphCount)); + m_data.insert(AbstractTimelineModel::insert(start, duration, stage), + SceneGraphEvent(typeIndex, glyphCount)); return duration; } @@ -295,8 +297,8 @@ void SceneGraphTimelineModel::clear() AbstractTimelineModel::clear(); } -SceneGraphTimelineModel::SceneGraphEvent::SceneGraphEvent(SceneGraphStage stage, int glyphCount) : - stage(stage), rowNumberCollapsed(-1), glyphCount(glyphCount) +SceneGraphTimelineModel::SceneGraphEvent::SceneGraphEvent(int typeId, int glyphCount) : + typeId(typeId), rowNumberCollapsed(-1), glyphCount(glyphCount) { } diff --git a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h index 0454e35ec0..1dbbe969c3 100644 --- a/plugins/qmlprofilerextension/scenegraphtimelinemodel.h +++ b/plugins/qmlprofilerextension/scenegraphtimelinemodel.h @@ -71,8 +71,8 @@ public: }; struct SceneGraphEvent { - SceneGraphEvent(SceneGraphStage stage = MaximumSceneGraphStage, int glyphCount = -1); - SceneGraphStage stage; + SceneGraphEvent(int typeId = -1, int glyphCount = -1); + int typeId; int rowNumberCollapsed; int glyphCount; // only used for one event type }; @@ -81,7 +81,7 @@ public: quint64 features() const; int row(int index) const; - int selectionId(int index) const; + int typeId(int index) const; QColor color(int index) const; QVariantList labels() const; -- cgit v1.2.3