52 QSGDefaultRenderContext(QSGContext *context);
54 QRhi *rhi()
const override {
return m_rhi; }
55 bool isValid()
const override {
return m_rhi !=
nullptr; }
57 static const int INIT_PARAMS_MAGIC = 0x50E;
58 struct InitParams :
public QSGRenderContext::InitParams {
59 int sType = INIT_PARAMS_MAGIC;
63 QSize initialSurfacePixelSize;
66 QSurface *maybeSurface =
nullptr;
69 void initialize(
const QSGRenderContext::InitParams *params) override;
70 void invalidate() override;
72 void prepareSync(qreal devicePixelRatio,
73 QRhiCommandBuffer *cb,
74 const QQuickGraphicsConfiguration &config) override;
76 void beginNextFrame(QSGRenderer *renderer,
const QSGRenderTarget &renderTarget,
77 RenderPassCallback mainPassRecordingStart,
78 RenderPassCallback mainPassRecordingEnd,
79 void *callbackUserData) override;
80 void renderNextFrame(QSGRenderer *renderer) override;
81 void endNextFrame(QSGRenderer *renderer) override;
83 void preprocess() override;
84 void invalidateGlyphCaches() override;
85 void flushGlyphCaches() override;
86 QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(
const QRawFont &font,
int renderTypeQuality) override;
87 QSGCurveGlyphAtlas *curveGlyphAtlas(
const QRawFont &font) override;
89 QSGTexture *createTexture(
const QImage &image, uint flags)
const override;
90 QSGRenderer *createRenderer(QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D) override;
91 QSGTexture *compressedTextureForFactory(
const QSGCompressedTextureFactory *factory)
const override;
93 virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant);
95 int maxTextureSize()
const override {
return m_maxTextureSize; }
96 bool useDepthBufferFor2D()
const {
return m_useDepthBufferFor2D; }
97 int msaaSampleCount()
const {
return m_initParams.sampleCount; }
99 QRhiCommandBuffer *currentFrameCommandBuffer()
const {
101 return m_currentFrameCommandBuffer;
103 QRhiRenderPassDescriptor *currentFrameRenderPass()
const {
105 return m_currentFrameRenderPass;
108 qreal currentDevicePixelRatio()
const
116 return m_currentDevicePixelRatio;
119 QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates();
120 QRhiResourceUpdateBatch *glyphCacheResourceUpdates();
121 void deferredReleaseGlyphCacheTexture(QRhiTexture *texture);
122 void resetGlyphCacheResources();
124 QSharedPointer<QSGDepthStencilBuffer> getDepthStencilBuffer(
const QSize &size,
int sampleCount);
125 void addDepthStencilBuffer(
const QSharedPointer<QSGDepthStencilBuffer> &ds);
128 InitParams m_initParams;
130 int m_maxTextureSize;
131 QSGRhiAtlasTexture::Manager *m_rhiAtlasManager;
132 QRhiCommandBuffer *m_currentFrameCommandBuffer;
133 QRhiRenderPassDescriptor *m_currentFrameRenderPass;
134 qreal m_currentDevicePixelRatio;
135 bool m_useDepthBufferFor2D;
136 QRhiResourceUpdateBatch *m_glyphCacheResourceUpdates;
137 QSet<QRhiTexture *> m_pendingGlyphCacheTextures;
138 QHash<FontKey, QSGCurveGlyphAtlas *> m_curveGlyphAtlases;
139 QHash<std::pair<QSize,
int>, QWeakPointer<QSGDepthStencilBuffer>> m_depthStencilBuffers;
141 friend class QSGDepthStencilBuffer;
static QFontEngine * fontEngineOfRawFont(const QRawFont &font)