Qt 6.x
The Qt SDK
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
59//Make it easy to identify and customize the root item if needed
60class Q_QUICK_PRIVATE_EXPORT QQuickRootItem : public QQuickItem
61{
65public:
67
68public Q_SLOTS:
71};
72
74{
75public:
76 void reset(QRhi *rhi);
79 QRhiTexture *texture = nullptr;
83 bool owns = false;
84};
85
86class Q_QUICK_PRIVATE_EXPORT QQuickWindowPrivate
87 : public QWindowPrivate
88 , public QQuickPaletteProviderPrivateBase<QQuickWindow, QQuickWindowPrivate>
89{
90public:
91 Q_DECLARE_PUBLIC(QQuickWindow)
92
94 FullUpdateRequest = QEvent::User + 1,
95 TriggerContextCreationFailure = QEvent::User + 2
96 };
97
98 static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); }
99 static inline const QQuickWindowPrivate *get(const QQuickWindow *c) { return c->d_func(); }
100
102 ~QQuickWindowPrivate() override;
103
104 void updateChildrenPalettes(const QPalette &parentPalette) override;
105
106 void init(QQuickWindow *, QQuickRenderControl *control = nullptr);
107
111
112 // primary delivery agent for the whole scene, used by default for events that arrive in this window;
113 // but any subscene root can have a QQuickItemPrivate::ExtraData::subsceneDeliveryAgent
114 QQuickDeliveryAgent *deliveryAgent = nullptr;
116 { return deliveryAgent ? static_cast<QQuickDeliveryAgentPrivate *>(QQuickDeliveryAgentPrivate::get(deliveryAgent)) : nullptr; }
117
118#if QT_CONFIG(cursor)
119 QQuickItem *cursorItem = nullptr;
120 QQuickPointerHandler *cursorHandler = nullptr;
121 void updateCursor(const QPointF &scenePos, QQuickItem *rootItem = nullptr);
122 QPair<QQuickItem*, QQuickPointerHandler*> findCursorItemAndHandler(QQuickItem *item, const QPointF &scenePos) const;
123#endif
124
125 void clearFocusObject() override;
126
127 void dirtyItem(QQuickItem *);
128 void cleanup(QSGNode *);
129
130 void ensureCustomRenderTarget();
131 void setCustomCommandBuffer(QRhiCommandBuffer *cb);
132
133 void polishItems();
134 void forcePolish();
135 void invalidateFontData(QQuickItem *item);
136 void syncSceneGraph();
137 void renderSceneGraph();
138
139 bool isRenderable() const;
140
141 bool emitError(QQuickWindow::SceneGraphError error, const QString &msg);
142
144 NativeTextureIsExternalOES = 0x01
145 };
146 Q_DECLARE_FLAGS(TextureFromNativeTextureFlags, TextureFromNativeTextureFlag)
147
148 QSGTexture *createTextureFromNativeTexture(quint64 nativeObjectHandle,
149 int nativeLayoutOrState,
150 uint nativeFormat,
151 const QSize &size,
152 QQuickWindow::CreateTextureOptions options,
153 TextureFromNativeTextureFlags flags = {}) const;
155 int nativeLayoutOrState,
156 const QSize &size,
157 QQuickWindow::CreateTextureOptions options,
158 TextureFromNativeTextureFlags flags = {}) const {
159 return createTextureFromNativeTexture(nativeObjectHandle, nativeLayoutOrState, 0, size, options, flags);
160 }
161
163
166
168
171
172 void updateDirtyNodes();
173 void cleanupNodes();
174 void cleanupNodesOnShutdown();
177 void updateDirtyNode(QQuickItem *);
178
179 void fireFrameSwapped() { Q_EMIT q_func()->frameSwapped(); }
180 void fireAboutToStop() { Q_EMIT q_func()->sceneGraphAboutToStop(); }
181
182 void clearGrabbers(QPointerEvent *event);
183
186 QByteArray visualizationMode; // Default renderer supports "clip", "overdraw", "changes", "batches" and blank.
187
191
193
198
199 // Storage for setRenderTarget(QQuickRenderTarget).
200 // Gets baked into redirect.renderTarget by ensureCustomRenderTarget() when rendering the next frame.
202
203 struct Redirect {
204 QRhiCommandBuffer *commandBuffer = nullptr;
206 bool renderTargetDirty = false;
207 } redirect;
208
210
212
214
216 static QQuickWindow::TextRenderType textRenderType;
217
218 // vvv currently in use in Controls 2; TODO remove
219 static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold = -1)
220 { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, *tp, startDragThreshold); }
221 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1)
222 { return QQuickDeliveryAgentPrivate::dragOverThreshold(d, axis, event, startDragThreshold); }
224 { deliveryAgentPrivate()->clearFocusInScope(scope, item, reason); }
225 // ^^^ currently in use in Controls 2; TODO remove
226
227 // data property
228 static void data_append(QQmlListProperty<QObject> *, QObject *);
229 static qsizetype data_count(QQmlListProperty<QObject> *);
230 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
231 static void data_clear(QQmlListProperty<QObject> *);
232 static void data_replace(QQmlListProperty<QObject> *, qsizetype, QObject *);
233 static void data_removeLast(QQmlListProperty<QObject> *);
234
235 static void rhiCreationFailureMessage(const QString &backendName,
236 QString *translatedMessage,
237 QString *untranslatedMessage);
238
239 static void emitBeforeRenderPassRecording(void *ud);
240 static void emitAfterRenderPassRecording(void *ud);
241
248
249 void runAndClearJobs(QList<QRunnable *> *jobs);
250 QOpenGLContext *openglContext();
251
252 QQuickWindow::GraphicsStateInfo rhiStateInfo;
253 QRhi *rhi = nullptr;
254 QRhiSwapChain *swapchain = nullptr;
255 QRhiRenderBuffer *depthStencilForSwapchain = nullptr;
256 QRhiRenderPassDescriptor *rpDescForSwapchain = nullptr;
261 bool pendingFontUpdate = false;
262 bool windowEventDispatch = false;
263
264private:
265 static void cleanupNodesOnShutdown(QQuickItem *);
266};
267
269{
270public:
272 void run() override { delete object; }
274 static void schedule(QQuickWindow *window, QObject *object) {
276 Q_ASSERT(object);
277 window->scheduleRenderJob(new QQuickWindowQObjectCleanupJob(object), QQuickWindow::AfterSynchronizingStage);
278 }
279};
280
281Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickWindowPrivate::TextureFromNativeTextureFlags)
282
284
285#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
Definition qlist.h:74
\inmodule QtCore Represents a handle to a signal-slot (or signal-functor) connection.
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qmutex.h:285
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
\inmodule QtCore
Definition qobject.h:90
\inmodule QtGui
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qpoint.h:214
A base class for pointer events.
Definition qevent.h:73
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
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:64
void setHeight(qreal)
void setWidth(qreal)
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 *)
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)
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * renderBuffer
QRhiRenderBuffer * depthStencil
QRhiRenderTarget * renderTarget
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtGui
Definition qrhi.h:1614
\inmodule QtGui
Definition qrhi.h:1071
\inmodule QtGui
Definition qrhi.h:1119
\inmodule QtGui
Definition qrhi.h:1135
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:883
\inmodule QtGui
Definition qrhi.h:1767
\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 qset.h:18
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:916
Combined button and popup list for selecting options.
FocusReason
std::pair< T1, T2 > QPair
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
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint object
[3]
GLbitfield flags
GLenum GLuint texture
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLboolean reset
const GLubyte * c
#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:56
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickWindowRenderTarget rt