From 6336fa98ca7340fe65ab252cc576c3d10c9ddb76 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Oct 2019 09:30:30 +0200 Subject: Fix loading pregenerated distance field cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can't assume the stride of the internal QImage data matches the width, since this is likely to be aligned to four bytes. Therefore we copy one scan line at the time instead. [ChangeLog][Text] Pregenerating distance field caches would sometimes lead to corrupted rendering. Fixes: QT3DS-3908 Change-Id: I3c30c6c707d6f220d852d6c067301ab4d468884c Reviewed-by: Jere Tuliniemi Reviewed-by: Tomi Korpipää --- src/runtimerender/Qt3DSDistanceFieldGlyphCache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtimerender/Qt3DSDistanceFieldGlyphCache.cpp b/src/runtimerender/Qt3DSDistanceFieldGlyphCache.cpp index b919ca5..d19c9f6 100644 --- a/src/runtimerender/Qt3DSDistanceFieldGlyphCache.cpp +++ b/src/runtimerender/Qt3DSDistanceFieldGlyphCache.cpp @@ -494,7 +494,8 @@ bool Q3DSDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font) resizeTexture(texInfo, width, height); - memcpy(texInfo->copy.bits(), textureData, size); + for (int y = 0; y < height; ++y) + memcpy(texInfo->copy.scanLine(y), textureData + y * width, width); textureData += size; QImage &image = texInfo->copy; -- cgit v1.2.3