diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-02-25 15:11:21 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-02-25 15:25:27 (GMT) |
commit | 49c866277e6aa7221a310a7635304c75d693bde5 (patch) | |
tree | 78f31032a13e16f687596150ff707369b382197f /src | |
parent | 0a022996bd138553360562444d8b85a6141ab0ae (diff) | |
download | Qt-49c866277e6aa7221a310a7635304c75d693bde5.zip Qt-49c866277e6aa7221a310a7635304c75d693bde5.tar.gz Qt-49c866277e6aa7221a310a7635304c75d693bde5.tar.bz2 |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qstroker.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 80353bc..fca46b4 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -668,26 +668,28 @@ template <class Iterator> 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()) { |