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
qquickprofiler.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquickprofiler_p.h"
5
6#include <QtQml/private/qqmlabstractprofileradapter_p.h>
7
8#include <QtCore/qcoreapplication.h>
9#include <QtCore/qthread.h>
10
12
13// instance will be set, unset in constructor. Allows static methods to be inlined.
14QQuickProfiler *QQuickProfiler::s_instance = nullptr;
15quint64 QQuickProfiler::featuresEnabled = 0;
16
17void QQuickProfiler::initialize(QObject *parent)
18{
19 Q_ASSERT(s_instance == nullptr);
20 s_instance = new QQuickProfiler(parent);
21}
22
24{
25 Q_QUICK_PROFILE(QQuickProfiler::ProfileAnimations, animationFrame(delta,
27 QQuickProfiler::GuiThread : QQuickProfiler::RenderThread));
28}
29
31{
32 QUnifiedTimer::instance()->registerProfilerCallback(&animationTimerCallback);
33}
34
37public:
43};
44
45QQuickProfiler::QQuickProfiler(QObject *parent) : QObject(parent)
46{
47 // This is safe because at this point the m_instance isn't initialized, yet.
48 m_timer.start();
49 CallbackRegistrationHelper *helper = new CallbackRegistrationHelper; // will delete itself
51
52 // Queue the signal to have the animation timer registration run in the right thread;
53 QObject signalSource;
54 connect(&signalSource, &QObject::destroyed,
57}
58
59QQuickProfiler::~QQuickProfiler()
60{
61 QMutexLocker lock(&m_dataMutex);
62 featuresEnabled = 0;
63 s_instance = nullptr;
64}
65
66void QQuickProfiler::startProfilingImpl(quint64 features)
67{
68 QMutexLocker lock(&m_dataMutex);
69 featuresEnabled = features;
70}
71
72void QQuickProfiler::stopProfilingImpl()
73{
74 QMutexLocker lock(&m_dataMutex);
75 featuresEnabled = 0;
76 emit dataReady(m_data);
77 m_data.clear();
78}
79
80void QQuickProfiler::reportDataImpl()
81{
82 QMutexLocker lock(&m_dataMutex);
83 emit dataReady(m_data);
84 m_data.clear();
85}
86
87void QQuickProfiler::setTimer(const QElapsedTimer &t)
88{
89 QMutexLocker lock(&m_dataMutex);
90 m_timer = t;
91}
92
94
95#include "qquickprofiler.moc"
96#include "moc_qquickprofiler_p.cpp"
NSData * m_data
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore
\inmodule QtCore
Definition qmutex.h:313
\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
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
bool moveToThread(QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
Changes the thread affinity for this object and its children and returns true on success.
Definition qobject.cpp:1643
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
static QThread * currentThread()
Definition qthread.cpp:1039
static QUnifiedTimer * instance()
Combined button and popup list for selecting options.
@ QueuedConnection
GLdouble GLdouble t
Definition qopenglext.h:243
void animationTimerCallback(qint64 delta)
#define Q_QUICK_PROFILE(feature, Method)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_OBJECT
#define emit
unsigned long long quint64
Definition qtypes.h:61
long long qint64
Definition qtypes.h:60
QReadWriteLock lock
[0]
static void registerAnimationCallback()