Raster painting: fix dashing for separate lines

When drawing multiple distinct (unconnected) lines (e.g. from
QPainter::drawLines() or a QPainterPath with alternating
movetos/linetos), the dash pattern should not continue from one to the
next, as it should when drawing a connected line (e.g. polyline).
Both the cosmetic stroker and the full stroker does it right, but the
fast rasterizing codepath got it wrong.

Fixes: QTBUG-83048
Change-Id: I3d090f7121726755a0e53cb66b99a5563ac0e1c0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Eirik Aavitsland 2020-03-27 09:41:03 +01:00
parent 0613bf5d16
commit 533f7d7ca3
2 changed files with 44 additions and 3 deletions

View File

@ -1713,8 +1713,11 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
width / line.length(),
s->lastPen.capStyle() == Qt::SquareCap);
} else {
d->rasterizeLine_dashed(line, width,
&dashIndex, &dashOffset, &inDash);
// LinesHint means each line is distinct, so restart dashing
int dIndex = dashIndex;
qreal dOffset = dashOffset;
bool inD = inDash;
d->rasterizeLine_dashed(line, width, &dIndex, &dOffset, &inD);
}
}
}

View File

@ -92,3 +92,41 @@ repeat_block draw_lines
setPen 0xffff0000 0 dashline squarecap
translate 100 0
repeat_block draw_lines
path_moveTo mypath 10 10
path_lineTo mypath 87 10
path_moveTo mypath 10 30
path_lineTo mypath 87 30
path_moveTo mypath 10 50
path_lineTo mypath 87 50
resetMatrix
translate 0 150
begin_block distinctLines
setPen black 0 SolidLine SquareCap
pen_setDashPattern [ 3 3 ]
drawPath mypath
translate 100 0
setPen black 5 SolidLine SquareCap
pen_setDashPattern [ 3 3 ]
drawPath mypath
translate 100 0
setPen black 0 SolidLine RoundCap
pen_setDashPattern [ 3 3 ]
drawPath mypath
translate 100 0
setPen black 5 SolidLine RoundCap
pen_setDashPattern [ 3 3 ]
drawPath mypath
end_block distinctLines
resetMatrix
translate 0 220
setRenderHint Antialiasing true
repeat_block distinctLines