|
A QDistanceFieldText has a text position (within the x/y-plane),
a color, a text (QString), a QFont, and a QDistanceGlyphCache
that is used to retrieve the glyph textures needed for rendering.
To render a given string, we use a QTextLayout to generate GlyphRuns,
which are associated with a given QRawFont. Now the following may
happen:
1. there may be multiple QRawFonts generated by the QTextLayout.
this is because some glyphs may not be available in one font,
so another font has to be used for these glyphs.
2. for the same QRawFont, multiple QTextureAtlasses may be needed
for all glyphs. This is because the the QDistanceFieldGlyphCache
grows lazily by allocating more QTextureAtlasses on demand.
So, for any given QDistanceFieldText, we might need to use multiple
textures for rendering. Because of this, we might need to create multiple
QEntities, each with a separate QDistanceFieldMaterial.
These QEntities are the DistanceFieldTextRenderers, which encapsulate
all QComponents needed to render the glyphs taken from one texture.
When something changes, QDistanceFieldText::update() uses a QTextLayout
to generate a number of QGlyphRuns, each associated with a QRawFont.
These QGlyphRuns are then given to
QDistanceFieldTextPrivate::setCurrentGlyphRuns(). There, for each distinct
texture, all glyph positions are gathered, and according vertex and index
buffers are built. These index buffers are then given to the
DistanceFieldTextRenderer nodes. We make sure to properly ref-count the
glyphs within the QDistanceFieldGlyphCache.
Change-Id: Icf332b87541a6426abd4fbb12e2968a6d8ec5c4c
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
|