Skip to content

Commit

Permalink
Fix huge painting artefact of certain dashed lines
Browse files Browse the repository at this point in the history
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 <lars.knoll@qt.io>
(cherry picked from commit 73573fc)
  • Loading branch information
aavit authored and tronical committed Aug 22, 2017
1 parent c86a75e commit 29d29cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/painting/qpaintengine_raster.cpp
Expand Up @@ -3164,7 +3164,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 {
Expand Down

0 comments on commit 29d29cb

Please sign in to comment.