aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/debugger/qqmlprofilerdefinitions_p.h15
-rw-r--r--src/quick/items/qquickview.cpp10
-rw-r--r--src/quick/items/qquickwindow.cpp16
-rw-r--r--src/quick/util/qquickprofiler.cpp9
-rw-r--r--src/quick/util/qquickprofiler_p.h22
-rw-r--r--src/quickwidgets/qquickwidget.cpp21
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp6
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.cpp20
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h2
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp48
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.h2
11 files changed, 128 insertions, 43 deletions
diff --git a/src/qml/debugger/qqmlprofilerdefinitions_p.h b/src/qml/debugger/qqmlprofilerdefinitions_p.h
index bdc21cbf25..f87df8cfe5 100644
--- a/src/qml/debugger/qqmlprofilerdefinitions_p.h
+++ b/src/qml/debugger/qqmlprofilerdefinitions_p.h
@@ -137,6 +137,21 @@ struct QQmlProfilerDefinitions {
MaximumProfileFeature
};
+
+ enum InputEventType {
+ InputKeyPress,
+ InputKeyRelease,
+ InputKeyUnknown,
+
+ InputMousePress,
+ InputMouseRelease,
+ InputMouseMove,
+ InputMouseDoubleClick,
+ InputMouseWheel,
+ InputMouseUnknown,
+
+ MaximumInputEventType
+ };
};
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 867f7d9d15..96f6b7ddd1 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -601,40 +601,30 @@ void QQuickView::resizeEvent(QResizeEvent *e)
/*! \reimp */
void QQuickView::keyPressEvent(QKeyEvent *e)
{
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Key>());
-
QQuickWindow::keyPressEvent(e);
}
/*! \reimp */
void QQuickView::keyReleaseEvent(QKeyEvent *e)
{
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Key>());
-
QQuickWindow::keyReleaseEvent(e);
}
/*! \reimp */
void QQuickView::mouseMoveEvent(QMouseEvent *e)
{
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
-
QQuickWindow::mouseMoveEvent(e);
}
/*! \reimp */
void QQuickView::mousePressEvent(QMouseEvent *e)
{
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
-
QQuickWindow::mousePressEvent(e);
}
/*! \reimp */
void QQuickView::mouseReleaseEvent(QMouseEvent *e)
{
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
-
QQuickWindow::mouseReleaseEvent(e);
}
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 6542bde4f1..9224c071fd 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -46,6 +46,7 @@
#include <private/qsgrenderloop_p.h>
#include <private/qquickrendercontrol_p.h>
#include <private/qquickanimatorcontroller_p.h>
+#include <private/qquickprofiler_p.h>
#include <private/qguiapplication_p.h>
#include <QtGui/QInputMethod>
@@ -1420,6 +1421,8 @@ bool QQuickWindow::event(QEvent *e)
void QQuickWindow::keyPressEvent(QKeyEvent *e)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyPress, e->key(),
+ e->modifiers());
d->deliverKeyEvent(e);
}
@@ -1427,6 +1430,8 @@ void QQuickWindow::keyPressEvent(QKeyEvent *e)
void QQuickWindow::keyReleaseEvent(QKeyEvent *e)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyRelease, e->key(),
+ e->modifiers());
d->deliverKeyEvent(e);
}
@@ -1524,6 +1529,8 @@ bool QQuickWindowPrivate::deliverMouseEvent(QMouseEvent *event)
void QQuickWindow::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMousePress, event->button(),
+ event->buttons());
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
event->accept();
@@ -1538,6 +1545,8 @@ void QQuickWindow::mousePressEvent(QMouseEvent *event)
void QQuickWindow::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseRelease, event->button(),
+ event->buttons());
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
event->accept();
@@ -1560,6 +1569,8 @@ void QQuickWindow::mouseReleaseEvent(QMouseEvent *event)
void QQuickWindow::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseDoubleClick,
+ event->button(), event->buttons());
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
event->accept();
@@ -1604,6 +1615,8 @@ bool QQuickWindowPrivate::sendHoverEvent(QEvent::Type type, QQuickItem *item,
void QQuickWindow::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove,
+ event->localPos().x(), event->localPos().y());
if (event->source() == Qt::MouseEventSynthesizedBySystem) {
event->accept();
@@ -1749,6 +1762,9 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event
void QQuickWindow::wheelEvent(QWheelEvent *event)
{
Q_D(QQuickWindow);
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseWheel,
+ event->angleDelta().x(), event->angleDelta().y());
+
qCDebug(DBG_MOUSE) << "QQuickWindow::wheelEvent()" << event->pixelDelta() << event->angleDelta() << event->phase();
//if the actual wheel event was accepted, accept the compatibility wheel event and return early
diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp
index 44fdbc5da8..5ed1ff05af 100644
--- a/src/quick/util/qquickprofiler.cpp
+++ b/src/quick/util/qquickprofiler.cpp
@@ -62,8 +62,15 @@ void QQuickProfilerData::toByteArrays(QList<QByteArray> &messages) const
switch (decodedMessageType) {
case QQuickProfiler::Event:
- if (decodedDetailType == (int)QQuickProfiler::AnimationFrame)
+ switch (decodedDetailType) {
+ case QQuickProfiler::AnimationFrame:
ds << framerate << count << threadId;
+ break;
+ case QQuickProfiler::Key:
+ case QQuickProfiler::Mouse:
+ ds << inputType << inputA << inputB;
+ break;
+ }
break;
case QQuickProfiler::PixmapCacheEvent:
ds << detailUrl.toString();
diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h
index 6b6e7fa062..78216acc7d 100644
--- a/src/quick/util/qquickprofiler_p.h
+++ b/src/quick/util/qquickprofiler_p.h
@@ -97,8 +97,9 @@ QT_BEGIN_NAMESPACE
(QQuickProfiler::reportSceneGraphFrame<Type, true>(Payload)))
-#define Q_QUICK_INPUT_PROFILE(Method)\
- Q_QUICK_PROFILE(QQuickProfiler::ProfileInputEvents, Method)
+#define Q_QUICK_INPUT_PROFILE(Type, DetailType, A, B)\
+ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileInputEvents,\
+ (QQuickProfiler::inputEvent<Type, DetailType>(A, B)))
// This struct is somewhat dangerous to use:
// You can save values either with 32 or 64 bit precision. toByteArrays will
@@ -117,10 +118,10 @@ struct Q_AUTOTEST_EXPORT QQuickProfilerData
time(time), messageType(messageType), detailType(detailType), detailUrl(url), x(x), y(y),
framerate(framerate), count(count) {}
- QQuickProfilerData(qint64 time, int messageType, int detailType, int framerate = 0,
- int count = 0, int threadId = 0) :
- time(time), messageType(messageType), detailType(detailType), framerate(framerate),
- count(count), threadId(threadId) {}
+ QQuickProfilerData(qint64 time, int messageType, int detailType, int framerateOrInputType = 0,
+ int countOrInputA = 0, int threadIdOrInputB = 0) :
+ time(time), messageType(messageType), detailType(detailType),
+ framerate(framerateOrInputType), count(countOrInputA), threadId(threadIdOrInputB) {}
// Special ctor for scenegraph frames. Note that it's missing the QString/QUrl params.
// This is slightly ugly, but makes it easier to disambiguate between int and qint64 params.
@@ -149,16 +150,19 @@ struct Q_AUTOTEST_EXPORT QQuickProfilerData
union {
qint64 subtime_3;
int framerate; //used by animation events
+ int inputType;
};
union {
qint64 subtime_4;
int count; //used by animation events and for pixmaps
+ int inputA; //used by input events
};
union {
qint64 subtime_5;
int threadId;
+ int inputB; //used by input events
};
void toByteArrays(QList<QByteArray> &messages) const;
@@ -208,11 +212,11 @@ public:
RenderThread
};
- template<EventType DetailType>
- static void addEvent()
+ template<EventType DetailType, InputEventType InputType>
+ static void inputEvent(int x, int y = 0)
{
s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 << Event,
- 1 << DetailType));
+ 1 << DetailType, InputType, x, y));
}
static void animationFrame(qint64 delta, AnimationThread threadId)
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index edaa1352ae..1f9056d062 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -1039,7 +1039,8 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
void QQuickWidget::keyPressEvent(QKeyEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Key>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyPress, e->key(),
+ e->modifiers());
QCoreApplication::sendEvent(d->offscreenWindow, e);
}
@@ -1048,7 +1049,8 @@ void QQuickWidget::keyPressEvent(QKeyEvent *e)
void QQuickWidget::keyReleaseEvent(QKeyEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Key>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Key, QQuickProfiler::InputKeyRelease, e->key(),
+ e->modifiers());
QCoreApplication::sendEvent(d->offscreenWindow, e);
}
@@ -1057,7 +1059,8 @@ void QQuickWidget::keyReleaseEvent(QKeyEvent *e)
void QQuickWidget::mouseMoveEvent(QMouseEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove, e->localPos().x(),
+ e->localPos().y());
// Use the constructor taking localPos and screenPos. That puts localPos into the
// event's localPos and windowPos, and screenPos into the event's screenPos. This way
@@ -1072,7 +1075,8 @@ void QQuickWidget::mouseMoveEvent(QMouseEvent *e)
void QQuickWidget::mouseDoubleClickEvent(QMouseEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseDoubleClick,
+ e->button(), e->buttons());
// As the second mouse press is suppressed in widget windows we emulate it here for QML.
// See QTBUG-25831
@@ -1108,7 +1112,8 @@ void QQuickWidget::hideEvent(QHideEvent *)
void QQuickWidget::mousePressEvent(QMouseEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMousePress, e->button(),
+ e->buttons());
QMouseEvent mappedEvent(e->type(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers());
QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent);
@@ -1119,7 +1124,8 @@ void QQuickWidget::mousePressEvent(QMouseEvent *e)
void QQuickWidget::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseRelease, e->button(),
+ e->buttons());
QMouseEvent mappedEvent(e->type(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers());
QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent);
@@ -1131,7 +1137,8 @@ void QQuickWidget::mouseReleaseEvent(QMouseEvent *e)
void QQuickWidget::wheelEvent(QWheelEvent *e)
{
Q_D(QQuickWidget);
- Q_QUICK_INPUT_PROFILE(addEvent<QQuickProfiler::Mouse>());
+ Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseWheel,
+ e->angleDelta().x(), e->angleDelta().y());
// Wheel events only have local and global positions, no need to map.
QCoreApplication::sendEvent(d->offscreenWindow, e);
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 2aa4afe4f6..04d0ede54a 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -112,8 +112,10 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
qint64)),
&m_profilerData, SLOT(addMemoryEvent(QQmlProfilerDefinitions::MemoryType,qint64,
qint64)));
- connect(&m_qmlProfilerClient, SIGNAL(inputEvent(QQmlProfilerDefinitions::EventType,qint64)),
- &m_profilerData, SLOT(addInputEvent(QQmlProfilerDefinitions::EventType,qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(inputEvent(QQmlProfilerDefinitions::InputEventType,qint64,
+ int,int)),
+ &m_profilerData, SLOT(addInputEvent(QQmlProfilerDefinitions::InputEventType,qint64,int,
+ int)));
connect(&m_qmlProfilerClient, SIGNAL(complete()), &m_profilerData, SLOT(complete()));
diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp
index 28cb64066d..5e63529d35 100644
--- a/tools/qmlprofiler/qmlprofilerclient.cpp
+++ b/tools/qmlprofiler/qmlprofilerclient.cpp
@@ -157,7 +157,25 @@ void QmlProfilerClient::messageReceived(const QByteArray &data)
event == QQmlProfilerDefinitions::Mouse) {
if (!(d->features & one << QQmlProfilerDefinitions::ProfileInputEvents))
return;
- emit this->inputEvent((QQmlProfilerDefinitions::EventType)event, time);
+
+ int type;
+ if (!stream.atEnd()) {
+ stream >> type;
+ } else {
+ type = (event == QQmlProfilerDefinitions::Key) ?
+ QQmlProfilerDefinitions::InputKeyUnknown :
+ QQmlProfilerDefinitions::InputMouseUnknown;
+ }
+
+ int a = 0;
+ if (!stream.atEnd())
+ stream >> a;
+
+ int b = 0;
+ if (!stream.atEnd())
+ stream >> b;
+
+ emit inputEvent(static_cast<QQmlProfilerDefinitions::InputEventType>(type), time, a, b);
}
} else if (messageType == QQmlProfilerDefinitions::Complete) {
emit complete();
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index daaf624d7d..bc267c7c88 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -68,7 +68,7 @@ signals:
void pixmapCache(QQmlProfilerDefinitions::PixmapEventType, qint64 time,
const QmlEventLocation &location, int width, int height, int refCount);
void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount);
- void inputEvent(QQmlProfilerDefinitions::EventType, qint64 time);
+ void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b);
void complete();
void enabledChanged(bool enabled);
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index f0c6302c06..4ed1a434a3 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -107,14 +107,17 @@ struct QmlRangeEventStartInstance {
qint64 duration;
union {
int frameRate;
+ int inputType;
qint64 numericData1;
};
union {
int animationCount;
+ int inputA;
qint64 numericData2;
};
union {
int threadId;
+ int inputB;
qint64 numericData3;
};
qint64 numericData4;
@@ -366,23 +369,36 @@ void QmlProfilerData::addMemoryEvent(QQmlProfilerDefinitions::MemoryType type, q
d->startInstanceList.append(rangeEventStartInstance);
}
-void QmlProfilerData::addInputEvent(QQmlProfilerDefinitions::EventType type, qint64 time)
+void QmlProfilerData::addInputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time,
+ int a, int b)
{
setState(AcquiringData);
- QString eventHashStr = QString::fromLatin1("Input:%1").arg(type);
+ QQmlProfilerDefinitions::EventType eventType;
+ switch (type) {
+ case QQmlProfilerDefinitions::InputKeyPress:
+ case QQmlProfilerDefinitions::InputKeyRelease:
+ case QQmlProfilerDefinitions::InputKeyUnknown:
+ eventType = QQmlProfilerDefinitions::Key;
+ break;
+ default:
+ eventType = QQmlProfilerDefinitions::Mouse;
+ break;
+ }
+
+ QString eventHashStr = QString::fromLatin1("Input:%1").arg(eventType);
QmlRangeEventData *newEvent;
if (d->eventDescriptions.contains(eventHashStr)) {
newEvent = d->eventDescriptions[eventHashStr];
} else {
- newEvent = new QmlRangeEventData(QString(), type, eventHashStr, QmlEventLocation(),
+ newEvent = new QmlRangeEventData(QString(), eventType, eventHashStr, QmlEventLocation(),
QString(), QQmlProfilerDefinitions::Event,
QQmlProfilerDefinitions::MaximumRangeType);
d->eventDescriptions.insert(eventHashStr, newEvent);
}
- d->startInstanceList.append(QmlRangeEventStartInstance(time, -1, 0, 0, 0, newEvent));
+ d->startInstanceList.append(QmlRangeEventStartInstance(time, -1, type, a, b, newEvent));
}
void QmlProfilerData::computeQmlTime()
@@ -567,13 +583,23 @@ bool QmlProfilerData::save(const QString &filename)
QString::number(event.duration));
stream.writeAttribute(QStringLiteral("eventIndex"), QString::number(
d->eventDescriptions.keys().indexOf(event.data->eventHashStr)));
- if (event.data->message == QQmlProfilerDefinitions::Event &&
- event.data->detailType == QQmlProfilerDefinitions::AnimationFrame) {
- // special: animation frame
- stream.writeAttribute(QStringLiteral("framerate"), QString::number(event.frameRate));
- stream.writeAttribute(QStringLiteral("animationcount"),
- QString::number(event.animationCount));
- stream.writeAttribute(QStringLiteral("thread"), QString::number(event.threadId));
+ if (event.data->message == QQmlProfilerDefinitions::Event) {
+ if (event.data->detailType == QQmlProfilerDefinitions::AnimationFrame) {
+ // special: animation frame
+ stream.writeAttribute(QStringLiteral("framerate"), QString::number(event.frameRate));
+ stream.writeAttribute(QStringLiteral("animationcount"),
+ QString::number(event.animationCount));
+ stream.writeAttribute(QStringLiteral("thread"), QString::number(event.threadId));
+ } else if (event.data->detailType == QQmlProfilerDefinitions::Key ||
+ event.data->detailType == QQmlProfilerDefinitions::Mouse) {
+ // numerical value here, to keep the format a bit more compact
+ stream.writeAttribute(QStringLiteral("type"),
+ QString::number(event.inputType));
+ stream.writeAttribute(QStringLiteral("data1"),
+ QString::number(event.inputA));
+ stream.writeAttribute(QStringLiteral("data2"),
+ QString::number(event.inputB));
+ }
} else if (event.data->message == QQmlProfilerDefinitions::PixmapCacheEvent) {
// special: pixmap cache event
if (event.data->detailType == QQmlProfilerDefinitions::PixmapSizeKnown) {
diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h
index e038fa6884..b931409917 100644
--- a/tools/qmlprofiler/qmlprofilerdata.h
+++ b/tools/qmlprofiler/qmlprofilerdata.h
@@ -83,7 +83,7 @@ public slots:
void addPixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventType type, qint64 time,
const QmlEventLocation &location, int width, int height, int refcount);
void addMemoryEvent(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 size);
- void addInputEvent(QQmlProfilerDefinitions::EventType type, qint64 time);
+ void addInputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b);
void complete();
bool save(const QString &filename);