diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-03-11 17:14:50 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-03-12 13:27:10 +0000 |
commit | fd6a2d1c8ff0488757378080f6003c434fd68de2 (patch) | |
tree | 4c9c37a98a66d47bef46f508866c0e526509b11a /src/gui/painting/qcosmeticstroker.cpp | |
parent | 7d43fb0c10726be005325a4b5c79b3d7f7722c37 (diff) | |
download | qtbase-fd6a2d1c8ff0488757378080f6003c434fd68de2.tar.gz |
Improve rounding in QCosmeticStroker
Fixes the drawn position of end points in drawLine.
Based on a patch by Jørgen Lind, and modified so that
it caused no test regressions.
Task-number: QTBUG-38144
Change-Id: I24aa28480cc6ae09abf91d80378970565a29b254
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui/painting/qcosmeticstroker.cpp')
-rw-r--r-- | src/gui/painting/qcosmeticstroker.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 93c95e4a86..f82b098012 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -437,8 +437,9 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int y = (y1 + 32) >> 6; int ys = (y2 + 32) >> 6; + int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; + x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; if (swapped) { lastPixel.x = x >> 16; @@ -468,8 +469,9 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int x = (x1 + 32) >> 6; int xs = (x2 + 32) >> 6; + int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; + y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; if (swapped) { lastPixel.x = x; @@ -762,9 +764,10 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int y = (y1 + 32) >> 6; int ys = (y2 + 32) >> 6; + int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; + x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; // calculate first and last pixel and perform dropout control QCosmeticStroker::Point first; @@ -837,9 +840,10 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int x = (x1 + 32) >> 6; int xs = (x2 + 32) >> 6; + int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; + y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; // calculate first and last pixel to perform dropout control QCosmeticStroker::Point first; |