diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-05-07 11:12:39 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-05-07 11:25:48 (GMT) |
commit | 20d88b4d390e2e11079f62ab9f472c30f7c5b11d (patch) | |
tree | afd34f0369b76b5d25572f5f42bd7600d9ab12fc | |
parent | 27aae6a5bb4858897547f2f436bc1cdf2e8bfbd4 (diff) | |
download | Qt-20d88b4d390e2e11079f62ab9f472c30f7c5b11d.zip Qt-20d88b4d390e2e11079f62ab9f472c30f7c5b11d.tar.gz Qt-20d88b4d390e2e11079f62ab9f472c30f7c5b11d.tar.bz2 |
Fixed some inconsistencies for image drawing on non-integer coords.
The fix for 1x1 source rect image drawing in change
ffbb3c1a2aee4134dce80cd144a26bf32865b698 was incorrect for transforms
with type >= TxScale. The aliased coordinate delta needs to be applied
in device coordinates, not in logical coordinates.
Also specialize the non-antialiased TxScale case by simply calling
fillRect_normalized directly, avoiding having to scan convert the
rectangle manually.
Task-number: 251561
Reviewed-by: Trond
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 19 | ||||
-rw-r--r-- | tests/arthur/data/qps/borderimage.qps | 19 | ||||
-rw-r--r-- | tests/arthur/data/qps/borderimage_qps.png | bin | 90704 -> 91838 bytes |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index cbfd5e3..847904b 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2575,9 +2575,10 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe if (!aa && sr.size() == QSize(1, 1)) { // as fillRect will apply the aliased coordinate delta we need to // subtract it here as we don't use it for image drawing - const QRectF targetRect = r.translated(-aliasedCoordinateDelta, - -aliasedCoordinateDelta); - fillRect(targetRect, QColor::fromRgba(img.pixel(sr.x(), sr.y()))); + QTransform old = s->matrix; + s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); + fillRect(r, QColor::fromRgba(img.pixel(sr.x(), sr.y()))); + s->matrix = old; return; } @@ -2611,6 +2612,18 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe return; d->image_filler_xform.setupMatrix(copy, s->flags.bilinear); + if (!aa && s->matrix.type() == QTransform::TxScale) { + QRectF rr = s->matrix.mapRect(r); + + const int x1 = qRound(rr.x()); + const int y1 = qRound(rr.y()); + const int x2 = qRound(rr.right()); + const int y2 = qRound(rr.bottom()); + + fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler_xform, d); + return; + } + #ifdef QT_FAST_SPANS ensureState(); if (s->flags.tx_noshear || s->matrix.type() == QTransform::TxScale) { diff --git a/tests/arthur/data/qps/borderimage.qps b/tests/arthur/data/qps/borderimage.qps index 14073fe..8d2e54b 100644 --- a/tests/arthur/data/qps/borderimage.qps +++ b/tests/arthur/data/qps/borderimage.qps @@ -123,6 +123,21 @@ end_block one_pixel_border resetMatrix +translate 205.1 626.1 +scale 0.4 0.4 + +repeat_block one_pixel_border + +resetMatrix + +translate 255.1 624.1 +scale 0.4 0.4 +rotate 10 + +repeat_block one_pixel_border + +resetMatrix + setPen red drawRect 0 0 70 680 @@ -145,5 +160,5 @@ drawText 174 114 "smoothpixmaptransform off" drawRect 164 128 224 134 drawText 174 252 "smoothpixmaptransform on" -drawRect 200 520 97 128 -drawText 210 638 "1x1 edges" +drawRect 200 520 97 188 +drawText 210 698 "1x1 edges" diff --git a/tests/arthur/data/qps/borderimage_qps.png b/tests/arthur/data/qps/borderimage_qps.png Binary files differindex a4ec6cb..ed51d5f 100644 --- a/tests/arthur/data/qps/borderimage_qps.png +++ b/tests/arthur/data/qps/borderimage_qps.png |