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
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_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 QSGCurveGlyphAtlas *curveGlyphAtlas(const QRawFont &font) override;
74
75 QSGTexture *createTexture(const QImage &image, uint flags) const override;
77 QSGTexture *compressedTextureForFactory(const QSGCompressedTextureFactory *factory) const override;
78
79 virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant);
80
81 int maxTextureSize() const override { return m_maxTextureSize; }
82 bool useDepthBufferFor2D() const { return m_useDepthBufferFor2D; }
83 int msaaSampleCount() const { return m_initParams.sampleCount; }
84
86 // may be null if not in an active frame, but returning null is valid then
87 return m_currentFrameCommandBuffer;
88 }
90 // may be null if not in an active frame, but returning null is valid then
91 return m_currentFrameRenderPass;
92 }
93
95 {
96 // Valid starting from QQuickWindow::syncSceneGraph(). This takes the
97 // redirections, e.g. QQuickWindow::setRenderTarget(), into account.
98 // This calculation logic matches what the renderer does, so this is
99 // the same value that gets exposed in RenderState::devicePixelRatio()
100 // to material shaders. This getter is useful to perform dpr-related
101 // operations in the sync phase (in updatePaintNode()).
102 return m_currentDevicePixelRatio;
103 }
104
105 QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates();
106 QRhiResourceUpdateBatch *glyphCacheResourceUpdates();
107 void deferredReleaseGlyphCacheTexture(QRhiTexture *texture);
108 void resetGlyphCacheResources();
109
110protected:
120 QSet<QRhiTexture *> m_pendingGlyphCacheTextures;
121 QHash<FontKey, QSGCurveGlyphAtlas *> m_curveGlyphAtlases;
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:1651
\inmodule QtGui
Definition qrhi.h:1142
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
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
QHash< FontKey, QSGCurveGlyphAtlas * > m_curveGlyphAtlases
QRhiCommandBuffer * currentFrameCommandBuffer() const
QRhiCommandBuffer * m_currentFrameCommandBuffer
The QSGMaterialShader class represents a graphics API independent shader program.
void(*)(void *) RenderPassCallback
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
Variant
Describes what kind of shader code an entry contains.
Definition qshader.h:103
\inmodule QtCore
Definition qsize.h:25
\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:94
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:34
double qreal
Definition qtypes.h:187
QItemEditorFactory * factory
QSvgRenderer * renderer
[0]