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;
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;
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;
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;
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;
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;
void drawTextOutsideGuiThread();
void drawTextWithComplexBrush();
+ void QTBUG26013_squareCapStroke();
private:
void fillData();
QVERIFY(paintedPixels > 0);
}
+void tst_QPainter::QTBUG26013_squareCapStroke()
+{
+ QImage image(4, 4, QImage::Format_RGB32);
+
+ QPainter p(&image);
+ p.setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap));
+
+ for (int i = 0; i < 3; ++i) {
+ qreal d = i / 3.0;
+
+ image.fill(0xffffffff);
+
+ p.drawLine(QLineF(0, d, 0, d + 2));
+ p.drawLine(QLineF(1, d, 3, d));
+
+ // ensure that a horizontal line and a vertical line with square cap round up (downwards) at the same time
+ QCOMPARE(image.pixel(0, 0), image.pixel(1, 0));
+
+ image.fill(0xffffffff);
+
+ p.drawLine(QLineF(d, 0, d + 2, 0));
+ p.drawLine(QLineF(d, 1, d, 3));
+
+ // ensure that a vertical line and a horizontal line with square cap round up (to the right) at the same time
+ QCOMPARE(image.pixel(0, 0), image.pixel(0, 1));
+ }
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"