forked from qt-creator/qt-creator
QmlJSDebugClient: Move QmlProfilerTraceClient into library
Change-Id: I1c0821778a3350ec55741b45680fca2cb1fed3aa Reviewed-on: http://codereview.qt.nokia.com/2680 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
@@ -26,7 +26,6 @@ SOURCES += \
|
||||
localqmlprofilerrunner.cpp \
|
||||
codaqmlprofilerrunner.cpp \
|
||||
remotelinuxqmlprofilerrunner.cpp \
|
||||
qmlprofilertraceclient.cpp \
|
||||
qmlprofilereventview.cpp \
|
||||
qmlprofilerruncontrolfactory.cpp
|
||||
|
||||
@@ -43,9 +42,7 @@ HEADERS += \
|
||||
localqmlprofilerrunner.h \
|
||||
codaqmlprofilerrunner.h \
|
||||
remotelinuxqmlprofilerrunner.h \
|
||||
qmlprofilertraceclient.h \
|
||||
qmlprofilereventview.h \
|
||||
qmlprofilereventtypes.h \
|
||||
qmlprofilerruncontrolfactory.h
|
||||
|
||||
RESOURCES += \
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROFILEREVENTTYPES_H
|
||||
#define QMLPROFILEREVENTTYPES_H
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
enum QmlEventType {
|
||||
Painting,
|
||||
Compiling,
|
||||
Creating,
|
||||
Binding,
|
||||
HandlingSignal,
|
||||
|
||||
MaximumQmlEventType
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //QMLPROFILEREVENTTYPES_H
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
|
||||
using namespace QmlJsDebugClient;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define QMLPROFILEREVENTVIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include "qmlprofilereventtypes.h"
|
||||
#include <qmljsdebugclient/qmlprofilereventtypes.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
@@ -42,7 +42,7 @@ namespace Internal {
|
||||
struct QmlEventData
|
||||
{
|
||||
QmlEventData() : displayname(0) , filename(0) , location(0) , details(0),
|
||||
line(0), eventType(MaximumQmlEventType), level(-1), parentList(0), childrenList(0) {}
|
||||
line(0), eventType(QmlJsDebugClient::MaximumQmlEventType), level(-1), parentList(0), childrenList(0) {}
|
||||
~QmlEventData() {
|
||||
delete displayname;
|
||||
delete filename;
|
||||
@@ -55,7 +55,7 @@ struct QmlEventData
|
||||
QString *location;
|
||||
QString *details;
|
||||
int line;
|
||||
QmlEventType eventType;
|
||||
QmlJsDebugClient::QmlEventType eventType;
|
||||
qint64 level;
|
||||
QList< QmlEventData *> *parentList;
|
||||
QList< QmlEventData *> *childrenList;
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "qmlprofilertraceclient.h"
|
||||
|
||||
using namespace QmlProfiler::Internal;
|
||||
using namespace QmlJsDebugClient;
|
||||
|
||||
static const int GAP_TIME = 150;
|
||||
|
||||
QmlProfilerTraceClient::QmlProfilerTraceClient(QDeclarativeDebugConnection *client)
|
||||
: QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client),
|
||||
m_inProgressRanges(0), m_maximumTime(0), m_recording(false), m_nestingLevel(0)
|
||||
{
|
||||
::memset(m_rangeCount, 0, MaximumQmlEventType * sizeof(int));
|
||||
::memset(m_nestingInType, 0, MaximumQmlEventType * sizeof(int));
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::clearView()
|
||||
{
|
||||
::memset(m_rangeCount, 0, MaximumQmlEventType * sizeof(int));
|
||||
::memset(m_nestingInType, 0, MaximumQmlEventType * sizeof(int));
|
||||
m_nestingLevel = 0;
|
||||
emit clear();
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::setRecording(bool v)
|
||||
{
|
||||
if (v == m_recording)
|
||||
return;
|
||||
|
||||
if (status() == Enabled) {
|
||||
QByteArray ba;
|
||||
QDataStream stream(&ba, QIODevice::WriteOnly);
|
||||
stream << v;
|
||||
sendMessage(ba);
|
||||
}
|
||||
|
||||
m_recording = v;
|
||||
emit recordingChanged(v);
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::statusChanged(Status status)
|
||||
{
|
||||
if (status == Enabled) {
|
||||
m_recording = !m_recording;
|
||||
setRecording(!m_recording);
|
||||
emit enabled();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QByteArray rwData = data;
|
||||
QDataStream stream(&rwData, QIODevice::ReadOnly);
|
||||
|
||||
qint64 time;
|
||||
int messageType;
|
||||
|
||||
stream >> time >> messageType;
|
||||
|
||||
// qDebug() << __FUNCTION__ << messageType;
|
||||
|
||||
if (messageType >= MaximumMessage)
|
||||
return;
|
||||
|
||||
if (time > (m_maximumTime + GAP_TIME) && 0 == m_inProgressRanges)
|
||||
emit gap(time);
|
||||
|
||||
if (messageType == Event) {
|
||||
int event;
|
||||
stream >> event;
|
||||
|
||||
if (event < MaximumEventType) {
|
||||
emit this->event((EventType)event, time);
|
||||
m_maximumTime = qMax(time, m_maximumTime);
|
||||
}
|
||||
} else if (messageType == Complete) {
|
||||
emit complete();
|
||||
} else {
|
||||
int range;
|
||||
stream >> range;
|
||||
|
||||
if (range >= MaximumQmlEventType)
|
||||
return;
|
||||
|
||||
if (messageType == RangeStart) {
|
||||
m_rangeStartTimes[range].push(time);
|
||||
m_inProgressRanges |= (static_cast<qint64>(1) << range);
|
||||
++m_rangeCount[range];
|
||||
++m_nestingLevel;
|
||||
++m_nestingInType[range];
|
||||
} else if (messageType == RangeData) {
|
||||
QString data;
|
||||
stream >> data;
|
||||
|
||||
int count = m_rangeCount[range];
|
||||
if (count > 0) {
|
||||
while (m_rangeDatas[range].count() < count)
|
||||
m_rangeDatas[range].push(QStringList());
|
||||
m_rangeDatas[range][count-1] << data;
|
||||
}
|
||||
|
||||
} else if (messageType == RangeLocation) {
|
||||
QString fileName;
|
||||
int line;
|
||||
stream >> fileName >> line;
|
||||
|
||||
if (m_rangeCount[range] > 0) {
|
||||
m_rangeLocations[range].push(Location(fileName, line));
|
||||
}
|
||||
} else {
|
||||
if (m_rangeCount[range] > 0) {
|
||||
--m_rangeCount[range];
|
||||
if (m_inProgressRanges & (static_cast<qint64>(1) << range))
|
||||
m_inProgressRanges &= ~(static_cast<qint64>(1) << range);
|
||||
|
||||
m_maximumTime = qMax(time, m_maximumTime);
|
||||
QStringList data = m_rangeDatas[range].count() ? m_rangeDatas[range].pop() : QStringList();
|
||||
Location location = m_rangeLocations[range].count() ? m_rangeLocations[range].pop() : Location();
|
||||
|
||||
qint64 startTime = m_rangeStartTimes[range].pop();
|
||||
emit this->range((QmlEventType)range, m_nestingLevel, m_nestingInType[range], startTime,
|
||||
time - startTime, data, location.fileName, location.line);
|
||||
--m_nestingLevel;
|
||||
--m_nestingInType[range];
|
||||
if (m_rangeCount[range] == 0) {
|
||||
int count = m_rangeDatas[range].count() +
|
||||
m_rangeStartTimes[range].count() +
|
||||
m_rangeLocations[range].count();
|
||||
if (count != 0)
|
||||
qWarning() << "incorrectly nested data";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QMLPROFILERTRACECLIENT_H
|
||||
#define QMLPROFILERTRACECLIENT_H
|
||||
|
||||
#include <qmljsdebugclient/qdeclarativedebugclient.h>
|
||||
#include <QtCore/QStack>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
struct Location
|
||||
{
|
||||
Location() : line(-1) {}
|
||||
Location(const QString &file, int lineNumber) : fileName(file), line(lineNumber) {}
|
||||
QString fileName;
|
||||
int line;
|
||||
};
|
||||
|
||||
class QmlProfilerTraceClient : public QmlJsDebugClient::QDeclarativeDebugClient
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
||||
|
||||
// don't hide by signal
|
||||
using QObject::event;
|
||||
|
||||
public:
|
||||
QmlProfilerTraceClient(QmlJsDebugClient::QDeclarativeDebugConnection *client);
|
||||
|
||||
enum EventType {
|
||||
FramePaint,
|
||||
Mouse,
|
||||
Key,
|
||||
|
||||
MaximumEventType
|
||||
};
|
||||
|
||||
enum Message {
|
||||
Event,
|
||||
RangeStart,
|
||||
RangeData,
|
||||
RangeLocation,
|
||||
RangeEnd,
|
||||
Complete,
|
||||
|
||||
MaximumMessage
|
||||
};
|
||||
|
||||
bool isRecording() const { return m_recording; }
|
||||
|
||||
public slots:
|
||||
void setRecording(bool);
|
||||
void clearView();
|
||||
|
||||
signals:
|
||||
void complete();
|
||||
void gap(qint64);
|
||||
void event(int event, qint64 time);
|
||||
void range(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
|
||||
const QStringList &data, const QString &fileName, int line);
|
||||
|
||||
void sample(int, int, int, bool);
|
||||
|
||||
void recordingChanged(bool arg);
|
||||
|
||||
void enabled();
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
qint64 m_inProgressRanges;
|
||||
QStack<qint64> m_rangeStartTimes[MaximumQmlEventType];
|
||||
QStack<QStringList> m_rangeDatas[MaximumQmlEventType];
|
||||
QStack<Location> m_rangeLocations[MaximumQmlEventType];
|
||||
int m_rangeCount[MaximumQmlEventType];
|
||||
qint64 m_maximumTime;
|
||||
bool m_recording;
|
||||
int m_nestingLevel;
|
||||
int m_nestingInType[MaximumQmlEventType];
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
#endif // QMLPROFILERTRACECLIENT_H
|
||||
@@ -33,9 +33,9 @@
|
||||
#include "tracewindow.h"
|
||||
|
||||
#include "qmlprofilerplugin.h"
|
||||
#include "qmlprofilertraceclient.h"
|
||||
|
||||
#include <qmljsdebugclient/qdeclarativedebugclient.h>
|
||||
#include <qmljsdebugclient/qmlprofilertraceclient.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QtDeclarative/QDeclarativeView>
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QGraphicsObject>
|
||||
|
||||
using namespace QmlJsDebugClient;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
@@ -112,7 +114,7 @@ TraceWindow::~TraceWindow()
|
||||
delete m_plugin.data();
|
||||
}
|
||||
|
||||
void TraceWindow::reset(QmlJsDebugClient::QDeclarativeDebugConnection *conn)
|
||||
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
||||
{
|
||||
if (m_plugin)
|
||||
disconnect(m_plugin.data(), SIGNAL(complete()), this, SIGNAL(viewUpdated()));
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#ifndef TRACEWINDOW_H
|
||||
#define TRACEWINDOW_H
|
||||
|
||||
#include "qmlprofilertraceclient.h"
|
||||
#include <qmljsdebugclient/qmlprofilertraceclient.h>
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
@@ -79,7 +79,7 @@ signals:
|
||||
void enableToolbar(bool);
|
||||
|
||||
private:
|
||||
QWeakPointer<QmlProfilerTraceClient> m_plugin;
|
||||
QWeakPointer<QmlJsDebugClient::QmlProfilerTraceClient> m_plugin;
|
||||
QSize m_sizeHint;
|
||||
|
||||
QDeclarativeView *m_view;
|
||||
|
||||
Reference in New Issue
Block a user