--- a/src/gui/painting/qcosmeticstroker.cpp
+++ b/src/gui/painting/qcosmeticstroker.cpp
@@ -423,7 +447,7 @@ void QCosmeticStroker::calculateLastPoin
     if (clipLine(rx1, ry1, rx2, ry2))
         return;
 
-    const int half = legacyRounding ? 31 : 0;
+    const int half = 0;
     int x1 = toF26Dot6(rx1) + half;
     int y1 = toF26Dot6(ry1) + half;
     int x2 = toF26Dot6(rx2) + half;
@@ -447,7 +447,7 @@ void QCosmeticStroker::calculateLastPoin
         int ys = (y2 + 32) >> 6;
 
         if (y != ys) {
-            x += ( ((((y << 6) + 32 - y1)))  * xinc ) >> 6;
+            x += ((((y << 6) - y1)  * xinc) >> 6) + 32768;
 
             if (swapped) {
                 lastPixel.x = x >> 16;
@@ -478,7 +478,7 @@ void QCosmeticStroker::calculateLastPoin
         int xs = (x2 + 32) >> 6;
 
         if (x != xs) {
-            y += ( ((((x << 6) + 32 - x1)))  * yinc ) >> 6;
+            y += ((((x << 6) - x1)  * yinc) >> 6) + 32768;
 
             if (swapped) {
                 lastPixel.x = x;
@@ -736,7 +736,7 @@ static bool drawLine(QCosmeticStroker *s
     if (stroker->clipLine(rx1, ry1, rx2, ry2))
         return false;
 
-    const int half = stroker->legacyRounding ? 31 : 0;
+    const int half = 0;
     int x1 = toF26Dot6(rx1) + half;
     int y1 = toF26Dot6(ry1) + half;
     int x2 = toF26Dot6(rx2) + half;
@@ -773,44 +773,48 @@ static bool drawLine(QCosmeticStroker 
         int ys = (y2 + 32) >> 6;
 
         if (y != ys) {
-            x += ( ((((y << 6) + 32 - y1)))  * xinc ) >> 6;
+            x += ((((y << 6) - y1)  * xinc) >> 6) + 32768;

             // calculate first and last pixel and perform dropout control
             QCosmeticStroker::Point first;
+            for (size_t i = 0; i < 2; ++i) {
             first.x = x >> 16;
             first.y = y;
             last.x = (x + (ys - y - 1)*xinc) >> 16;
             last.y = ys - 1;
             if (swapped)
                 qSwap(first, last);

             bool axisAligned = qAbs(xinc) < (1 << 14);
             if (stroker->lastPixel.x >= 0) {
                 if (first.x == stroker->lastPixel.x &&
                     first.y == stroker->lastPixel.y) {
                     // remove duplicated pixel
                     if (swapped) {
                         --ys;
                     } else {
                         ++y;
                         x += xinc;
                     }
                 } else if (stroker->lastDir != dir &&
                            (((axisAligned && stroker->lastAxisAligned) &&
                              stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) ||
                             (qAbs(stroker->lastPixel.x - first.x) > 1 ||
                              qAbs(stroker->lastPixel.y - first.y) > 1))) {
                     // have a missing pixel, insert it
                     if (swapped) {
                         ++ys;
                     } else {
                         --y;
                         x -= xinc;
                     }
+                        continue;
                 }
             }
             stroker->lastDir = dir;
             stroker->lastAxisAligned = axisAligned;
+                break;
+            }
 
             Dasher dasher(stroker, swapped, y << 6, ys << 6);
 
@@ -848,43 +852,47 @@ static bool drawLine(QCosmeticStroker *s
         int xs = (x2 + 32) >> 6;
 
         if (x != xs) {
-            y += ( ((((x << 6) + 32 - x1)))  * yinc ) >> 6;
+            y += ((((x << 6) - x1)  * yinc) >> 6) + 32768;
 
             // calculate first and last pixel to perform dropout control
             QCosmeticStroker::Point first;
+            for (size_t i = 0; i < 2; ++i) {
             first.x = x;
             first.y = y >> 16;
             last.x = xs - 1;
             last.y = (y + (xs - x - 1)*yinc) >> 16;
             if (swapped)
                 qSwap(first, last);

             bool axisAligned = qAbs(yinc) < (1 << 14);
             if (stroker->lastPixel.x >= 0) {
                 if (first.x == stroker->lastPixel.x && first.y == stroker->lastPixel.y) {
                     // remove duplicated pixel
                     if (swapped) {
                         --xs;
                     } else {
                         ++x;
                         y += yinc;
                     }
                 } else if (stroker->lastDir != dir &&
                            (((axisAligned && stroker->lastAxisAligned) &&
                              stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) ||
                             (qAbs(stroker->lastPixel.x - first.x) > 1 ||
                              qAbs(stroker->lastPixel.y - first.y) > 1))) {
                     // have a missing pixel, insert it
                     if (swapped) {
                         ++xs;
                     } else {
                         --x;
                         y -= yinc;
                     }
+                        continue;
                 }
             }
             stroker->lastDir = dir;
             stroker->lastAxisAligned = axisAligned;
+                break;
+            }
 
             Dasher dasher(stroker, swapped, x << 6, xs << 6);
 
