summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qtextureglyphcache.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-05-02 14:58:12 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-05-28 17:48:03 +0200
commitc143161608ded130919006f151bf92c44a0991d0 (patch)
treefd4ab337193f517bf357d81b6e908159dd433ea8 /src/gui/painting/qtextureglyphcache.cpp
parent29fa59d24417d017205bdb00d215e372154ce573 (diff)
Avoid uninitialized texture data in image glyph cache
The problem becomes visible with styled native text materials in Quick, but only in certain cases: the regions not used by glyphs in the QImage are undefined (if they are 0 there's no problem) - but the whole code path is only used when the fbo readback workaround is enabled. When these conditions met, the styled text materials may sample locations with uninitialized data in the texture, showing small artifacts around the glyphs when shifting is involved in the styling. The non-image based GL glyph cache handles this by an explicit upload with all 0's when creating the texture - the QImage code path should do the same then. Change-Id: I818ee19f87c6a147e42cd3ead39645da4d0fef11 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/gui/painting/qtextureglyphcache.cpp')
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index c21f2cdda4..e8c47df21c 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -285,6 +285,8 @@ QImageTextureGlyphCache::~QImageTextureGlyphCache()
void QImageTextureGlyphCache::resizeTextureData(int width, int height)
{
m_image = m_image.copy(0, 0, width, height);
+ // Regions not part of the copy are initialized to 0, and that is just what
+ // we need.
}
void QImageTextureGlyphCache::createTextureData(int width, int height)
@@ -305,6 +307,12 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
default:
Q_UNREACHABLE();
}
+
+ // Regions not touched by the glyphs must be initialized to 0. (such
+ // locations may in fact be sampled with styled (shifted) text materials)
+ // When resizing, the QImage copy() does this implicitly but the initial
+ // contents must be zeroed out explicitly here.
+ m_image.fill(0);
}
void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subPixelPosition)