summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-06-03 12:16:39 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-06-03 12:22:30 (GMT)
commit91f5c7314afdfd43c867266fc1bc418e0f70bac7 (patch)
treeecf73dfef25df6d4eda6d389623707b93a4b0a6e
parentd16b52d5346a3b652ad7507b24373c51fc0d530c (diff)
downloadQt-91f5c7314afdfd43c867266fc1bc418e0f70bac7.zip
Qt-91f5c7314afdfd43c867266fc1bc418e0f70bac7.tar.gz
Qt-91f5c7314afdfd43c867266fc1bc418e0f70bac7.tar.bz2
Fixed raster bug causing fully clipped images to be partially blended.
The blend functions assume the width / height of the images being blended to be greater than 0. A width of 0 caused the first iteration of a duff's device memcpy (QT_MEMCPY_USHORT) to be executed, thus blending 8 pixels instead of none. BT: yes Task-number: 255014 Reviewed-by: Trond
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp26
2 files changed, 28 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 58ffb02..1a1c204 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1053,7 +1053,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = x + iw - cx2;
iw -= d;
}
- if (iw < 0)
+ if (iw <= 0)
return;
// adapt the y paremeters...
@@ -1070,7 +1070,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = y + ih - cy2;
ih -= d;
}
- if (ih < 0)
+ if (ih <= 0)
return;
// call the blend function...
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 87f9c13..8d6c9d2 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -215,6 +215,7 @@ private slots:
void imageCoordinateLimit();
void imageBlending_data();
void imageBlending();
+ void imageBlending_clipped();
void paintOnNullPixmap();
void checkCompositionMode();
@@ -3792,6 +3793,31 @@ void tst_QPainter::imageBlending()
}
}
+void tst_QPainter::imageBlending_clipped()
+{
+ QImage src(20, 20, QImage::Format_RGB16);
+ QPainter p(&src);
+ p.fillRect(src.rect(), Qt::red);
+ p.end();
+
+ QImage dst(40, 20, QImage::Format_RGB16);
+ p.begin(&dst);
+ p.fillRect(dst.rect(), Qt::white);
+ p.end();
+
+ QImage expected = dst;
+
+ p.begin(&dst);
+ p.setClipRect(QRect(23, 0, 20, 20));
+
+ // should be completely clipped
+ p.drawImage(QRectF(3, 0, 20, 20), src);
+ p.end();
+
+ // dst should be left unchanged
+ QCOMPARE(dst, expected);
+}
+
void tst_QPainter::paintOnNullPixmap()
{
QPixmap pix(16, 16);