diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-11-19 13:38:58 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-11-19 13:38:58 (GMT) |
commit | 649719c29bc3b33ab6a5eb9577d53bd0ba897550 (patch) | |
tree | 0674977bc66e6d1cec5f1434eb32c303f9aceb74 /src/gui | |
parent | 72f161739b270b01807f97cd853030440f0fd430 (diff) | |
download | Qt-649719c29bc3b33ab6a5eb9577d53bd0ba897550.zip Qt-649719c29bc3b33ab6a5eb9577d53bd0ba897550.tar.gz Qt-649719c29bc3b33ab6a5eb9577d53bd0ba897550.tar.bz2 |
Fix possible missing glyphs in raster engine glyph cache
Two possible failures when using the glyph cache on raster engine and
populating the cache with very many glyphs:
1. Change 72f161739b270b01807f97cd853030440f0fd430 caused the maximum
height of the glyph cache to be 32768, which was not sufficient for
large fonts with very many characters (e.g. Chinese text)
2. Since we are using QPainter to draw into the glyph cache for RGB32
glyphcaches, and QPainter does not support very high coordinates,
we need to create a reference image that references a section of the
glyph cache and paint into that instead.
Task-number: QT-3971
Reviewed-by: Samuel
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 21 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache_p.h | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 2cd7780..2daa1f0 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -151,11 +151,11 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const while (new_height < m_cy + c.h) new_height *= 2; - if (new_height > maxTextureHeight()) { - // We can't make a new texture of the required size, so - // bail out - return false; - } + if (maxTextureHeight() > 0 && new_height > maxTextureHeight()) { + // We can't make a new texture of the required size, so + // bail out + return false; + } // if no room in the current texture - realloc a larger texture resizeTextureData(m_w, new_height); @@ -266,11 +266,14 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) } #endif - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) { - QPainter p(&m_image); + if (m_type == QFontEngineGlyphCache::Raster_RGBMask) { + QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()), + qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(), + m_image.format()); + QPainter p(&ref); p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(c.x, c.y, c.w, c.h, QColor(0,0,0,0)); // TODO optimize this - p.drawImage(c.x, c.y, mask); + p.fillRect(0, 0, c.w, c.h, QColor(0,0,0,0)); // TODO optimize this + p.drawImage(0, 0, mask); p.end(); } else if (m_type == QFontEngineGlyphCache::Raster_Mono) { if (mask.depth() > 1) { diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index f84d1e6..94cb555 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -118,7 +118,7 @@ public: QImage textureMapForGlyph(glyph_t g) const; virtual int maxTextureWidth() const { return QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; } - virtual int maxTextureHeight() const { return 32768; } + virtual int maxTextureHeight() const { return -1; } protected: QFontEngine *m_current_fontengine; |