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
qquickwindow_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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#ifndef QQUICKWINDOW_P_H
5#define QQUICKWINDOW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qquickdeliveryagent_p_p.h>
19#include <QtQuick/private/qquickevents_p_p.h>
20#include <QtQuick/private/qsgcontext_p.h>
21#include <QtQuick/private/qquickpaletteproviderprivatebase_p.h>
22#include <QtQuick/private/qquickrendertarget_p.h>
23#include <QtQuick/private/qquickgraphicsdevice_p.h>
24#include <QtQuick/private/qquickgraphicsconfiguration_p.h>
25#include <QtQuick/qquickitem.h>
26#include <QtQuick/qquickwindow.h>
27
28#include <QtCore/qthread.h>
29#include <QtCore/qmutex.h>
30#include <QtCore/qwaitcondition.h>
31#include <QtCore/qrunnable.h>
32#include <QtCore/qstack.h>
33
34#include <QtGui/private/qevent_p.h>
35#include <QtGui/private/qpointingdevice_p.h>
36#include <QtGui/private/qwindow_p.h>
37#include <QtGui/qevent.h>
38#include <QtGui/qstylehints.h>
39#include <QtGui/qguiapplication.h>
40
42
43class QOpenGLContext;
47class QPointingDevice;
51class QSGRenderLoop;
52class QTouchEvent;
53class QRhi;
54class QRhiSwapChain;
57class QRhiTexture;
58
59Q_DECLARE_LOGGING_CATEGORY(lcQuickWindow)
60
61//Make it easy to identify and customize the root item if needed
62class Q_QUICK_EXPORT QQuickRootItem : public QQuickItem
63{
67public:
69
70public Q_SLOTS:
73};
74
76{
77 enum class ResetFlag {
79 };
80 Q_DECLARE_FLAGS(ResetFlags, ResetFlag)
81 void reset(QRhi *rhi, ResetFlags flags = {});
82
83 struct {
85 bool owns = false;
87 } rt;
88 struct {
89 QRhiTexture *texture = nullptr;
92 } res;
99 struct {
101 bool owns = false;
102 } sw;
103};
104
105Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowRenderTarget::ResetFlags)
106
107class Q_QUICK_EXPORT QQuickWindowPrivate
108 : public QWindowPrivate
110{
111public:
112 Q_DECLARE_PUBLIC(QQuickWindow)
113
115 FullUpdateRequest = QEvent::User + 1,
116 TriggerContextCreationFailure = QEvent::User + 2
117 };
118
119 static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); }
120 static inline const QQuickWindowPrivate *get(const QQuickWindow *c) { return c->d_func(); }
121
123 ~QQuickWindowPrivate() override;
124
125 void setPalette(QQuickPalette *p) override;
126 void updateWindowPalette();
127 void updateChildrenPalettes(const QPalette &parentPalette) override;
128
129 void init(QQuickWindow *, QQuickRenderControl *control = nullptr);
130
132 QSet<QQuickItem *> parentlessItems;
133 QQmlListProperty<QObject> data();
134
135 // primary delivery agent for the whole scene, used by default for events that arrive in this window;
136 // but any subscene root can have a QQuickItemPrivate::ExtraData::subsceneDeliveryAgent
137 QQuickDeliveryAgent *deliveryAgent = nullptr;
139 { return deliveryAgent ? static_cast<QQuickDeliveryAgentPrivate *>(QQuickDeliveryAgentPrivate::get(deliveryAgent)) : nullptr; }
140
141#if QT_CONFIG(cursor)
142 QQuickItem *cursorItem = nullptr;
143 QQuickPointerHandler *cursorHandler = nullptr;
144 void updateCursor(const QPointF &scenePos, QQuickItem *rootItem = nullptr);
145 QPair<QQuickItem*, QQuickPointerHandler*> findCursorItemAndHandler(QQuickItem *item, const QPointF &scenePos) const;
146#endif
147
148 void clearFocusObject() override;
149 void setFocusToTarget(FocusTarget, Qt::FocusReason) override;
150
151 void dirtyItem(QQuickItem *);
152 void cleanup(QSGNode *);
153
154 void ensureCustomRenderTarget();
155 void setCustomCommandBuffer(QRhiCommandBuffer *cb);
156
157 void polishItems();
158 void forcePolish();
159 void invalidateFontData(QQuickItem *item);
160 void syncSceneGraph();
161 void renderSceneGraph();
162
163 bool isRenderable() const;
164
165 bool emitError(QQuickWindow::SceneGraphError error, const QString &msg);
166
168 NativeTextureIsExternalOES = 0x01
169 };
170 Q_DECLARE_FLAGS(TextureFromNativeTextureFlags, TextureFromNativeTextureFlag)
171
172 QSGTexture *createTextureFromNativeTexture(quint64 nativeObjectHandle,
173 int nativeLayoutOrState,
174 uint nativeFormat,
175 const QSize &size,
176 QQuickWindow::CreateTextureOptions options,
177 TextureFromNativeTextureFlags flags = {}) const;
179 int nativeLayoutOrState,
180 const QSize &size,
181 QQuickWindow::CreateTextureOptions options,
182 TextureFromNativeTextureFlags flags = {}) const {
183 return createTextureFromNativeTexture(nativeObjectHandle, nativeLayoutOrState, 0, size, options, flags);
184 }
185
187
189 QList<QSGNode *> cleanupNodeList;
190
191 QVector<QQuickItem *> itemsToPolish;
192
195
196 void updateDirtyNodes();
197 void cleanupNodes();
198 void cleanupNodesOnShutdown();
201 void updateDirtyNode(QQuickItem *);
202
203 void fireFrameSwapped() { Q_EMIT q_func()->frameSwapped(); }
204 void fireAboutToStop() { Q_EMIT q_func()->sceneGraphAboutToStop(); }
205
206 void updateChildWindowStackingOrder(QQuickItem *item = nullptr);
207
208 int multiViewCount();
209 QRhiRenderTarget *activeCustomRhiRenderTarget();
210
213 QByteArray visualizationMode; // Default renderer supports "clip", "overdraw", "changes", "batches" and blank.
214
217 QScopedPointer<QQuickAnimatorController> animationController;
218
220
224
225 // Storage for setRenderTarget(QQuickRenderTarget).
226 // Gets baked into redirect.renderTarget by ensureCustomRenderTarget() when rendering the next frame.
228
229 struct Redirect {
230 QRhiCommandBuffer *commandBuffer = nullptr;
232 bool renderTargetDirty = false;
233 } redirect;
234
236
238
240
242 static QQuickWindow::TextRenderType textRenderType;
243
244 // vvv currently in use in Controls 2; TODO remove
245 static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold = -1)
246 { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, *tp, startDragThreshold); }
247 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1)
248 { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, event, startDragThreshold); }
250 { deliveryAgentPrivate()->clearFocusInScope(scope, item, reason); }
251 // ^^^ currently in use in Controls 2; TODO remove
252
253 // data property
254 static void data_append(QQmlListProperty<QObject> *, QObject *);
255 static qsizetype data_count(QQmlListProperty<QObject> *);
256 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
257 static void data_clear(QQmlListProperty<QObject> *);
258 static void data_replace(QQmlListProperty<QObject> *, qsizetype, QObject *);
259 static void data_removeLast(QQmlListProperty<QObject> *);
260
261 static void rhiCreationFailureMessage(const QString &backendName,
262 QString *translatedMessage,
263 QString *untranslatedMessage);
264
265 static void emitBeforeRenderPassRecording(void *ud);
266 static void emitAfterRenderPassRecording(void *ud);
267
269 QList<QRunnable *> beforeSynchronizingJobs;
270 QList<QRunnable *> afterSynchronizingJobs;
271 QList<QRunnable *> beforeRenderingJobs;
272 QList<QRunnable *> afterRenderingJobs;
273 QList<QRunnable *> afterSwapJobs;
274
275 void runAndClearJobs(QList<QRunnable *> *jobs);
276 QOpenGLContext *openglContext();
277
278 QQuickWindow::GraphicsStateInfo rhiStateInfo;
279 QRhi *rhi = nullptr;
280 QRhiSwapChain *swapchain = nullptr;
281 QRhiRenderBuffer *depthStencilForSwapchain = nullptr;
282 QRhiRenderPassDescriptor *rpDescForSwapchain = nullptr;
287 bool pendingFontUpdate = false;
288 bool windowEventDispatch = false;
289 QPointer<QQuickPalette> windowPaletteRef;
290
291private:
292 static void cleanupNodesOnShutdown(QQuickItem *);
293};
294
296{
297public:
299 void run() override { delete object; }
301 static void schedule(QQuickWindow *window, QObject *object) {
303 Q_ASSERT(object);
304 window->scheduleRenderJob(new QQuickWindowQObjectCleanupJob(object), QQuickWindow::AfterSynchronizingStage);
305 }
306};
307
308Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowPrivate::TextureFromNativeTextureFlags)
309
311
312#endif // QQUICKWINDOW_P_H
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore Represents a handle to a signal-slot (or signal-functor) connection.
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qmutex.h:281
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
\inmodule QtGui
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold=-1)
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QQuickGraphicsDevice class provides an opaque container for native graphics objects representing ...
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
void setHeight(qreal)
void setWidth(qreal)
Contains color groups for each QML item state. \inmodule QtQuick.
The QQuickRenderControl class provides a mechanism for rendering the Qt Quick scenegraph onto an offs...
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a ...
void setHeight(int h)
void setWidth(int w)
QByteArray visualizationMode
QQuickWindow::GraphicsStateInfo rhiStateInfo
QList< QRunnable * > afterSwapJobs
QQuickItem::UpdatePaintNodeData updatePaintNodeData
void updateEffectiveOpacityRoot(QQuickItem *, qreal)
QQuickGraphicsConfiguration graphicsConfig
QSGTexture * createTextureFromNativeTexture(quint64 nativeObjectHandle, int nativeLayoutOrState, const QSize &size, QQuickWindow::CreateTextureOptions options, TextureFromNativeTextureFlags flags={}) const
QQuickRootItem * contentItem
QList< QRunnable * > beforeRenderingJobs
QMetaObject::Connection physicalDpiChangedConnection
static QQuickWindowPrivate * get(QQuickWindow *c)
static QQuickWindow::TextRenderType textRenderType
QSGRenderContext * context
QSGRenderer * renderer
QQuickRenderControl * renderControl
static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold=-1)
QList< QRunnable * > beforeSynchronizingJobs
QVector< QQuickItem * > itemsToPolish
static const QQuickWindowPrivate * get(const QQuickWindow *c)
QQuickItem * dirtyItemList
static bool defaultAlphaBuffer
QQuickRenderTarget customRenderTarget
bool updateEffectiveOpacity(QQuickItem *)
QPointer< QQuickPalette > windowPaletteRef
QQuickDeliveryAgentPrivate * deliveryAgentPrivate() const
QSet< QQuickItem * > parentlessItems
qreal lastReportedItemDevicePixelRatio
QScopedPointer< QQuickAnimatorController > animationController
QQuickGraphicsDevice customDeviceObjects
void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason)
QSGRenderLoop * windowManager
QQuickWindowIncubationController * incubationController
QList< QSGNode * > cleanupNodeList
QList< QRunnable * > afterRenderingJobs
static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold=-1)
QList< QRunnable * > afterSynchronizingJobs
void run() override
Implement this pure virtual function in your subclass.
static void schedule(QQuickWindow *window, QObject *object)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtGui
Definition qrhi.h:1652
\inmodule QtGui
Definition qrhi.h:1095
\inmodule QtGui
Definition qrhi.h:1143
\inmodule QtGui
Definition qrhi.h:1159
\inmodule QtGui
Definition qrhi.h:1550
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1805
\inmodule QtCore
Definition qrunnable.h:18
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The renderer class is the abstract baseclass used for rendering the QML scene graph.
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
Combined button and popup list for selecting options.
FocusReason
DBusConnection const char DBusError * error
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
static QString backendName
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint object
[3]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLbitfield flags
GLenum GLuint texture
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLboolean reset
const GLubyte * c
GLfloat GLfloat p
[1]
#define QML_ANONYMOUS
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
const QQuickItem * rootItem(const I &item)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
unsigned long long quint64
Definition qtypes.h:61
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickWindowRenderTarget rt
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * renderBuffer
struct QQuickWindowRenderTarget::@697 res
struct QQuickWindowRenderTarget::@696 rt
struct QQuickWindowRenderTarget::@698 sw
struct QQuickWindowRenderTarget::ImplicitBuffers implicitBuffers
QRhiRenderTarget * renderTarget