diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-31 06:36:52 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-05-31 06:40:38 (GMT) |
commit | 21f5bf3a3030a393ba17ce7726b70fe853b5b608 (patch) | |
tree | 7fe11ccccbd024b5fec105312fd513717b433d2a /src/gui/painting | |
parent | 035129c96d714ba6183057ff2b77658d993394db (diff) | |
download | Qt-21f5bf3a3030a393ba17ce7726b70fe853b5b608.zip Qt-21f5bf3a3030a393ba17ce7726b70fe853b5b608.tar.gz Qt-21f5bf3a3030a393ba17ce7726b70fe853b5b608.tar.bz2 |
Fix antialiasing with transformed text in OpenGL2 paint engine
Since the paint engine now transforms the prerendered glyphs instead of
rendering transformed glyphs as paths, we need to turn on texture
filtering to avoid antialiasing artifacts. In order to do this, we also
need to pad the glyphs in the glyph cache, otherwise you will get
artifacts when sampling the area around the glyph's bounding rect (where
there might be other glyphs.) This done by adding a glyphPadding()
function to the cache which returns the number of pixels to pad between
each glyph.
Updated: This also fixes a general issue where some combinations of font
sizes and transformations will cause the engine to sample neighbouring
glyphs, so this has been backported to Qt 4.6.x.
Task-number: QTBUG-9706, QTBUG-11028
Reviewed-by: Tom
Conflicts:
src/gui/painting/qtextureglyphcache.cpp
src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 7 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache_p.h | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 7b7f325..b65323f 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -66,6 +66,7 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, m_current_textitem = &ti; const int margin = glyphMargin(); + const int paddingDoubled = glyphPadding() * 2; QHash<glyph_t, Coord> listItemCoordinates; int rowHeight = 0; @@ -114,7 +115,7 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, if (listItemCoordinates.isEmpty()) return; - rowHeight += margin * 2; + rowHeight += margin * 2 + paddingDoubled; if (isNull()) createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, rowHeight); @@ -126,7 +127,7 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, if (m_cx + c.w > m_w) { // no room on the current line, start new glyph strip m_cx = 0; - m_cy = m_h; + m_cy = m_h + paddingDoubled; } if (m_cy + c.h > m_h) { int new_height; @@ -153,7 +154,7 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, } else { // for the Mono case, glyph_width is 8-bit aligned, // and therefore so will m_cx - m_cx += c.w; + m_cx += c.w + paddingDoubled; } ++iter; } diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index d347e61..ebb7d6b 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -97,6 +97,7 @@ public: virtual void createTextureData(int width, int height) = 0; virtual void resizeTextureData(int width, int height) = 0; virtual int glyphMargin() const { return 0; } + virtual int glyphPadding() const { return 0; } virtual void fillTexture(const Coord &coord, glyph_t glyph) = 0; |