summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-02-25 16:11:21 +0100
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 12:25:06 +0200
commitfc2c0094cf661825ce8f3744eefaa65b49426ad2 (patch)
treea854edf7c8db904e59d3d059722afcf14ddcbdbb
parent70ca9e26898cd6e7d9dc0939dd7793ae1020c54f (diff)
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
-rw-r--r--src/gui/painting/qstroker.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 448c9721da..de56490589 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()) {