aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-03-21 20:52:22 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-23 18:33:31 +0000
commit4983d26e0aa678653bac6981b00f7448a220e1b1 (patch)
treeaacc656eef0e3e2f7d9daf50f95c5ff1639c6b87 /src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
parent0b530a6b4440e656d8625dee1434dc4d335d2c65 (diff)
Fix destroying glyph cache textures with hidden text items
Move the management of the to-be-released textures up to the rendercontext, so that the glyph cache objects do not need to care about this. Issuing a delete(Later) on the QRhiTexture in the glyph cache is too early if there is no visible text item in the scene that's going to commit the resource updates collected on the rendercontext's QRhiResourceUpdateBatch. Instead, it is logical to move also the list of pending-release textures to the rendercontext, since it already has the update batch object. Fixes: QTBUG-111995 Change-Id: Ic4309166f265950a7061ae510567ce677c4943df Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit e9c0b15060e0b70f70857d02029d6ebed95c0abf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp')
-rw-r--r--src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
index a68842577d..54cf298943 100644
--- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
@@ -32,19 +32,10 @@ QSGRhiDistanceFieldGlyphCache::QSGRhiDistanceFieldGlyphCache(QSGDefaultRenderCon
QSGRhiDistanceFieldGlyphCache::~QSGRhiDistanceFieldGlyphCache()
{
- // A plain delete should work, but just in case commitResourceUpdates was
- // not called and something is enqueued on the update batch for a texture,
- // defer until the end of the frame.
- for (int i = 0; i < m_textures.size(); ++i) {
- if (m_textures[i].texture)
- m_textures[i].texture->deleteLater();
- }
+ for (const TextureInfo &t : std::as_const(m_textures))
+ m_rc->deferredReleaseGlyphCacheTexture(t.texture);
delete m_areaAllocator;
-
- // should be empty, but just in case
- for (QRhiTexture *t : std::as_const(m_pendingDispose))
- t->deleteLater();
}
void QSGRhiDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &glyphs)
@@ -243,7 +234,7 @@ void QSGRhiDistanceFieldGlyphCache::resizeTexture(TextureInfo *texInfo, int widt
resourceUpdates->copyTexture(texInfo->texture, oldTexture);
}
- m_pendingDispose.insert(oldTexture);
+ m_rc->deferredReleaseGlyphCacheTexture(oldTexture);
}
bool QSGRhiDistanceFieldGlyphCache::useTextureResizeWorkaround() const
@@ -522,14 +513,8 @@ void QSGRhiDistanceFieldGlyphCache::commitResourceUpdates(QRhiResourceUpdateBatc
{
if (QRhiResourceUpdateBatch *resourceUpdates = m_rc->maybeGlyphCacheResourceUpdates()) {
mergeInto->merge(resourceUpdates);
- m_rc->releaseGlyphCacheResourceUpdates();
+ m_rc->resetGlyphCacheResources();
}
-
- // now let's assume the resource updates will be committed in this frame
- for (QRhiTexture *t : std::as_const(m_pendingDispose))
- t->deleteLater(); // will be deleted after the frame is submitted -> safe
-
- m_pendingDispose.clear();
}
bool QSGRhiDistanceFieldGlyphCache::eightBitFormatIsAlphaSwizzled() const