diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-05-05 13:36:30 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-05-05 13:42:22 (GMT) |
commit | fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd (patch) | |
tree | 5fd8e43395c2a2394cdf562efe39490d32d9f235 /src/gui/painting/qpaintengine_raster.cpp | |
parent | d89d1eb47e69c2c2dc1121ef92fd08ef983e3e63 (diff) | |
download | Qt-fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd.zip Qt-fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd.tar.gz Qt-fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd.tar.bz2 |
Ensured correct rounding of scaled image drawing at non-integer coords.
Images coordinates should simply be rounded and are not to be subject
to the aliased coordinate delta. The patch also adds a tiny delta in
QSpanData::setupMatrix() to ensure coordinates for fetching from source
images are rounded the opposite direction of the target rectangle.
This removes a lot of artifacts when trying to do border-image based
drawing on non-integer coordinates. A new qps test for border-image
drawing is included.
Task-number: 251561
Reviewed-by: Trond
Diffstat (limited to 'src/gui/painting/qpaintengine_raster.cpp')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index e249b3e..788b722 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2664,7 +2664,13 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe QRectF rr = r; rr.translate(s->matrix.dx(), s->matrix.dy()); - fillRect_normalized(toRect_normalized(rr), &d->image_filler, d); + + 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, d); } } @@ -5147,7 +5153,11 @@ void QSpanData::adjustSpanMethods() void QSpanData::setupMatrix(const QTransform &matrix, int bilin) { - QTransform inv = matrix.inverted(); + QTransform delta; + // make sure we round off correctly in qdrawhelper.cpp + delta.translate(1.0 / 65536, 1.0 / 65536); + + QTransform inv = (delta * matrix).inverted(); m11 = inv.m11(); m12 = inv.m12(); m13 = inv.m13(); |