forked from qt-creator/qt-creator
QmlProfiler: overview using model aggregator
Change-Id: Iaffb44d97e6641f2e34df6fb5ac839f5b6ebc545 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
committed by
Kai Koehne
parent
1b06a7646d
commit
35d9037732
@@ -75,6 +75,7 @@ public:
|
|||||||
virtual int findLastIndex(qint64 endTime) const = 0;
|
virtual int findLastIndex(qint64 endTime) const = 0;
|
||||||
|
|
||||||
virtual int getEventType(int index) const = 0;
|
virtual int getEventType(int index) const = 0;
|
||||||
|
virtual int getEventCategory(int index) const = 0;
|
||||||
virtual int getEventRow(int index) const = 0;
|
virtual int getEventRow(int index) const = 0;
|
||||||
Q_INVOKABLE virtual qint64 getDuration(int index) const = 0;
|
Q_INVOKABLE virtual qint64 getDuration(int index) const = 0;
|
||||||
Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0;
|
Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0;
|
||||||
|
|||||||
@@ -44,75 +44,66 @@ function drawData(canvas, ctxt, region)
|
|||||||
if ((!qmlProfilerModelProxy) || qmlProfilerModelProxy.count() == 0)
|
if ((!qmlProfilerModelProxy) || qmlProfilerModelProxy.count() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var typeCount = 5;
|
|
||||||
var width = canvas.width;
|
var width = canvas.width;
|
||||||
var bump = 10;
|
var bump = 10;
|
||||||
var height = canvas.height - bump;
|
var height = canvas.height - bump;
|
||||||
|
|
||||||
|
var typeCount = qmlProfilerModelProxy.visibleCategories();
|
||||||
var blockHeight = height / typeCount;
|
var blockHeight = height / typeCount;
|
||||||
|
|
||||||
var spacing = width / qmlProfilerModelProxy.traceDuration();
|
var spacing = width / qmlProfilerModelProxy.traceDuration();
|
||||||
|
|
||||||
var highest = [0,0,0,0,0]; // note: change if typeCount changes
|
var modelRowStart = 0;
|
||||||
|
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
|
||||||
|
for (var ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
|
||||||
|
|
||||||
for (var ii = 0; ii < qmlProfilerModelProxy.count(); ++ii) {
|
var xx = (qmlProfilerModelProxy.getStartTime(modelIndex,ii) -
|
||||||
|
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
||||||
|
if (xx > region.x + region.width)
|
||||||
|
continue;
|
||||||
|
|
||||||
var xx = (qmlProfilerModelProxy.getStartTime(ii) -
|
var eventWidth = qmlProfilerModelProxy.getDuration(modelIndex,ii) * spacing;
|
||||||
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
if (xx + eventWidth < region.x)
|
||||||
if (xx > region.x + region.width)
|
continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
var eventWidth = qmlProfilerModelProxy.getDuration(ii) * spacing;
|
if (eventWidth < 1)
|
||||||
if (xx + eventWidth < region.x)
|
eventWidth = 1;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (eventWidth < 1)
|
xx = Math.round(xx);
|
||||||
eventWidth = 1;
|
|
||||||
|
|
||||||
xx = Math.round(xx);
|
var rowNumber = modelRowStart + qmlProfilerModelProxy.getEventCategoryInModel(modelIndex, ii);
|
||||||
var ty = qmlProfilerModelProxy.getType(ii);
|
|
||||||
|
|
||||||
if (xx + eventWidth > highest[ty]) {
|
var itemHeight = qmlProfilerModelProxy.getHeight(modelIndex,ii) * blockHeight;
|
||||||
/*
|
var yy = (rowNumber + 1) * blockHeight - itemHeight ;
|
||||||
// special: animations
|
|
||||||
if (ty === 0 && qmlProfilerModelProxy.getAnimationCount(ii) >= 0) {
|
|
||||||
var vertScale = qmlProfilerModelProxy.getMaximumAnimationCount() -
|
|
||||||
qmlProfilerModelProxy.getMinimumAnimationCount();
|
|
||||||
if (vertScale < 1)
|
|
||||||
vertScale = 1;
|
|
||||||
var fraction = (qmlProfilerModelProxy.getAnimationCount(ii) -
|
|
||||||
qmlProfilerModelProxy.getMinimumAnimationCount()) / vertScale;
|
|
||||||
var eventHeight = blockHeight * (fraction * 0.85 + 0.15);
|
|
||||||
var yy = bump + ty*blockHeight + blockHeight - eventHeight;
|
|
||||||
|
|
||||||
var fpsFraction = qmlProfilerModelProxy.getFramerate(ii) / 60.0;
|
var itemColor = qmlProfilerModelProxy.getColorRGB(modelIndex, ii);
|
||||||
if (fpsFraction > 1.0)
|
ctxt.fillStyle = "rgb("+itemColor[0]+","+itemColor[1]+","+itemColor[2]+")";
|
||||||
fpsFraction = 1.0;
|
ctxt.fillRect(xx, bump + yy, eventWidth, itemHeight);
|
||||||
ctxt.fillStyle = "hsl("+(fpsFraction*0.27+0.028)+",0.3,0.65)";
|
|
||||||
ctxt.fillRect(xx, yy, eventWidth, eventHeight);
|
|
||||||
} else { */
|
|
||||||
var hue = ( qmlProfilerModelProxy.getEventId(ii) * 25 ) % 360;
|
|
||||||
ctxt.fillStyle = "hsl("+(hue/360.0+0.001)+",0.3,0.65)";
|
|
||||||
ctxt.fillRect(xx, bump + ty*blockHeight, eventWidth, blockHeight);
|
|
||||||
/*}*/
|
|
||||||
highest[ty] = xx+eventWidth;
|
|
||||||
}
|
}
|
||||||
|
modelRowStart += qmlProfilerModelProxy.categoryCount(modelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// binding loops
|
// binding loops
|
||||||
ctxt.strokeStyle = "orange";
|
ctxt.strokeStyle = "orange";
|
||||||
ctxt.lineWidth = 2;
|
ctxt.lineWidth = 2;
|
||||||
var radius = 1;
|
var radius = 1;
|
||||||
for (var ii = 0; ii < qmlProfilerModelProxy.count(); ++ii) {
|
modelRowStart = 0;
|
||||||
if (qmlProfilerModelProxy.getBindingLoopDest(ii) >= 0) {
|
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
|
||||||
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(ii) +
|
for (ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
|
||||||
qmlProfilerModelProxy.getDuration(ii) -
|
if (qmlProfilerModelProxy.getBindingLoopDest(modelIndex,ii) >= 0) {
|
||||||
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(modelIndex,ii) +
|
||||||
var ycenter = Math.round(bump + qmlProfilerModelProxy.getType(ii) *
|
qmlProfilerModelProxy.getDuration(modelIndex,ii) -
|
||||||
blockHeight + blockHeight/2);
|
qmlProfilerModelProxy.traceStartTime()) * spacing;
|
||||||
ctxt.arc(xcenter, ycenter, radius, 0, 2*Math.PI, true);
|
var ycenter = Math.round(bump + (modelRowStart +
|
||||||
ctxt.stroke();
|
qmlProfilerModelProxy.getEventCategoryInModel(modelIndex, ii)) *
|
||||||
|
blockHeight + blockHeight/2);
|
||||||
|
ctxt.arc(xcenter, ycenter, radius, 0, 2*Math.PI, true);
|
||||||
|
ctxt.stroke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
modelRowStart += qmlProfilerModelProxy.categoryCount(modelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawTimeBar(canvas, ctxt, region)
|
function drawTimeBar(canvas, ctxt, region)
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ SOURCES += \
|
|||||||
qmlprofilerprocessedmodel.cpp \
|
qmlprofilerprocessedmodel.cpp \
|
||||||
qmlprofilereventsmodelproxy.cpp \
|
qmlprofilereventsmodelproxy.cpp \
|
||||||
qmlprofilertimelinemodelproxy.cpp \
|
qmlprofilertimelinemodelproxy.cpp \
|
||||||
qmlprofileroverviewmodelproxy.cpp \
|
|
||||||
qmlprofilertreeview.cpp \
|
qmlprofilertreeview.cpp \
|
||||||
qmlprofilertracefile.cpp \
|
qmlprofilertracefile.cpp \
|
||||||
abstracttimelinemodel.cpp \
|
abstracttimelinemodel.cpp \
|
||||||
@@ -57,7 +56,6 @@ HEADERS += \
|
|||||||
qmlprofilerprocessedmodel.h \
|
qmlprofilerprocessedmodel.h \
|
||||||
qmlprofilereventsmodelproxy.h \
|
qmlprofilereventsmodelproxy.h \
|
||||||
qmlprofilertimelinemodelproxy.h \
|
qmlprofilertimelinemodelproxy.h \
|
||||||
qmlprofileroverviewmodelproxy.h \
|
|
||||||
qmlprofilertreeview.h \
|
qmlprofilertreeview.h \
|
||||||
qmlprofilertracefile.h \
|
qmlprofilertracefile.h \
|
||||||
abstracttimelinemodel.h \
|
abstracttimelinemodel.h \
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ QtcPlugin {
|
|||||||
"qmlprofilereventview.h",
|
"qmlprofilereventview.h",
|
||||||
"qmlprofilermodelmanager.cpp",
|
"qmlprofilermodelmanager.cpp",
|
||||||
"qmlprofilermodelmanager.h",
|
"qmlprofilermodelmanager.h",
|
||||||
"qmlprofileroverviewmodelproxy.cpp",
|
|
||||||
"qmlprofileroverviewmodelproxy.h",
|
|
||||||
"qmlprofilerplugin.cpp",
|
"qmlprofilerplugin.cpp",
|
||||||
"qmlprofilerplugin.h",
|
"qmlprofilerplugin.h",
|
||||||
"qmlprofilerprocessedmodel.cpp",
|
"qmlprofilerprocessedmodel.cpp",
|
||||||
|
|||||||
@@ -1,227 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "qmlprofileroverviewmodelproxy.h"
|
|
||||||
#include "qmlprofilermodelmanager.h"
|
|
||||||
#include "qmlprofilersimplemodel.h"
|
|
||||||
|
|
||||||
#include <qmldebug/qmlprofilereventtypes.h>
|
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QStack>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace QmlProfiler {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlProfilerOverviewModelProxy::QmlProfilerOverviewModelProxyPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QmlProfilerOverviewModelProxyPrivate(QmlProfilerOverviewModelProxy *qq) : q(qq) {}
|
|
||||||
~QmlProfilerOverviewModelProxyPrivate() {}
|
|
||||||
|
|
||||||
QVector <QmlProfilerOverviewModelProxy::QmlOverviewEvent> data;
|
|
||||||
int rowCount;
|
|
||||||
|
|
||||||
QmlProfilerModelManager *modelManager;
|
|
||||||
QmlProfilerOverviewModelProxy *q;
|
|
||||||
};
|
|
||||||
|
|
||||||
QmlProfilerOverviewModelProxy::QmlProfilerOverviewModelProxy(QmlProfilerModelManager *modelManager, QObject *parent)
|
|
||||||
: QObject(parent), d(new QmlProfilerOverviewModelProxyPrivate(this))
|
|
||||||
{
|
|
||||||
d->modelManager = modelManager;
|
|
||||||
connect(modelManager->simpleModel(),SIGNAL(changed()),this,SLOT(dataChanged()));
|
|
||||||
connect(modelManager,SIGNAL(countChanged()),this,SIGNAL(countChanged()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlProfilerOverviewModelProxy::~QmlProfilerOverviewModelProxy()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QVector<QmlProfilerOverviewModelProxy::QmlOverviewEvent> QmlProfilerOverviewModelProxy::getData() const
|
|
||||||
{
|
|
||||||
return d->data;
|
|
||||||
}
|
|
||||||
void QmlProfilerOverviewModelProxy::clear()
|
|
||||||
{
|
|
||||||
d->data.clear();
|
|
||||||
d->rowCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerOverviewModelProxy::dataChanged()
|
|
||||||
{
|
|
||||||
loadData();
|
|
||||||
|
|
||||||
emit dataAvailable();
|
|
||||||
emit emptyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerOverviewModelProxy::detectBindingLoops()
|
|
||||||
{
|
|
||||||
QStack<int> callStack;
|
|
||||||
|
|
||||||
static QVector<int> acceptedTypes =
|
|
||||||
QVector<int>() << QmlDebug::Compiling << QmlDebug::Creating
|
|
||||||
<< QmlDebug::Binding << QmlDebug::HandlingSignal;
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < d->data.size(); ++i) {
|
|
||||||
QmlOverviewEvent *event = &d->data[i];
|
|
||||||
|
|
||||||
if (!acceptedTypes.contains(event->eventType))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QmlOverviewEvent *potentialParent = callStack.isEmpty() ? 0 : &d->data[callStack.top()];
|
|
||||||
|
|
||||||
while (potentialParent
|
|
||||||
&& !(potentialParent->startTime + potentialParent->duration > event->startTime)) {
|
|
||||||
callStack.pop();
|
|
||||||
potentialParent = callStack.isEmpty() ? 0 : &d->data[callStack.top()];
|
|
||||||
}
|
|
||||||
|
|
||||||
// check whether event is already in stack
|
|
||||||
for (int ii = 0; ii < callStack.size(); ++ii) {
|
|
||||||
if (d->data[callStack.at(ii)].eventId == event->eventId) {
|
|
||||||
event->bindingLoopHead = callStack.at(ii);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callStack.push(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool compareEvents(const QmlProfilerOverviewModelProxy::QmlOverviewEvent &t1, const QmlProfilerOverviewModelProxy::QmlOverviewEvent &t2)
|
|
||||||
{
|
|
||||||
return t1.startTime < t2.startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QmlProfilerOverviewModelProxy::loadData()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
|
|
||||||
if (simpleModel->isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QHash <QString, int> eventIdDict;
|
|
||||||
|
|
||||||
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList = simpleModel->getEvents();
|
|
||||||
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
|
|
||||||
|
|
||||||
// find event id
|
|
||||||
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
|
|
||||||
int eventId;
|
|
||||||
if (eventIdDict.contains(eventHash)) {
|
|
||||||
eventId = eventIdDict[eventHash];
|
|
||||||
} else {
|
|
||||||
eventId = eventIdDict.count();
|
|
||||||
eventIdDict.insert(eventHash, eventId);
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlOverviewEvent newEvent = {
|
|
||||||
event.eventType,
|
|
||||||
event.startTime,
|
|
||||||
event.duration,
|
|
||||||
1.0, // height
|
|
||||||
eventId, // eventId
|
|
||||||
event.eventType, // eventType
|
|
||||||
-1 // bindingLoopHead
|
|
||||||
};
|
|
||||||
d->data.append(newEvent);
|
|
||||||
|
|
||||||
if (event.eventType > d->rowCount)
|
|
||||||
d->rowCount = event.eventType;
|
|
||||||
}
|
|
||||||
|
|
||||||
qSort(d->data.begin(), d->data.end(), compareEvents);
|
|
||||||
|
|
||||||
detectBindingLoops();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////// QML interface
|
|
||||||
|
|
||||||
bool QmlProfilerOverviewModelProxy::isEmpty() const
|
|
||||||
{
|
|
||||||
return count() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerOverviewModelProxy::count() const
|
|
||||||
{
|
|
||||||
return d->data.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 QmlProfilerOverviewModelProxy::traceStartTime() const
|
|
||||||
{
|
|
||||||
return d->modelManager->traceTime()->startTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 QmlProfilerOverviewModelProxy::traceDuration() const
|
|
||||||
{
|
|
||||||
return d->modelManager->traceTime()->duration();
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 QmlProfilerOverviewModelProxy::traceEndTime() const
|
|
||||||
{
|
|
||||||
return d->modelManager->traceTime()->endTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 QmlProfilerOverviewModelProxy::getStartTime(int index) const
|
|
||||||
{
|
|
||||||
return d->data[index].startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 QmlProfilerOverviewModelProxy::getDuration(int index) const
|
|
||||||
{
|
|
||||||
return d->data[index].duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerOverviewModelProxy::getType(int index) const
|
|
||||||
{
|
|
||||||
return d->data[index].row;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerOverviewModelProxy::getEventId(int index) const
|
|
||||||
{
|
|
||||||
return d->data[index].eventId;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QmlProfilerOverviewModelProxy::getBindingLoopDest(int index) const
|
|
||||||
{
|
|
||||||
return d->data[index].bindingLoopHead;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
||||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef QMLPROFILEROVERVIEWMODELPROXY_H
|
|
||||||
#define QMLPROFILEROVERVIEWMODELPROXY_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
|
||||||
namespace QmlProfiler {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlProfilerModelManager;
|
|
||||||
|
|
||||||
class QmlProfilerOverviewModelProxy : public QObject
|
|
||||||
{
|
|
||||||
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
|
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
struct QmlOverviewEvent {
|
|
||||||
int row;
|
|
||||||
qint64 startTime;
|
|
||||||
qint64 duration;
|
|
||||||
double height;
|
|
||||||
int eventId;
|
|
||||||
int eventType;
|
|
||||||
int bindingLoopHead;
|
|
||||||
};
|
|
||||||
|
|
||||||
QmlProfilerOverviewModelProxy(QmlProfilerModelManager *modelManager, QObject *parent = 0);
|
|
||||||
~QmlProfilerOverviewModelProxy();
|
|
||||||
|
|
||||||
const QVector<QmlOverviewEvent> getData() const;
|
|
||||||
|
|
||||||
void loadData();
|
|
||||||
Q_INVOKABLE int count() const;
|
|
||||||
Q_INVOKABLE qint64 traceStartTime() const;
|
|
||||||
Q_INVOKABLE qint64 traceDuration() const;
|
|
||||||
Q_INVOKABLE qint64 traceEndTime() const;
|
|
||||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
|
||||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
|
||||||
Q_INVOKABLE int getType(int index) const;
|
|
||||||
Q_INVOKABLE int getEventId(int index) const;
|
|
||||||
Q_INVOKABLE int getBindingLoopDest(int i) const;
|
|
||||||
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
int rowCount() const;
|
|
||||||
|
|
||||||
|
|
||||||
// QML interface
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void countChanged();
|
|
||||||
void dataAvailable();
|
|
||||||
// void stateChanged();
|
|
||||||
void emptyChanged();
|
|
||||||
// void expandedChanged();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void dataChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void detectBindingLoops();
|
|
||||||
|
|
||||||
private:
|
|
||||||
class QmlProfilerOverviewModelProxyPrivate;
|
|
||||||
QmlProfilerOverviewModelProxyPrivate *d;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -283,6 +283,13 @@ int PaintEventsModelProxy::getEventType(int index) const
|
|||||||
return (int)QmlDebug::Painting;
|
return (int)QmlDebug::Painting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PaintEventsModelProxy::getEventCategory(int index) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
|
// there is only one category, all events belong to it
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int PaintEventsModelProxy::getEventRow(int index) const
|
int PaintEventsModelProxy::getEventRow(int index) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index);
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
int findLastIndex(qint64 endTime) const;
|
int findLastIndex(qint64 endTime) const;
|
||||||
|
|
||||||
int getEventType(int index) const;
|
int getEventType(int index) const;
|
||||||
|
Q_INVOKABLE int getEventCategory(int index) const;
|
||||||
int getEventRow(int index) const;
|
int getEventRow(int index) const;
|
||||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||||
|
|||||||
@@ -541,6 +541,15 @@ int BasicTimelineModel::getEventType(int index) const
|
|||||||
return d->eventDict[d->startTimeData[index].eventId].eventType;
|
return d->eventDict[d->startTimeData[index].eventId].eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BasicTimelineModel::getEventCategory(int index) const
|
||||||
|
{
|
||||||
|
int evTy = getEventType(index);
|
||||||
|
// special: paint events shown?
|
||||||
|
if (d->categorySpan[0].empty && !isEmpty())
|
||||||
|
return evTy - 1;
|
||||||
|
return evTy;
|
||||||
|
}
|
||||||
|
|
||||||
int BasicTimelineModel::getEventRow(int index) const
|
int BasicTimelineModel::getEventRow(int index) const
|
||||||
{
|
{
|
||||||
if (d->categorySpan[getEventType(index)].expanded)
|
if (d->categorySpan[getEventType(index)].expanded)
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ public:
|
|||||||
int findLastIndex(qint64 endTime) const;
|
int findLastIndex(qint64 endTime) const;
|
||||||
|
|
||||||
int getEventType(int index) const;
|
int getEventType(int index) const;
|
||||||
|
int getEventCategory(int index) const;
|
||||||
int getEventRow(int index) const;
|
int getEventRow(int index) const;
|
||||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "qmlprofilermodelmanager.h"
|
#include "qmlprofilermodelmanager.h"
|
||||||
#include "qmlprofilertimelinemodelproxy.h"
|
#include "qmlprofilertimelinemodelproxy.h"
|
||||||
#include "timelinemodelaggregator.h"
|
#include "timelinemodelaggregator.h"
|
||||||
#include "qmlprofileroverviewmodelproxy.h"
|
|
||||||
|
|
||||||
// Needed for the load&save actions in the context menu
|
// Needed for the load&save actions in the context menu
|
||||||
#include <analyzerbase/ianalyzertool.h>
|
#include <analyzerbase/ianalyzertool.h>
|
||||||
@@ -123,9 +122,8 @@ public:
|
|||||||
QDeclarativeView *m_timebar;
|
QDeclarativeView *m_timebar;
|
||||||
QDeclarativeView *m_overview;
|
QDeclarativeView *m_overview;
|
||||||
QmlProfilerModelManager *m_modelManager;
|
QmlProfilerModelManager *m_modelManager;
|
||||||
// BasicTimelineModel *m_modelProxy;
|
|
||||||
TimelineModelAggregator *m_modelProxy;
|
TimelineModelAggregator *m_modelProxy;
|
||||||
QmlProfilerOverviewModelProxy *m_overviewProxy;
|
|
||||||
|
|
||||||
ZoomControl *m_zoomControl;
|
ZoomControl *m_zoomControl;
|
||||||
|
|
||||||
@@ -189,14 +187,12 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
|||||||
d->m_modelManager = modelManager;
|
d->m_modelManager = modelManager;
|
||||||
d->m_modelProxy = new TimelineModelAggregator(this);
|
d->m_modelProxy = new TimelineModelAggregator(this);
|
||||||
d->m_modelProxy->setModelManager(modelManager);
|
d->m_modelProxy->setModelManager(modelManager);
|
||||||
// d->m_modelProxy = new BasicTimelineModel(modelManager, this);
|
|
||||||
d->m_overviewProxy = new QmlProfilerOverviewModelProxy(modelManager, this);
|
|
||||||
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
connect(d->m_modelManager, SIGNAL(stateChanged()),
|
||||||
this, SLOT(profilerDataModelStateChanged()));
|
this, SLOT(profilerDataModelStateChanged()));
|
||||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||||
d->m_modelProxy);
|
d->m_modelProxy);
|
||||||
d->m_overview->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
d->m_overview->rootContext()->setContextProperty(QLatin1String("qmlProfilerModelProxy"),
|
||||||
d->m_overviewProxy);
|
d->m_modelProxy);
|
||||||
|
|
||||||
d->m_profilerState = profilerState;
|
d->m_profilerState = profilerState;
|
||||||
connect(d->m_profilerState, SIGNAL(stateChanged()),
|
connect(d->m_profilerState, SIGNAL(stateChanged()),
|
||||||
|
|||||||
@@ -107,6 +107,17 @@ int TimelineModelAggregator::categories() const
|
|||||||
return categoryCount;
|
return categoryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimelineModelAggregator::visibleCategories() const
|
||||||
|
{
|
||||||
|
int categoryCount = 0;
|
||||||
|
foreach (const AbstractTimelineModel *modelProxy, d->modelList) {
|
||||||
|
for (int i = 0; i < modelProxy->categories(); i++)
|
||||||
|
if (modelProxy->categoryDepth(i) > 0)
|
||||||
|
categoryCount ++;
|
||||||
|
}
|
||||||
|
return categoryCount;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList TimelineModelAggregator::categoryTitles() const
|
QStringList TimelineModelAggregator::categoryTitles() const
|
||||||
{
|
{
|
||||||
QStringList retString;
|
QStringList retString;
|
||||||
@@ -235,6 +246,11 @@ int TimelineModelAggregator::getEventType(int modelIndex, int index) const
|
|||||||
return d->modelList[modelIndex]->getEventType(index);
|
return d->modelList[modelIndex]->getEventType(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TimelineModelAggregator::getEventCategoryInModel(int modelIndex, int index) const
|
||||||
|
{
|
||||||
|
return d->modelList[modelIndex]->getEventCategory(index);
|
||||||
|
}
|
||||||
|
|
||||||
int TimelineModelAggregator::getEventRow(int modelIndex, int index) const
|
int TimelineModelAggregator::getEventRow(int modelIndex, int index) const
|
||||||
{
|
{
|
||||||
return d->modelList[modelIndex]->getEventRow(index);
|
return d->modelList[modelIndex]->getEventRow(index);
|
||||||
@@ -270,6 +286,17 @@ QColor TimelineModelAggregator::getColor(int modelIndex, int index) const
|
|||||||
return d->modelList[modelIndex]->getColor(index);
|
return d->modelList[modelIndex]->getColor(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantList TimelineModelAggregator::getColorRGB(int modelIndex, int itemIndex) const
|
||||||
|
{
|
||||||
|
// return color as RGB list, for use in Qml
|
||||||
|
QColor c = getColor(modelIndex, itemIndex);
|
||||||
|
QVariantList res;
|
||||||
|
res.append(QVariant(c.red()));
|
||||||
|
res.append(QVariant(c.green()));
|
||||||
|
res.append(QVariant(c.blue()));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
float TimelineModelAggregator::getHeight(int modelIndex, int index) const
|
float TimelineModelAggregator::getHeight(int modelIndex, int index) const
|
||||||
{
|
{
|
||||||
return d->modelList[modelIndex]->getHeight(index);
|
return d->modelList[modelIndex]->getHeight(index);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
Q_INVOKABLE int categories() const;
|
Q_INVOKABLE int categories() const;
|
||||||
|
Q_INVOKABLE int visibleCategories() const;
|
||||||
Q_INVOKABLE QStringList categoryTitles() const;
|
Q_INVOKABLE QStringList categoryTitles() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
Q_INVOKABLE int count(int modelIndex = -1) const;
|
Q_INVOKABLE int count(int modelIndex = -1) const;
|
||||||
@@ -78,6 +79,7 @@ public:
|
|||||||
int findLastIndex(int modelIndex, qint64 endTime) const;
|
int findLastIndex(int modelIndex, qint64 endTime) const;
|
||||||
|
|
||||||
int getEventType(int modelIndex, int index) const;
|
int getEventType(int modelIndex, int index) const;
|
||||||
|
Q_INVOKABLE int getEventCategoryInModel(int modelIndex, int index) const;
|
||||||
int getEventRow(int modelIndex, int index) const;
|
int getEventRow(int modelIndex, int index) const;
|
||||||
Q_INVOKABLE qint64 getDuration(int modelIndex, int index) const;
|
Q_INVOKABLE qint64 getDuration(int modelIndex, int index) const;
|
||||||
Q_INVOKABLE qint64 getStartTime(int modelIndex, int index) const;
|
Q_INVOKABLE qint64 getStartTime(int modelIndex, int index) const;
|
||||||
@@ -85,6 +87,7 @@ public:
|
|||||||
Q_INVOKABLE int getEventId(int modelIndex, int index) const;
|
Q_INVOKABLE int getEventId(int modelIndex, int index) const;
|
||||||
Q_INVOKABLE int getBindingLoopDest(int modelIndex, int index) const;
|
Q_INVOKABLE int getBindingLoopDest(int modelIndex, int index) const;
|
||||||
Q_INVOKABLE QColor getColor(int modelIndex, int index) const;
|
Q_INVOKABLE QColor getColor(int modelIndex, int index) const;
|
||||||
|
Q_INVOKABLE QVariantList getColorRGB(int modelIndex, int itemIndex) const;
|
||||||
Q_INVOKABLE float getHeight(int modelIndex, int index) const;
|
Q_INVOKABLE float getHeight(int modelIndex, int index) const;
|
||||||
|
|
||||||
Q_INVOKABLE const QVariantList getLabelsForCategory(int modelIndex, int category) const;
|
Q_INVOKABLE const QVariantList getLabelsForCategory(int modelIndex, int category) const;
|
||||||
|
|||||||
@@ -200,7 +200,13 @@ int SceneGraphTimelineModel::getEventType(int index) const
|
|||||||
// TODO fix
|
// TODO fix
|
||||||
return QmlDebug::PixmapCacheEvent;
|
return QmlDebug::PixmapCacheEvent;
|
||||||
//return QmlDebug::SceneGraphFrameEvent;
|
//return QmlDebug::SceneGraphFrameEvent;
|
||||||
// return 0;
|
// return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SceneGraphTimelineModel::getEventCategory(int index) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SceneGraphTimelineModel::getEventRow(int index) const
|
int SceneGraphTimelineModel::getEventRow(int index) const
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
int findLastIndex(qint64 endTime) const;
|
int findLastIndex(qint64 endTime) const;
|
||||||
|
|
||||||
int getEventType(int index) const;
|
int getEventType(int index) const;
|
||||||
|
int getEventCategory(int index) const;
|
||||||
int getEventRow(int index) const;
|
int getEventRow(int index) const;
|
||||||
Q_INVOKABLE qint64 getDuration(int index) const;
|
Q_INVOKABLE qint64 getDuration(int index) const;
|
||||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user