optimize QTextureGlyphCache

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-06-22 13:20:17 +00:00
parent 0cc78ae59e
commit 9dee62017f

View file

@ -213,9 +213,9 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
} }
// now actually use the coords and paint the wanted glyps into cache. // now actually use the coords and paint the wanted glyps into cache.
QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = listItemCoordinates.begin(); QHash<GlyphAndSubPixelPosition, Coord>::const_iterator iter = listItemCoordinates.constBegin();
int requiredWidth = m_w; int requiredWidth = m_w;
while (iter != listItemCoordinates.end()) { while (iter != listItemCoordinates.constEnd()) {
Coord c = iter.value(); Coord c = iter.value();
m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2); m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
@ -260,8 +260,8 @@ void QTextureGlyphCache::fillInPendingGlyphs()
int requiredHeight = m_h; int requiredHeight = m_h;
int requiredWidth = m_w; // Use a minimum size to avoid a lot of initial reallocations int requiredWidth = m_w; // Use a minimum size to avoid a lot of initial reallocations
{ {
QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin(); QHash<GlyphAndSubPixelPosition, Coord>::const_iterator iter = m_pendingGlyphs.constBegin();
while (iter != m_pendingGlyphs.end()) { while (iter != m_pendingGlyphs.constEnd()) {
Coord c = iter.value(); Coord c = iter.value();
requiredHeight = qMax(requiredHeight, c.y + c.h); requiredHeight = qMax(requiredHeight, c.y + c.h);
requiredWidth = qMax(requiredWidth, c.x + c.w); requiredWidth = qMax(requiredWidth, c.x + c.w);
@ -277,8 +277,8 @@ void QTextureGlyphCache::fillInPendingGlyphs()
} }
{ {
QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin(); QHash<GlyphAndSubPixelPosition, Coord>::const_iterator iter = m_pendingGlyphs.constBegin();
while (iter != m_pendingGlyphs.end()) { while (iter != m_pendingGlyphs.constEnd()) {
GlyphAndSubPixelPosition key = iter.key(); GlyphAndSubPixelPosition key = iter.key();
fillTexture(iter.value(), key.glyph, key.subPixelPosition); fillTexture(iter.value(), key.glyph, key.subPixelPosition);