From 08533d26596bb56f971081e2951d48ca26ff90a5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 21 May 2015 17:48:58 +0200 Subject: qmlprofiler: Record input events Change-Id: Ib6413d97638b192377d7dbeb19ed0c2f733a06a1 Reviewed-by: Joerg Bornemann --- tools/qmlprofiler/qmlprofilerapplication.cpp | 2 ++ tools/qmlprofiler/qmlprofilerclient.cpp | 5 +++- tools/qmlprofiler/qmlprofilerclient.h | 1 + tools/qmlprofiler/qmlprofilerdata.cpp | 40 ++++++++++++++++++++++++---- tools/qmlprofiler/qmlprofilerdata.h | 1 + 5 files changed, 43 insertions(+), 6 deletions(-) (limited to 'tools/qmlprofiler') diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 1b3a90a1a1..fbea376082 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -104,6 +104,8 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : qint64)), &m_profilerData, SLOT(addMemoryEvent(QQmlProfilerService::MemoryType,qint64, qint64))); + connect(&m_qmlProfilerClient, SIGNAL(inputEvent(QQmlProfilerService::EventType,qint64)), + &m_profilerData, SLOT(addInputEvent(QQmlProfilerService::EventType,qint64))); connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete())); diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp index f6ac846668..4f06514d8d 100644 --- a/tools/qmlprofiler/qmlprofilerclient.cpp +++ b/tools/qmlprofiler/qmlprofilerclient.cpp @@ -141,7 +141,10 @@ void QmlProfilerClient::messageReceived(const QByteArray &data) emit this->frame(time, frameRate, animationCount, threadId); } else if (event == QQmlProfilerService::StartTrace) { emit this->traceStarted(time); - } else if (event < QQmlProfilerService::MaximumEventType) { + } else if (event == QQmlProfilerService::Key || event == QQmlProfilerService::Mouse) { + if (!(d->features & one << QQmlProfilerService::ProfileInputEvents)) + return; + emit this->inputEvent((QQmlProfilerService::EventType)event, time); } } else if (messageType == QQmlProfilerService::Complete) { emit complete(); diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h index 84da96197b..1dd5ccfea9 100644 --- a/tools/qmlprofiler/qmlprofilerclient.h +++ b/tools/qmlprofiler/qmlprofilerclient.h @@ -93,6 +93,7 @@ signals: void pixmapCache(QQmlProfilerService::PixmapEventType, qint64 time, const QmlEventLocation &location, int width, int height, int refCount); void memoryAllocation(QQmlProfilerService::MemoryType type, qint64 time, qint64 amount); + void inputEvent(QQmlProfilerService::EventType, qint64 time); protected: virtual void messageReceived(const QByteArray &); diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp index 72aeafcb0f..6f8701d2cc 100644 --- a/tools/qmlprofiler/qmlprofilerdata.cpp +++ b/tools/qmlprofiler/qmlprofilerdata.cpp @@ -390,6 +390,25 @@ void QmlProfilerData::addMemoryEvent(QQmlProfilerService::MemoryType type, qint6 d->startInstanceList.append(rangeEventStartInstance); } +void QmlProfilerData::addInputEvent(QQmlProfilerDefinitions::EventType type, qint64 time) +{ + setState(AcquiringData); + + QString eventHashStr = QString::fromLatin1("Input:%1").arg(type); + + QmlRangeEventData *newEvent; + if (d->eventDescriptions.contains(eventHashStr)) { + newEvent = d->eventDescriptions[eventHashStr]; + } else { + newEvent = new QmlRangeEventData(QString(), type, eventHashStr, QmlEventLocation(), + QString(), QQmlProfilerService::Event, + QQmlProfilerService::MaximumRangeType); + d->eventDescriptions.insert(eventHashStr, newEvent); + } + + d->startInstanceList.append(QmlRangeEventStartInstance(time, -1, 0, 0, 0, newEvent)); +} + QString QmlProfilerData::rootEventName() { return tr(""); @@ -599,11 +618,22 @@ bool QmlProfilerData::save(const QString &filename) if (eventData->rangeType == QQmlProfilerService::Binding) stream.writeTextElement(QStringLiteral("bindingType"), QString::number((int)eventData->detailType)); - else if (eventData->message == QQmlProfilerService::Event && - eventData->detailType == QQmlProfilerService::AnimationFrame) - stream.writeTextElement(QStringLiteral("animationFrame"), - QString::number((int)eventData->detailType)); - else if (eventData->message == QQmlProfilerService::PixmapCacheEvent) + else if (eventData->message == QQmlProfilerService::Event) { + switch (eventData->detailType) { + case QQmlProfilerService::AnimationFrame: + stream.writeTextElement(QStringLiteral("animationFrame"), + QString::number((int)eventData->detailType)); + break; + case QQmlProfilerService::Key: + stream.writeTextElement(QStringLiteral("keyEvent"), + QString::number((int)eventData->detailType)); + break; + case QQmlProfilerService::Mouse: + stream.writeTextElement(QStringLiteral("mouseEvent"), + QString::number((int)eventData->detailType)); + break; + } + } else if (eventData->message == QQmlProfilerService::PixmapCacheEvent) stream.writeTextElement(QStringLiteral("cacheEventType"), QString::number((int)eventData->detailType)); else if (eventData->message == QQmlProfilerService::SceneGraphFrame) diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h index d420275d5e..ef8ef10929 100644 --- a/tools/qmlprofiler/qmlprofilerdata.h +++ b/tools/qmlprofiler/qmlprofilerdata.h @@ -88,6 +88,7 @@ public slots: void addPixmapCacheEvent(QQmlProfilerService::PixmapEventType type, qint64 time, const QmlEventLocation &location, int width, int height, int refcount); void addMemoryEvent(QQmlProfilerService::MemoryType type, qint64 time, qint64 size); + void addInputEvent(QQmlProfilerService::EventType type, qint64 time); void complete(); bool save(const QString &filename); -- cgit v1.2.3