diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-24 12:51:17 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-24 13:57:52 (GMT) |
commit | f0d257ae6ab3e1ec7c5dfb1ea646e5c824e437de (patch) | |
tree | 33996e308999b64bcee64ddded2e609e66cace77 /src/gui/painting/qtextureglyphcache.cpp | |
parent | 1308b32a1a3e36c5b2788ad4f701a0203b876484 (diff) | |
download | Qt-f0d257ae6ab3e1ec7c5dfb1ea646e5c824e437de.zip Qt-f0d257ae6ab3e1ec7c5dfb1ea646e5c824e437de.tar.gz Qt-f0d257ae6ab3e1ec7c5dfb1ea646e5c824e437de.tar.bz2 |
Fix problems in QTextureGlyphCache caused by insufficient merge
Since the logic of QTextureGlyphCache has been changed, it is impossible
to do an automatic merge of eb2926a2f9607e985b8bca54346e6fdf91343247.
This change fixes problems that occurred with that change:
1. We need to postpone actually resizing the texture until
fillInPendingGlyphs() where we are sure to have a context.
2. We have to fall back to a default max texture size when there is no
context.
Reviewed-by: Trond
Diffstat (limited to 'src/gui/painting/qtextureglyphcache.cpp')
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 2bb8cce..9219876 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -202,18 +202,18 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const // now actually use the coords and paint the wanted glyps into cache. QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = listItemCoordinates.begin(); + int requiredWidth = m_w; while (iter != listItemCoordinates.end()) { Coord c = iter.value(); m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2); - if (m_cx + c.w > m_w) { - int new_width = m_w*2; + if (m_cx + c.w > requiredWidth) { + int new_width = requiredWidth*2; while (new_width < m_cx + c.w) new_width *= 2; if (new_width <= maxTextureWidth()) { - resizeTextureData(new_width, m_h); - m_w = new_width; + requiredWidth = new_width; } else { // no room on the current line, start new glyph strip m_cx = 0; @@ -238,21 +238,23 @@ void QTextureGlyphCache::fillInPendingGlyphs() if (m_pendingGlyphs.isEmpty()) return; - int requiredHeight = 0; + int requiredHeight = m_h; + int requiredWidth = m_w; // Use a minimum size to avoid a lot of initial reallocations { QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin(); while (iter != m_pendingGlyphs.end()) { Coord c = iter.value(); requiredHeight = qMax(requiredHeight, c.y + c.h); + requiredWidth = qMax(requiredWidth, c.x + c.w); ++iter; } } - if (requiredHeight > m_h) { + if (isNull() || requiredHeight > m_h || requiredWidth > m_w) { if (isNull()) - createCache(m_w, qt_next_power_of_two(requiredHeight)); + createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); else - resizeCache(m_w, qt_next_power_of_two(requiredHeight)); + resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); } { |