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
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#include <private/qfontengine_p.h>
28
29#include <QtQuick/qsgnode.h>
30#include <QtQuick/qsgrendererinterface.h>
31#include <QtQuick/qsgtextnode.h>
32
33#include <QtCore/qpointer.h>
34
36
37class QSGContextPrivate;
41class QSGPainterNode;
42class QSGGlyphNode;
43class QSGRenderer;
45class QQuickWindow;
46class QSGTexture;
47class QSGMaterial;
48class QSGRenderLoop;
49class QSGLayer;
52class QSGContext;
58class QSGTextNode;
59class QSGImageNode;
61class QSGSpriteNode;
63class QSGRenderTarget;
64class QRhi;
69class QQuickItem;
71
72Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP)
73Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION)
74Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_TEXTURE)
75Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_GLYPH)
76Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERER)
77
79Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_RENDERLOOP)
80
81class Q_QUICK_EXPORT QSGContext : public QObject
82{
84
85public:
91
92 explicit QSGContext(QObject *parent = nullptr);
93 ~QSGContext() override;
94
95 virtual void renderContextInitialized(QSGRenderContext *renderContext);
96 virtual void renderContextInvalidated(QSGRenderContext *renderContext);
98
99 QSGInternalRectangleNode *createInternalRectangleNode(const QRectF &rect, const QColor &c);
102 virtual QSGInternalTextNode *createInternalTextNode(QSGRenderContext *renderContext);
104 virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) = 0;
105 virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0;
106 virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager();
107 virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext);
108#if QT_CONFIG(quick_sprite)
109 virtual QSGSpriteNode *createSpriteNode() = 0;
110#endif
111 virtual QAnimationDriver *createAnimationDriver(QObject *parent);
112 virtual float vsyncIntervalForAnimationDriver(QAnimationDriver *driver);
113 virtual bool isVSyncDependent(QAnimationDriver *driver);
114
115 virtual QSize minimumFBOSize() const;
117
118 virtual QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext);
119
120 virtual QSGTextNode *createTextNode(QSGRenderContext *renderContext);
124
125 static QSGContext *createDefaultContext();
126 static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image);
127 static QSGRenderLoop *createWindowManager();
128
129 static void setBackend(const QString &backend);
130 static QString backend();
131};
132
133class Q_QUICK_EXPORT QSGRenderContext : public QObject
134{
136public:
138 CreateTexture_Alpha = 0x1,
139 CreateTexture_Atlas = 0x2,
140 CreateTexture_Mipmap = 0x4
141 };
142
144 ~QSGRenderContext() override;
145
146 QSGContext *sceneGraphContext() const { return m_sg; }
147 virtual bool isValid() const { return true; }
148
149 struct InitParams { };
150 virtual void initialize(const InitParams *params);
151 virtual void invalidate();
152
153 using RenderPassCallback = void (*)(void *);
154
155 virtual void prepareSync(qreal devicePixelRatio,
158
159 virtual void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget,
160 RenderPassCallback mainPassRecordingStart,
161 RenderPassCallback mainPassRecordingEnd,
162 void *callbackUserData);
164 virtual void endNextFrame(QSGRenderer *renderer);
165
166 virtual void endSync();
167
168 virtual void preprocess();
169 virtual void invalidateGlyphCaches();
170 virtual QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality);
171 virtual QSGCurveGlyphAtlas *curveGlyphAtlas(const QRawFont &font);
173
174 virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const = 0;
176 virtual QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *) const;
177
178 virtual int maxTextureSize() const = 0;
179
180 void unregisterFontengineForCleanup(QFontEngine *engine);
181 void registerFontengineForCleanup(QFontEngine *engine);
182
183 virtual QRhi *rhi() const;
184
189
190public Q_SLOTS:
191 void textureFactoryDestroyed(QObject *o);
192
193protected:
204 friend bool operator==(const QSGRenderContext::FontKey &f1, const QSGRenderContext::FontKey &f2);
205 friend size_t qHash(const QSGRenderContext::FontKey &f, size_t seed);
206
207 // Hold m_sg with QPointer in the rare case it gets deleted before us.
208 QPointer<QSGContext> m_sg;
209
211 QHash<QObject *, QSGTexture *> m_textures;
212 QSet<QSGTexture *> m_texturesToDelete;
213 QHash<FontKey, QSGDistanceFieldGlyphCache *> m_glyphCaches;
214
215 // References to font engines that are currently in use by native rendering glyph nodes
216 // and which must be kept alive as long as they are used in the render thread.
217 QHash<QFontEngine *, int> m_fontEnginesToClean;
218};
219
221{
222 return f1.faceId == f2.faceId
223 && f1.style == f2.style
224 && f1.weight == f2.weight
225 && f1.renderTypeQuality == f2.renderTypeQuality
226 && f1.familyName == f2.familyName
227 && f1.styleName == f2.styleName;
228}
229
230inline size_t qHash(const QSGRenderContext::FontKey &f, size_t seed = 0)
231{
232 return qHashMulti(seed, f.faceId, f.renderTypeQuality, f.familyName, f.styleName, f.style, f.weight);
233}
234
235
237
238#endif // QSGCONTEXT_H
\inmodule QtCore
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
Style
This enum describes the different styles of glyphs that are used to display text.
Definition qfont.h:76
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
Definition qobject.h:103
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
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:484
\inmodule QtGui
Definition qrhi.h:1651
\inmodule QtGui
Definition qrhi.h:1142
\inmodule QtGui
Definition qrhi.h:1158
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
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 QSGRenderContext * createRenderContext()=0
virtual QSurfaceFormat defaultSurfaceFormat() const =0
virtual QSGLayer * createLayer(QSGRenderContext *renderContext)=0
virtual QSGNinePatchNode * createNinePatchNode()=0
virtual QSGImageNode * createImageNode()=0
virtual QSGGlyphNode * createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality)=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< 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()
QHash< FontKey, QSGDistanceFieldGlyphCache * > m_glyphCaches
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.
The QSGTextNode class is a class for drawing text layouts and text documents in the Qt Quick scene gr...
Definition qsgtextnode.h:14
RenderType
This enum type describes type of glyph node used for rendering the text.
Definition qsgtextnode.h:29
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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:94
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
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLfloat GLfloat f
GLbitfield flags
void ** params
const GLubyte * c
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
bool operator==(const QSGRenderContext::FontKey &f1, const QSGRenderContext::FontKey &f2)
size_t qHash(const QSGRenderContext::FontKey &f, size_t seed=0)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
static QSvgNode * createTextNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *handler)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QGraphicsItem * item
QItemEditorFactory * factory
aWidget window() -> setWindowTitle("New Window Title")
[2]
QJSEngine engine
[0]
QSvgRenderer * renderer
[0]
QFontEngine::FaceId faceId