src/gui/painting/qstroker.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/src/gui/painting/qstroker.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/gui/painting/qstroker.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -452,6 +452,17 @@
 #endif
 
     if (join == FlatJoin) {
+        QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y),
+                        qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y));
+        QPointF isect;
+        QLineF::IntersectType type = prevLine.intersect(nextLine, &isect);
+        QLineF shortCut(prevLine.p2(), nextLine.p1());
+        qreal angle = shortCut.angleTo(prevLine);
+        if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
+            emitLineTo(focal_x, focal_y);
+            emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
+            return;
+        }
         emitLineTo(qt_real_to_fixed(nextLine.x1()),
                    qt_real_to_fixed(nextLine.y1()));
 
@@ -468,8 +479,8 @@
             // If we are on the inside, do the short cut...
             QLineF shortCut(prevLine.p2(), nextLine.p1());
             qreal angle = shortCut.angleTo(prevLine);
-
             if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
+                emitLineTo(focal_x, focal_y);
                 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
                 return;
             }
@@ -509,8 +520,9 @@
             qfixed offset = m_strokeWidth / 2;
 
             QLineF shortCut(prevLine.p2(), nextLine.p1());
-            qreal angle = prevLine.angle(shortCut);
+            qreal angle = shortCut.angleTo(prevLine);
             if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
+                emitLineTo(focal_x, focal_y);
                 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
                 return;
             }
@@ -581,6 +593,13 @@
                         qt_real_to_fixed(l1.x1()),
                         qt_real_to_fixed(l1.y1()));
         } else if (join == SvgMiterJoin) {
+            QLineF shortCut(prevLine.p2(), nextLine.p1());
+            qreal angle = shortCut.angleTo(prevLine);
+            if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
+                emitLineTo(focal_x, focal_y);
+                emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
+                return;
+            }
             QLineF miterLine(QPointF(qt_fixed_to_real(focal_x),
                                      qt_fixed_to_real(focal_y)), isect);
             if (miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) {
@@ -891,8 +910,8 @@
         }
     }
 
-    int startSegment = int(floor(startAngle / 90));
-    int endSegment = int(floor((startAngle + sweepLength) / 90));
+    int startSegment = int(qFloor(startAngle / 90));
+    int endSegment = int(qFloor((startAngle + sweepLength) / 90));
 
     qreal startT = (startAngle - startSegment * 90) / 90;
     qreal endT = (startAngle + sweepLength - endSegment * 90) / 90;