From 649719c29bc3b33ab6a5eb9577d53bd0ba897550 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Nov 2010 14:38:58 +0100 Subject: 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 --- src/gui/painting/qtextureglyphcache.cpp | 21 ++++++++++++--------- src/gui/painting/qtextureglyphcache_p.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 2cd7780d56..2daa1f08b8 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 f84d1e66d9..94cb555540 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; -- cgit v1.2.3