From b528e1324add2208abf8f83fb51a8bd2183157f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 13 Mar 2013 11:40:48 +0100 Subject: Fixed QPainter::drawPolyline() not drawing solid lines. If a line segment isn't filled we keep using the same point of origin. Task-number: QTBUG-26156 Change-Id: I20af8410a7039b69848f201ab62fd3c01b95531b Reviewed-by: Titta Heikkala Reviewed-by: Gunnar Sletta --- src/gui/painting/qcosmeticstroker.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/gui/painting/qcosmeticstroker.cpp') diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 1de955bc13..7f53bec52f 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -583,6 +583,7 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) patternOffset = state->lastPen.dashOffset()*64; lastPixel.x = -1; + const qreal *begin = points; const qreal *end = points + 2*path.elementCount(); // handle closed path case bool closed = path.hasImplicitClose() || (points[0] == end[-2] && points[1] == end[-1]); @@ -592,6 +593,7 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) calculateLastPoint(p2.x(), p2.y(), p.x(), p.y()); } + bool fastPenAliased = (state->flags.fast_pen && !state->flags.antialiased); points += 2; while (points < end) { QPointF p2 = QPointF(points[0], points[1]) * state->matrix; @@ -599,9 +601,22 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) if (!closed && drawCaps && points == end - 2) caps |= CapEnd; + QCosmeticStroker::Point last = this->lastPixel; stroke(this, p.x(), p.y(), p2.x(), p2.y(), caps); - p = p2; + /* fix for gaps in polylines with fastpen and aliased in a sequence + of points with small distances: if current point p2 has been dropped + out, keep last non dropped point p. */ + if (fastPenAliased) { + if (last.x != lastPixel.x || last.y != lastPixel.y || + points == begin + 2 || points == end - 2 ) { + { + p = p2; + } + } + } else { + p = p2; + } points += 2; caps = NoCaps; } -- cgit v1.2.3