51 QSGDefaultRenderContext(QSGContext *context);
53 QRhi *rhi()
const override {
return m_rhi; }
54 bool isValid()
const override {
return m_rhi !=
nullptr; }
56 static const int INIT_PARAMS_MAGIC = 0x50E;
57 struct InitParams :
public QSGRenderContext::InitParams {
58 int sType = INIT_PARAMS_MAGIC;
62 QSize initialSurfacePixelSize;
65 QSurface *maybeSurface =
nullptr;
68 void initialize(
const QSGRenderContext::InitParams *params) override;
69 void invalidate() override;
71 void prepareSync(qreal devicePixelRatio,
72 QRhiCommandBuffer *cb,
73 const QQuickGraphicsConfiguration &config) override;
75 void beginNextFrame(QSGRenderer *renderer,
const QSGRenderTarget &renderTarget,
76 RenderPassCallback mainPassRecordingStart,
77 RenderPassCallback mainPassRecordingEnd,
78 void *callbackUserData) override;
79 void renderNextFrame(QSGRenderer *renderer) override;
80 void endNextFrame(QSGRenderer *renderer) override;
82 void preprocess() override;
83 void invalidateGlyphCaches() override;
84 void flushGlyphCaches() override;
85 QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(
const QRawFont &font,
int renderTypeQuality) override;
86 QSGCurveGlyphAtlas *curveGlyphAtlas(
const QRawFont &font) override;
88 QSGTexture *createTexture(
const QImage &image, uint flags)
const override;
89 QSGRenderer *createRenderer(QSGRendererInterface::RenderMode renderMode = QSGRendererInterface::RenderMode2D) override;
90 QSGTexture *compressedTextureForFactory(
const QSGCompressedTextureFactory *factory)
const override;
92 virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant);
94 int maxTextureSize()
const override {
return m_maxTextureSize; }
95 bool useDepthBufferFor2D()
const {
return m_useDepthBufferFor2D; }
96 int msaaSampleCount()
const {
return m_initParams.sampleCount; }
98 QRhiCommandBuffer *currentFrameCommandBuffer()
const {
100 return m_currentFrameCommandBuffer;
102 QRhiRenderPassDescriptor *currentFrameRenderPass()
const {
104 return m_currentFrameRenderPass;
107 qreal currentDevicePixelRatio()
const
115 return m_currentDevicePixelRatio;
118 QRhiResourceUpdateBatch *maybeGlyphCacheResourceUpdates();
119 QRhiResourceUpdateBatch *glyphCacheResourceUpdates();
120 void deferredReleaseGlyphCacheTexture(QRhiTexture *texture);
121 void resetGlyphCacheResources();
123 QSharedPointer<QSGDepthStencilBuffer> getDepthStencilBuffer(
const QSize &size,
int sampleCount);
124 void addDepthStencilBuffer(
const QSharedPointer<QSGDepthStencilBuffer> &ds);
127 InitParams m_initParams;
129 int m_maxTextureSize;
130 QSGRhiAtlasTexture::Manager *m_rhiAtlasManager;
131 QRhiCommandBuffer *m_currentFrameCommandBuffer;
132 QRhiRenderPassDescriptor *m_currentFrameRenderPass;
133 qreal m_currentDevicePixelRatio;
134 bool m_useDepthBufferFor2D;
135 QRhiResourceUpdateBatch *m_glyphCacheResourceUpdates;
136 QSet<QRhiTexture *> m_pendingGlyphCacheTextures;
137 QHash<FontKey, QSGCurveGlyphAtlas *> m_curveGlyphAtlases;
138 QHash<std::pair<QSize,
int>, QWeakPointer<QSGDepthStencilBuffer>> m_depthStencilBuffers;
140 friend class QSGDepthStencilBuffer;
static QFontEngine * fontEngineOfRawFont(const QRawFont &font)