From 73573fce295caef35da706a8c8c796ec18e6baf1 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 18 Aug 2017 10:19:48 +0200 Subject: Fix huge painting artefact of certain dashed lines The artefacts appeared for square-capped dashed pens when the end of the line fell a tiny fraction into the start of a new dash. At that point in the dashing algorithm, accumulated precision errors in the 'length' variable could make it slightly differ from the actual length between the start and end points of the line fragment. Although both values would be "almost zero", the rasterizeLine() function's square capping would make the error very visible; see the bug report. Fix by calculating the precise length of the last line fragment. Task-number: QTBUG-56969 Change-Id: I7b69c0d465649be61fb87ac7b8348f0c299486ee Reviewed-by: Lars Knoll --- src/gui/painting/qpaintengine_raster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f99a247270..ef58f96fbc 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3207,7 +3207,7 @@ void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line, QLineF l = line; if (dash >= length) { - dash = length; + dash = line.length(); // Avoid accumulated precision error in 'length' *dashOffset += dash / width; length = 0; } else { -- cgit v1.2.3 From 789f9d0d56204354652760fcde407b30b3b3aded Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 29 Aug 2017 15:08:59 +0200 Subject: Avoid assert on large clips in qt_alphamapblit_generic It is (end - start) that represent the number of pixels being worked on and needs to be smaller than the buffer size. Change-Id: I75a22bc2656ac1c7d231278c3a1931758090f8ce Reviewed-by: Gatis Paeglis Reviewed-by: Laszlo Agocs --- src/gui/painting/qdrawhelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5c6c91f0ba..c78fdfe62e 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5627,7 +5627,7 @@ static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer, int start = qMax(x, clip.x); int end = qMin(x + mapWidth, clip.x + clip.len); - Q_ASSERT(clip.len <= buffer_size); + Q_ASSERT(end - start <= buffer_size); QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, end - start); for (int xp=start; xp(x, clip.x); int end = qMin(x + mapWidth, clip.x + clip.len); - Q_ASSERT(clip.len <= buffer_size); + Q_ASSERT(end - start <= buffer_size); QRgba64 *dest = destFetch64((QRgba64*)buffer, rasterBuffer, start, clip.y, end - start); for (int xp=start; xp