summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2020-02-10 13:08:13 +0200
committerJere Tuliniemi <jere.tuliniemi@qt.io>2020-02-11 08:36:36 +0200
commit2dff84fddcffde95e882faceb45d5797dc5c63b9 (patch)
treefc711f3e06f4b37892729d167cf6e18c3791f99d
parentbff0bf78b328b730843abf0e79f58e8411908de5 (diff)
Fix distance field text caching logic
For whatever reason EndFrame is called without the text being rendered in the frame, so we need to keep both text and glyph caches alive during those passes. Previously only text hashes were saved, so now the glyphs are too to prevent building meshes again. Text and glyph hashes are also now not added twice to the lists. Task-number: QT3DS-4062 Change-Id: I3e5cddab788a0d974c98e533d131ed8ae24569ac Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/runtimerender/Qt3DSDistanceFieldRenderer.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/runtimerender/Qt3DSDistanceFieldRenderer.cpp b/src/runtimerender/Qt3DSDistanceFieldRenderer.cpp
index 5ceb9fa..12c46c3 100644
--- a/src/runtimerender/Qt3DSDistanceFieldRenderer.cpp
+++ b/src/runtimerender/Qt3DSDistanceFieldRenderer.cpp
@@ -986,10 +986,12 @@ void Q3DSDistanceFieldRenderer::renderText(SText &text, const QT3DSMat44 &mvp)
glyphInfo.fontScale * float(m_pixelRatio), textColor);
}
- m_renderedGlyphs += glyphHashValue;
+ if (!m_renderedGlyphs.contains(glyphHashValue))
+ m_renderedGlyphs += glyphHashValue;
}
- m_renderedTexts += textHashValue;
+ if (!m_renderedTexts.contains(textHashValue))
+ m_renderedTexts += textHashValue;
text.m_Bounds = NVBounds3(minimum, maximum);
}
@@ -1013,9 +1015,20 @@ ITextRendererCore &ITextRendererCore::createDistanceFieldRenderer(NVFoundationBa
void Q3DSDistanceFieldRenderer::checkAndAddRenderedTexts(SText &text)
{
- auto hashVal = getTextHashValue(text);
- if (m_glyphCache.contains(hashVal))
- m_renderedTexts += hashVal;
+ auto textHashVal = getTextHashValue(text);
+ if (m_glyphCache.contains(textHashVal)) {
+ m_renderedTexts += textHashVal;
+
+ QHash<Q3DSDistanceFieldGlyphCache::TextureInfo *, GlyphInfo> &glyphsPerTexture
+ = m_glyphCache[textHashVal];
+ QHash<Q3DSDistanceFieldGlyphCache::TextureInfo *, GlyphInfo>::const_iterator it;
+ for (it = glyphsPerTexture.constBegin(); it != glyphsPerTexture.constEnd(); ++it) {
+ const GlyphInfo &glyphInfo = it.value();
+ size_t glyphHashValue = getGlyphHashValue(glyphInfo);
+ if (m_meshCache.contains(glyphHashValue))
+ m_renderedGlyphs += glyphHashValue;
+ }
+ }
}
// Unused methods: