Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dprofileradapter.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include <QCoreApplication>
7#include <private/qqmldebugconnector_p.h>
8#include <private/qversionedpacket_p.h>
9#include <private/qqmldebugserviceinterfaces_p.h>
10
12
13using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>;
14
17{
18 QQuick3DProfiler::initialize(this);
19 // We can always do DirectConnection here as all methods are protected by mutexes
21 QQuick3DProfiler::s_instance, &QQuick3DProfiler::startProfilingImpl, Qt::DirectConnection);
23 QQuick3DProfiler::s_instance, &QQuick3DProfiler::startProfilingImpl, Qt::DirectConnection);
25 QQuick3DProfiler::s_instance, &QQuick3DProfiler::setTimer, Qt::DirectConnection);
27 QQuick3DProfiler::s_instance, &QQuick3DProfiler::stopProfilingImpl, Qt::DirectConnection);
29 QQuick3DProfiler::s_instance, &QQuick3DProfiler::stopProfilingImpl, Qt::DirectConnection);
31 QQuick3DProfiler::s_instance, &QQuick3DProfiler::reportDataImpl, Qt::DirectConnection);
32 connect(QQuick3DProfiler::s_instance, &QQuick3DProfiler::dataReady,
34}
35
37{
38 if (service)
39 service->removeGlobalProfiler(this);
40}
41
42
43// convert to QByteArrays that can be sent to the debug client
44static void QQuick3DProfilerDataToByteArrays(const QQuick3DProfilerData &data,
45 QList<QByteArray> &messages,
46 const QHash<int, QByteArray> &eventData)
47{
49
50 // packet header
51 ds << data.time << data.messageType << data.detailType;
52 // packet data
53 switch (data.messageType) {
54 case QQuick3DProfiler::Event:
55 break;
56 case QQuick3DProfiler::Quick3DFrame:
57 if (data.detailType == QQuick3DProfiler::Quick3DEventData) {
58 ds << eventData[data.subdata1];
59 } else {
60 ds << data.subdata1 << data.subdata2;
61 if (data.ids[0] || data.ids[1])
62 ds << data.ids[0] << data.ids[1];
63 }
64 break;
65 default:
66 Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type.");
67 break;
68 }
69
70 messages.append(ds.squeezedData());
71 ds.clear();
72}
73
74qint64 QQuick3DProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
75{
76 while (next < m_data.size()) {
77 if (m_data[next].time <= until && messages.size() <= s_numMessagesPerBatch)
78 QQuick3DProfilerDataToByteArrays(m_data[next++], messages, m_eventData);
79 else
80 return m_data[next].time;
81 }
82 m_data.clear();
83 next = 0;
84 return -1;
85}
86
87void QQuick3DProfilerAdapter::receiveData(const QVector<QQuick3DProfilerData> &new_data, const QHash<int, QByteArray> &eventData)
88{
89 if (m_data.isEmpty())
90 m_data = new_data;
91 else
92 m_data.append(new_data);
93 m_eventData = eventData;
94 service->dataReady(this);
95}
96
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QByteArray squeezedData() const
Returns a copy of the raw packet data, with extra reserved space removed.
Definition qpacket.cpp:86
void clear()
Clears the packet, discarding any data.
Definition qpacket.cpp:96
void profilingEnabled(quint64 features)
void profilingEnabledWhileWaiting(quint64 features)
void referenceTimeKnown(const QElapsedTimer &timer)
void receiveData(const QVector< QQuick3DProfilerData > &new_data, const QHash< int, QByteArray > &eventData)
QQuick3DProfilerAdapter(QObject *parent=0)
qint64 sendMessages(qint64 until, QList< QByteArray > &messages) override
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
@ DirectConnection
#define Q_FUNC_INFO
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static void QQuick3DProfilerDataToByteArrays(const QQuick3DProfilerData &data, QList< QByteArray > &messages, const QHash< int, QByteArray > &eventData)
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
long long qint64
Definition qtypes.h:60