4#ifndef QQUICKPROFILER_P_H
5#define QQUICKPROFILER_P_H
18#include <QtCore/private/qabstractanimation_p.h>
19#include <QtQuick/private/qtquickglobal_p.h>
21#if QT_CONFIG(qml_debug)
22#include <QtQml/private/qqmlprofilerdefinitions_p.h>
25#include <QtCore/qurl.h>
26#include <QtCore/qsize.h>
27#include <QtCore/qmutex.h>
28#include <QtCore/qthreadstorage.h>
32#if !QT_CONFIG(qml_debug)
34#define Q_QUICK_PROFILE_IF_ENABLED(feature, Code)
42#define Q_QUICK_PROFILE_IF_ENABLED(feature, Code)\
43 if (QQuickProfiler::featuresEnabled & (1 << feature)) {\
58 QQuickProfilerData() {}
60 QQuickProfilerData(
qint64 time,
int messageType,
int detailType,
const QUrl &
url,
int x = 0,
61 int y = 0,
int framerate = 0,
int count = 0) :
62 time(
time), messageType(messageType), detailType(detailType), detailUrl(
url),
x(
x),
y(
y),
65 QQuickProfilerData(
qint64 time,
int messageType,
int detailType,
int framerateOrInputType = 0,
66 int countOrInputA = 0,
int threadIdOrInputB = 0) :
67 time(
time), messageType(messageType), detailType(detailType),
68 framerate(framerateOrInputType),
count(countOrInputA), threadId(threadIdOrInputB) {}
74 time(
time), messageType(messageType), detailType(detailType), subtime_1(
d1), subtime_2(
d2),
75 subtime_3(d3), subtime_4(d4), subtime_5(d5) {}
117 static const uint s_numSceneGraphTimings = 5;
125 TimingData<NumGUIThreadFrameTypes> guiThreadTimings;
128 template<SceneGraphFrameType type>
142 enum AnimationThread {
147 enum SceneGraphContextStage {
148 SceneGraphContextStart,
149 SceneGraphContextMaterialCompile
152 enum SceneGraphRendererStage {
153 SceneGraphRendererStart,
154 SceneGraphRendererPreprocess,
155 SceneGraphRendererUpdate,
156 SceneGraphRendererBinding,
157 SceneGraphRendererRender
160 enum SceneGraphAdaptationLayerStage {
161 SceneGraphAdaptationLayerStart,
162 SceneGraphAdaptationLayerGlyphRender,
163 SceneGraphAdaptationLayerGlyphStore
166 enum SceneGraphRenderLoopStage {
167 SceneGraphRenderLoopStart,
168 SceneGraphRenderLoopSync,
169 SceneGraphRenderLoopRender,
170 SceneGraphRenderLoopSwap
173 enum SceneGraphPolishStage {
174 SceneGraphPolishStart,
175 SceneGraphPolishPolish
178 enum SceneGraphPolishAndSyncStage {
179 SceneGraphPolishAndSyncStart,
180 SceneGraphPolishAndSyncPolish,
181 SceneGraphPolishAndSyncWait,
182 SceneGraphPolishAndSyncSync,
183 SceneGraphPolishAndSyncAnimations
186 enum SceneGraphTexturePrepareStage {
187 SceneGraphTexturePrepareStart,
188 SceneGraphTexturePrepareBind,
189 SceneGraphTexturePrepareConvert,
190 SceneGraphTexturePrepareSwizzle,
191 SceneGraphTexturePrepareUpload,
192 SceneGraphTexturePrepareMipmap
195 enum SceneGraphTextureDeletionStage {
196 SceneGraphTextureDeletionStart,
197 SceneGraphTextureDeletionDelete
200 template<EventType DetailType, InputEventType InputType>
201 static void inputEvent(
int x,
int y = 0)
203 s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 <<
Event,
204 1 << DetailType, InputType,
x,
y));
207 static void animationFrame(
qint64 delta, AnimationThread threadId)
211 if (animCount > 0 && delta > 0) {
212 s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(), 1 <<
Event,
218 template<SceneGraphFrameType FrameType1, SceneGraphFrameType FrameType2>
219 static void startSceneGraphFrame()
221 startSceneGraphFrame<FrameType1>();
222 s_instance->m_sceneGraphData.timings<FrameType2>()[0] =
223 s_instance->m_sceneGraphData.timings<FrameType1>()[0];
226 template<SceneGraphFrameType FrameType>
227 static void startSceneGraphFrame()
229 s_instance->m_sceneGraphData.timings<
FrameType>()[0] = s_instance->timestamp();
232 template<SceneGraphFrameType FrameType>
235 s_instance->m_sceneGraphData.timings<
FrameType>()[
position] = s_instance->timestamp();
238 template<SceneGraphFrameType FrameType, u
int Skip>
243 for (
uint i = 0;
i < Skip; ++
i)
247 template<SceneGraphFrameType FrameType,
bool Record>
252 timings[
position] = s_instance->timestamp();
253 s_instance->processMessage(QQuickProfilerData(
255 position > 0 ? timings[1] - timings[0] : payload,
256 position > 1 ? timings[2] - timings[1] : payload,
257 position > 2 ? timings[3] - timings[2] : payload,
258 position > 3 ? timings[4] - timings[3] : payload,
259 position > 4 ? timings[5] - timings[4] : payload));
262 template<SceneGraphFrameType FrameType,
bool Record, SceneGraphFrameType SwitchTo>
265 reportSceneGraphFrame<FrameType, Record>(
position, payload);
266 s_instance->m_sceneGraphData.timings<SwitchTo>()[0] =
267 s_instance->m_sceneGraphData.timings<FrameType>()[
position];
270 template<PixmapEventType PixmapState>
271 static void pixmapStateChanged(
const QUrl &
url)
273 s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(),
279 s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(),
285 template<PixmapEventType CountType>
286 static void pixmapCountChanged(
const QUrl &
url,
int count)
288 s_instance->processMessage(QQuickProfilerData(s_instance->timestamp(),
292 static void registerAnimationCallback();
294 qint64 timestamp() {
return m_timer.nsecsElapsed(); }
296 static quint64 featuresEnabled;
312 QQuickProfilerSceneGraphData m_sceneGraphData;
316 void processMessage(
const QQuickProfilerData &
message)
322 void startProfilingImpl(
quint64 features);
323 void stopProfilingImpl();
324 void reportDataImpl();
330#define Q_QUICK_PROFILE(feature, Method)\
331 Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method)
334#define Q_QUICK_SG_PROFILE_START(Type)\
335 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
336 (QQuickProfiler::startSceneGraphFrame<Type>()))
339#define Q_QUICK_SG_PROFILE_RECORD(Type, position)\
340 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
341 (QQuickProfiler::recordSceneGraphTimestamp<Type>(position)))
345#define Q_QUICK_SG_PROFILE_SKIP(Type, position, Skip)\
346 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
347 (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>(position)))
350#define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\
351 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
352 (QQuickProfiler::startSceneGraphFrame<Type1, Type2>()))
356#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2, position)\
357 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
358 (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>(\
362#define Q_QUICK_SG_PROFILE_REPORT(Type, position)\
363 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
364 (QQuickProfiler::reportSceneGraphFrame<Type, false>(position)))
368#define Q_QUICK_SG_PROFILE_END(Type, position)\
369 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
370 (QQuickProfiler::reportSceneGraphFrame<Type, true>(position)))
375#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, position, Payload)\
376 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
377 (QQuickProfiler::reportSceneGraphFrame<Type, true>(position,\
380#define Q_QUICK_INPUT_PROFILE(Type, DetailType, A, B)\
381 Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileInputEvents,\
382 (QQuickProfiler::inputEvent<Type, DetailType>(A, B)))
T & localData()
Returns a reference to the data that was set by the calling thread.
int runningAnimationCount()
static QUnifiedTimer * instance()
Combined button and popup list for selecting options.
GLenum GLsizei GLsizei GLint * values
[15]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
@ NumRenderThreadFrameTypes
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_AUTOTEST_EXPORT
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
QUrl url("example.com")
[constructor-url-reference]
@ NumRenderThreadFrameTypes
static void registerAnimationCallback()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent