From 5ef6ac6550f1692d66611e7918d85c7ebedda439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 30 Mar 2009 09:25:38 +0200 Subject: Fix missing fills of rects with negative width/height in raster engine. Call isEmpty() on the normalized rect instead of the original rect. Task-number: 247505 Reviewed-by: --- src/gui/painting/qpaintengine_raster.cpp | 2 +- tests/auto/qpainter/tst_qpainter.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index ba79b5b..6dd5682 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1529,7 +1529,7 @@ void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount) d->initializeRasterizer(&s->brushData); for (int i = 0; i < rectCount; ++i) { const QRectF &rect = rects[i].normalized(); - if (rects[i].isEmpty()) + if (rect.isEmpty()) continue; const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 2e1335c..a4c768d 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -203,6 +203,7 @@ private slots: void drawImage_task217400_data(); void drawImage_task217400(); void drawRect_task215378(); + void drawRect_task247505(); void drawImage_data(); void drawImage(); @@ -3589,6 +3590,26 @@ void tst_QPainter::drawRect_task215378() QVERIFY(img.pixel(0, 0) != img.pixel(1, 1)); } +void tst_QPainter::drawRect_task247505() +{ + QImage a(10, 10, QImage::Format_ARGB32_Premultiplied); + a.fill(0); + QImage b = a; + + QPainter p(&a); + p.setPen(Qt::NoPen); + p.setBrush(Qt::black); + p.drawRect(QRectF(10, 0, -10, 10)); + p.end(); + p.begin(&b); + p.setPen(Qt::NoPen); + p.setBrush(Qt::black); + p.drawRect(QRectF(0, 0, 10, 10)); + p.end(); + + QCOMPARE(a, b); +} + void tst_QPainter::drawImage_data() { QTest::addColumn("x"); -- cgit v0.12