17QQuick3DProfilerAdapter::QQuick3DProfilerAdapter(QObject *parent) :
18 QQmlAbstractProfilerAdapter(parent), next(0)
20 QQuick3DProfiler::initialize(
this);
22 connect(
this, &QQmlAbstractProfilerAdapter::profilingEnabled,
23 QQuick3DProfiler::s_instance, &QQuick3DProfiler::startProfilingImpl, Qt::DirectConnection);
24 connect(
this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting,
25 QQuick3DProfiler::s_instance, &QQuick3DProfiler::startProfilingImpl, Qt::DirectConnection);
26 connect(
this, &QQmlAbstractProfilerAdapter::referenceTimeKnown,
27 QQuick3DProfiler::s_instance, &QQuick3DProfiler::setTimer, Qt::DirectConnection);
28 connect(
this, &QQmlAbstractProfilerAdapter::profilingDisabled,
29 QQuick3DProfiler::s_instance, &QQuick3DProfiler::stopProfilingImpl, Qt::DirectConnection);
30 connect(
this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting,
31 QQuick3DProfiler::s_instance, &QQuick3DProfiler::stopProfilingImpl, Qt::DirectConnection);
32 connect(
this, &QQmlAbstractProfilerAdapter::dataRequested,
33 QQuick3DProfiler::s_instance, &QQuick3DProfiler::reportDataImpl, Qt::DirectConnection);
34 connect(QQuick3DProfiler::s_instance, &QQuick3DProfiler::dataReady,
35 this, &QQuick3DProfilerAdapter::receiveData, Qt::DirectConnection);
47 QList<QByteArray> &messages,
48 const QHash<
int, QByteArray> &eventData)
53 ds << data.time << data.messageType << data.detailType;
55 switch (data.messageType) {
56 case QQuick3DProfiler::Event:
58 case QQuick3DProfiler::Quick3DFrame:
59 if (data.detailType == QQuick3DProfiler::Quick3DEventData) {
60 ds << eventData[data.subdata1];
62 ds << data.subdata1 << data.subdata2;
63 if (data.ids[0] || data.ids[1])
64 ds << data.ids[0] << data.ids[1];
68 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Invalid message type.");
72 messages.append(ds.squeezedData());
76qint64 QQuick3DProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
78 while (next < m_data.size()) {
79 if (m_data[next].time <= until && messages.size() <= s_numMessagesPerBatch)
80 QQuick3DProfilerDataToByteArrays(m_data[next++], messages, m_eventData);
82 return m_data[next].time;