Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsgdefaultrendercontext_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 QSGDEFAULTRENDERCONTEXT_H
5#define QSGDEFAULTRENDERCONTEXT_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/qsgcontext_p.h>
19#include <rhi/qshader.h>
20
22
23class QRhi;
27class QRhiTexture;
29class QSurface;
30
32 class Manager;
33}
34
35class Q_QUICK_PRIVATE_EXPORT QSGDefaultRenderContext : public QSGRenderContext
36{
38public:
40
41 QRhi *rhi() const override { return m_rhi; }
42 bool isValid() const override { return m_rhi != nullptr; }
43
44 static const int INIT_PARAMS_MAGIC = 0x50E;
46 int sType = INIT_PARAMS_MAGIC; // help discovering broken code passing something else as 'context'
47 QRhi *rhi = nullptr;
48 int sampleCount = 1; // 1, 4, 8, ...
49 // only used as a hint f.ex. in the texture atlas init
51 // The first window that will be used with this rc, if available.
52 // Only a hint, to help picking better values for atlases.
53 QSurface *maybeSurface = nullptr;
54 };
55
57 void invalidate() override;
58
59 void prepareSync(qreal devicePixelRatio,
61 const QQuickGraphicsConfiguration &config) override;
62
63 void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget,
64 RenderPassCallback mainPassRecordingStart,
65 RenderPassCallback mainPassRecordingEnd,
66 void *callbackUserData) override;
67 void renderNextFrame(QSGRenderer *renderer) override;
68 void endNextFrame(QSGRenderer *renderer) override;
69
70 void preprocess() override;
71 void invalidateGlyphCaches() override;
72 QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality) override;
73
74 QSGTexture *createTexture(const QImage &image, uint flags) const override;
77
78 virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant);
79
80 int maxTextureSize() const override { return m_maxTextureSize; }
81 bool useDepthBufferFor2D() const { return m_useDepthBufferFor2D; }
82 int msaaSampleCount() const { return m_initParams.sampleCount; }
83
85 // may be null if not in an active frame, but returning null is valid then
86 return m_currentFrameCommandBuffer;
87 }
89 // may be null if not in an active frame, but returning null is valid then
90 return m_currentFrameRenderPass;
91 }
92
94 {
95 // Valid starting from QQuickWindow::syncSceneGraph(). This takes the
96 // redirections, e.g. QQuickWindow::setRenderTarget(), into account.
97 // This calculation logic matches what the renderer does, so this is
98 // the same value that gets exposed in RenderState::devicePixelRatio()
99 // to material shaders. This getter is useful to perform dpr-related
100 // operations in the sync phase (in updatePaintNode()).
101 return m_currentDevicePixelRatio;
102 }
103
104 QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates();
105 QRhiResourceUpdateBatch *glyphCacheResourceUpdates();
106 void deferredReleaseGlyphCacheTexture(QRhiTexture *texture);
107 void resetGlyphCacheResources();
108
109protected:
110 static QString fontKey(const QRawFont &font, int renderTypeQuality);
111
122};
123
125
126#endif // QSGDEFAULTRENDERCONTEXT_H
\inmodule QtGui
Definition qimage.h:37
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
\inmodule QtGui
Definition qrhi.h:1614
\inmodule QtGui
Definition qrhi.h:1119
\inmodule QtGui
Definition qrhi.h:1694
\inmodule QtGui
Definition qrhi.h:883
\inmodule QtGui
Definition qrhi.h:1767
The QSGContext holds the scene graph entry points for one QML engine.
int maxTextureSize() const override
QRhiResourceUpdateBatch * m_glyphCacheResourceUpdates
QSet< QRhiTexture * > m_pendingGlyphCacheTextures
QRhiRenderPassDescriptor * m_currentFrameRenderPass
QRhiRenderPassDescriptor * currentFrameRenderPass() const
QSGRhiAtlasTexture::Manager * m_rhiAtlasManager
QRhiCommandBuffer * currentFrameCommandBuffer() const
QRhiCommandBuffer * m_currentFrameCommandBuffer
The QSGMaterialShader class represents a graphics API independent shader program.
virtual void endNextFrame(QSGRenderer *renderer)
virtual QSGTexture * createTexture(const QImage &image, uint flags=CreateTexture_Alpha) const =0
virtual void beginNextFrame(QSGRenderer *renderer, const QSGRenderTarget &renderTarget, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, void *callbackUserData)
virtual void invalidateGlyphCaches()
virtual QSGDistanceFieldGlyphCache * distanceFieldGlyphCache(const QRawFont &font, int renderTypeQuality)
Factory function for scene graph backends of the distance-field glyph cache.
virtual void invalidate()
void(*)(void *) RenderPassCallback
virtual QSGRenderer * createRenderer(QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D)=0
virtual void renderNextFrame(QSGRenderer *renderer)=0
virtual void preprocess()
Do necessary preprocessing before the frame.
virtual void prepareSync(qreal devicePixelRatio, QRhiCommandBuffer *cb, const QQuickGraphicsConfiguration &config)
virtual QSGTexture * compressedTextureForFactory(const QSGCompressedTextureFactory *) const
Return the texture corresponding to a texture factory.
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
Variant
Describes what kind of shader code an entry contains.
Definition qshader.h:103
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qsurface.h:21
Combined button and popup list for selecting options.
Definition image.cpp:4
static void * context
static bool initialize()
Definition qctf.cpp:67
EGLConfig config
GLbitfield flags
GLenum GLuint texture
void ** params
GLuint shader
Definition qopenglext.h:665
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define Q_OBJECT
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QItemEditorFactory * factory
QSvgRenderer * renderer
[0]