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>
This commit is contained in:
parent
29fa59d244
commit
c143161608
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user