Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgcontext_p.h
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#ifndef QSGCONTEXT_H
5#define QSGCONTEXT_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 <QtCore/QObject>
19#include <QtCore/qabstractanimation.h>
20#include <QtCore/QMutex>
21
22#include <QtGui/QImage>
23#include <QtGui/QSurfaceFormat>
24
25#include <private/qtquickglobal_p.h>
26#include <private/qrawfont_p.h>
27
28#include <QtQuick/qsgnode.h>
29#include <QtQuick/qsgrendererinterface.h>
30
32
33class QSGContextPrivate;
36class QSGPainterNode;
37class QSGGlyphNode;
38class QSGRenderer;
40class QQuickWindow;
41class QSGTexture;
42class QSGMaterial;
43class QSGRenderLoop;
44class QSGLayer;
47class QSGContext;
53class QSGImageNode;
55class QSGSpriteNode;
57class QSGRenderTarget;
58class QRhi;
63
64Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP)
65Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION)
66Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_TEXTURE)
67Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_GLYPH)
68Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERER)
69
71Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_RENDERLOOP)
72
73class Q_QUICK_PRIVATE_EXPORT QSGContext : public QObject
74{
76
77public:
81 MsaaAntialiasing
82 };
83
84 explicit QSGContext(QObject *parent = nullptr);
85 ~QSGContext() override;
86
87 virtual void renderContextInitialized(QSGRenderContext *renderContext);
88 virtual void renderContextInvalidated(QSGRenderContext *renderContext);
90
91 QSGInternalRectangleNode *createInternalRectangleNode(const QRectF &rect, const QColor &c);
95 virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode, int renderTypeQuality) = 0;
96 virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0;
97 virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager();
98 virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext);
99#if QT_CONFIG(quick_sprite)
100 virtual QSGSpriteNode *createSpriteNode() = 0;
101#endif
102 virtual QAnimationDriver *createAnimationDriver(QObject *parent);
103 virtual float vsyncIntervalForAnimationDriver(QAnimationDriver *driver);
104 virtual bool isVSyncDependent(QAnimationDriver *driver);
105
106 virtual QSize minimumFBOSize() const;
108
109 virtual QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext);
110
114
115 static QSGContext *createDefaultContext();
116 static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image);
117 static QSGRenderLoop *createWindowManager();
118
119 static void setBackend(const QString &backend);
120 static QString backend();
121};
122
123class Q_QUICK_PRIVATE_EXPORT QSGRenderContext : public QObject
124{
126public:
128 CreateTexture_Alpha = 0x1,
129 CreateTexture_Atlas = 0x2,
130 CreateTexture_Mipmap = 0x4
131 };
132
134 ~QSGRenderContext() override;
135
136 QSGContext *sceneGraphContext() const { return m_sg; }
137 virtual bool isValid() const { return true; }
138
139 struct InitParams { };
140 virtual void initialize(const InitParams *params);
141 virtual void invalidate();
142
143 using RenderPassCallback = void (*)(void *);
144
145 virtual void prepareSync(qreal devicePixelRatio,
148
149 virtual void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget,
150 RenderPassCallback mainPassRecordingStart,
151 RenderPassCallback mainPassRecordingEnd,
152 void *callbackUserData);
154 virtual void endNextFrame(QSGRenderer *renderer);
155
156 virtual void endSync();
157
158 virtual void preprocess();
159 virtual void invalidateGlyphCaches();
160 virtual QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality);
162
163 virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const = 0;
165 virtual QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *) const;
166
167 virtual int maxTextureSize() const = 0;
168
169 void unregisterFontengineForCleanup(QFontEngine *engine);
170 void registerFontengineForCleanup(QFontEngine *engine);
171
172 virtual QRhi *rhi() const;
173
178
179public Q_SLOTS:
180 void textureFactoryDestroyed(QObject *o);
181
182protected:
183 // Hold m_sg with QPointer in the rare case it gets deleted before us.
185
190
191 // References to font engines that are currently in use by native rendering glyph nodes
192 // and which must be kept alive as long as they are used in the render thread.
194};
195
197
198#endif // QSGCONTEXT_H
\inmodule QtCore
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qhash.h:818
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmutex.h:285
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.
The QQuickTextureFactory class provides an interface for loading custom textures from QML....
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtGui
Definition qrhi.h:1614
\inmodule QtGui
Definition qrhi.h:1119
\inmodule QtGui
Definition qrhi.h:1135
\inmodule QtGui
Definition qrhi.h:1767
The QSGContext holds the scene graph entry points for one QML engine.
virtual QSGPainterNode * createPainterNode(QQuickPaintedItem *item)=0
virtual QSGInternalRectangleNode * createInternalRectangleNode()=0
virtual QSGInternalImageNode * createInternalImageNode(QSGRenderContext *renderContext)=0
virtual QSGRectangleNode * createRectangleNode()=0
virtual QSGGlyphNode * createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode, int renderTypeQuality)=0
virtual QSGRenderContext * createRenderContext()=0
virtual QSurfaceFormat defaultSurfaceFormat() const =0
virtual QSGLayer * createLayer(QSGRenderContext *renderContext)=0
virtual QSGNinePatchNode * createNinePatchNode()=0
virtual QSGImageNode * createImageNode()=0
@ UndecidedAntialiasing
The QSGImageNode class is provided for convenience to easily draw textured content using the QML scen...
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
\inmodule QtQuick
The QSGRectangleNode class is a convenience class for drawing solid filled rectangles using scenegrap...
QHash< QString, QSGDistanceFieldGlyphCache * > m_glyphCaches
QHash< QObject *, QSGTexture * > m_textures
virtual int maxTextureSize() const =0
virtual QSGTexture * createTexture(const QImage &image, uint flags=CreateTexture_Alpha) const =0
QHash< QFontEngine *, int > m_fontEnginesToClean
QPointer< QSGContext > m_sg
void(*)(void *) RenderPassCallback
virtual QSGRenderer * createRenderer(QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D)=0
QSGContext * sceneGraphContext() const
virtual void renderNextFrame(QSGRenderer *renderer)=0
void releaseCachedResourcesRequested()
QSet< QSGTexture * > m_texturesToDelete
virtual bool isValid() const
An interface providing access to some of the graphics API specific internals of the scenegraph.
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
The renderer class is the abstract baseclass used for rendering the QML scene graph.
\inmodule QtQuick
Definition qsgtexture.h:20
Definition qset.h:18
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
static void * context
static bool initialize()
Definition qctf.cpp:67
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLConfig config
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLbitfield flags
void ** params
const GLubyte * c
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QGraphicsItem * item
QItemEditorFactory * factory
aWidget window() -> setWindowTitle("New Window Title")
[2]
QJSEngine engine
[0]
QSvgRenderer * renderer
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent