From fc2c0094cf661825ce8f3744eefaa65b49426ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Feb 2011 16:11:21 +0100 Subject: Prevent stroking zero length lines in qstroker.cpp If several consecutive points are the same, we should just skip until we get a unique point. This prevents stroking artifacts in the miter join for example. Task-number: QTBUG-5331 Reviewed-by: Kim --- src/gui/painting/qstroker.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 448c972..de56490 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -668,26 +668,28 @@ template bool qt_stroke_side(Iterator *it, #endif QLineF line(qt_fixed_to_real(prev.x), qt_fixed_to_real(prev.y), qt_fixed_to_real(e.x), qt_fixed_to_real(e.y)); - QLineF normal = line.normalVector(); - normal.setLength(offset); - line.translate(normal.dx(), normal.dy()); - - // If we are starting a new subpath, move to correct starting point. - if (first) { - if (capFirst) - stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); - else - stroker->emitMoveTo(qt_real_to_fixed(line.x1()), qt_real_to_fixed(line.y1())); - *startTangent = line; - first = false; - } else { - stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); - } + if (line.p1() != line.p2()) { + QLineF normal = line.normalVector(); + normal.setLength(offset); + line.translate(normal.dx(), normal.dy()); + + // If we are starting a new subpath, move to correct starting point. + if (first) { + if (capFirst) + stroker->joinPoints(prev.x, prev.y, line, stroker->capStyleMode()); + else + stroker->emitMoveTo(qt_real_to_fixed(line.x1()), qt_real_to_fixed(line.y1())); + *startTangent = line; + first = false; + } else { + stroker->joinPoints(prev.x, prev.y, line, stroker->joinStyleMode()); + } - // Add the stroke for this line. - stroker->emitLineTo(qt_real_to_fixed(line.x2()), - qt_real_to_fixed(line.y2())); - prev = e; + // Add the stroke for this line. + stroker->emitLineTo(qt_real_to_fixed(line.x2()), + qt_real_to_fixed(line.y2())); + prev = e; + } // CurveToElement } else if (e.isCurveTo()) { -- cgit v0.12