diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2010-08-18 15:17:15 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-08-18 15:21:33 (GMT) |
commit | 041a68007413a20a9a9c97d0f2f04f9e03428f67 (patch) | |
tree | 87ab76fa3d8704194935df78f429c75752736002 | |
parent | 3014b427aa8700890f9bd8ea2a0300fc152bf3d2 (diff) | |
download | Qt-041a68007413a20a9a9c97d0f2f04f9e03428f67.zip Qt-041a68007413a20a9a9c97d0f2f04f9e03428f67.tar.gz Qt-041a68007413a20a9a9c97d0f2f04f9e03428f67.tar.bz2 |
Revert "Fix the rendering of lines with the X11 paint engine"
This reverts commit ebbab30af417dfbf3df47dec15c0e2f8d6a30fa6,
which broke fill / outline consistency, and when trying to fix that
by rounding the fill the same way that broke rendering in Creator.
Unfortunately the X11 paint engine is too sensitive to changes, there
have already been tons of patches to make it as consistent as possible.
It's simply not possible to get the same rounding for both fill and
outlines and at the same time have consistency between fill and outline
(no holes or fill outside the outline), while using the integer based
Xlib rendering API. Hopefully in 4.8 we'll switch to raster and the X11
paint engine will be a legacy.
Reviewed-by: Trond
-rw-r--r-- | src/gui/painting/qpaintengine_x11.cpp | 22 | ||||
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 65 |
2 files changed, 12 insertions, 75 deletions
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index e521e01..910b2df 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -696,10 +696,11 @@ void QX11PaintEngine::drawLines(const QLine *lines, int lineCount) linef = d->matrix.map(QLineF(lines[i])); } if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); - int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); - int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); - int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); + int x1 = qRound(linef.x1() + aliasedCoordinateDelta); + int y1 = qRound(linef.y1() + aliasedCoordinateDelta); + int x2 = qRound(linef.x2() + aliasedCoordinateDelta); + int y2 = qRound(linef.y2() + aliasedCoordinateDelta); + XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -729,10 +730,11 @@ void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount) for (int i = 0; i < lineCount; ++i) { QLineF linef = d->matrix.map(lines[i]); if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); - int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); - int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); - int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); + int x1 = qRound(linef.x1() + aliasedCoordinateDelta); + int y1 = qRound(linef.y1() + aliasedCoordinateDelta); + int x2 = qRound(linef.x2() + aliasedCoordinateDelta); + int y2 = qRound(linef.y2() + aliasedCoordinateDelta); + XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -1688,8 +1690,8 @@ void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int if (clippedCount > 0) { QVarLengthArray<XPoint> xpoints(clippedCount); for (int i = 0; i < clippedCount; ++i) { - xpoints[i].x = qFloor(clippedPoints[i].x + aliasedCoordinateDelta); - xpoints[i].y = qFloor(clippedPoints[i].y + aliasedCoordinateDelta); + xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta); + xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta); } uint numberPoints = qMin(clippedCount, xlibMaxLinePoints); XPoint *pts = xpoints.data(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 2cbb9b2..f358681 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -118,12 +118,10 @@ private slots: void drawLine_task190634(); void drawLine_task229459(); void drawLine_task234891(); - void drawHorizontalLineF(); void drawRect_data() { fillData(); } void drawRect(); void drawRect2(); - void drawRectFHorizontalLine(); void fillRect(); void fillRect2(); @@ -253,7 +251,6 @@ private slots: void setPenColorOnPixmap(); void QTBUG5939_attachPainterPrivate(); - void drawHorizontalLine(); private: void fillData(); @@ -1221,26 +1218,6 @@ void tst_QPainter::drawLine_task234891() QCOMPARE(expected, img); } -void tst_QPainter::drawHorizontalLineF() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - void tst_QPainter::drawLine_task216948() { QImage img(1, 10, QImage::Format_ARGB32_Premultiplied); @@ -1325,26 +1302,6 @@ void tst_QPainter::drawRect2() } } -void tst_QPainter::drawRectFHorizontalLine() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - void tst_QPainter::fillRect() { QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -4565,28 +4522,6 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() QCOMPARE(widget->deviceTransform, proxy->deviceTransform); } -void tst_QPainter::drawHorizontalLine() -{ - QPixmap pixmap(100, 3); - pixmap.fill(); - - { - QPainter painter(&pixmap); - painter.translate(0.3, 0.3); - painter.drawLine(QLine(1, 1, 99, 1)); - } - - QImage refImage(100, 3, QImage::Format_ARGB32); - refImage.fill(0xFFFFFFFF); - { - QPainter painter(&refImage); - painter.translate(0.3, 0.3); - painter.drawLine(QLine(1, 1, 99, 1)); - } - - QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); -} - QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |