diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2012-09-20 15:30:24 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-20 23:08:44 +0200 |
commit | 72aaba336c7afe6d79d59995bfb31a8effca4e9e (patch) | |
tree | e6f38c0330f1229bec0f4db6e4a612e6d2f8b46d /src/gui/painting | |
parent | 562d6ff90f693e43086b286b6e4b2bf2e581e111 (diff) |
Fixed inconsistent rounding of square cap pens.
A horizontal line should round up at the same time as a vertical line
with square cap, when rendering at subpixel coordinates. Thus, the
special casing in the cosmetic stroker of offsetting by half a pixel
should be for flat caps instead of for square caps.
Task-number: QTBUG-26013
Change-Id: Ic09249337f814c7de95a17976ec9e651561a744b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qcosmeticstroker.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 6f7b69f7b0..8bfa6d6c92 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -409,7 +409,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal if (clipLine(rx1, ry1, rx2, ry2)) return; - const int half = 32; + const int half = 31; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; @@ -429,8 +429,8 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); int x = x1 << 10; - int y = y1 >> 6; - int ys = y2 >> 6; + int y = (y1 + 32) >> 6; + int ys = (y2 + 32) >> 6; if (y != ys) { x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; @@ -460,8 +460,8 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1); int y = y1 << 10; - int x = x1 >> 6; - int xs = x2 >> 6; + int x = (x1 + 32) >> 6; + int xs = (x2 + 32) >> 6; if (x != xs) { y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; @@ -702,7 +702,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, if (stroker->clipLine(rx1, ry1, rx2, ry2)) return; - static const int half = 32; + static const int half = 31; int x1 = toF26Dot6(rx1) + half; int y1 = toF26Dot6(ry1) + half; int x2 = toF26Dot6(rx2) + half; @@ -735,8 +735,8 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, capAdjust(caps, y1, y2, x, xinc); - int y = y1 >> 6; - int ys = y2 >> 6; + int y = (y1 + 32) >> 6; + int ys = (y2 + 32) >> 6; if (y != ys) { x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6; @@ -810,8 +810,8 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, capAdjust(caps, x1, x2, y, yinc); - int x = x1 >> 6; - int xs = x2 >> 6; + int x = (x1 + 32) >> 6; + int xs = (x2 + 32) >> 6; if (x != xs) { y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6; |