From 40fef756b1e27aaceead7baaf3225c023f0da121 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 18 Aug 2009 16:53:35 +0200 Subject: Fixed rounding error in fillRect() in the raster paint engine Problem introduced by 7661126bc86ed105c02fd9b084ac5a91f12f10c4, which introduced always rounding up when converting the rectangle's coordinates to integers. This would e.g. cause off-by-one errors for the cursor in QTextDocument. Some code paths depended on the ceiling of the coordinates, and these have been reverted. Task-number: 257914 Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index c166c52..93282ab 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1762,10 +1762,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) static inline QRect toNormalizedFillRect(const QRectF &rect) { - const int x1 = qRound(rect.x() + aliasedCoordinateDelta); - const int y1 = qRound(rect.y() + aliasedCoordinateDelta); - const int x2 = qRound(rect.right() + aliasedCoordinateDelta); - const int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); + const int x1 = qRound(rect.x()); + const int y1 = qRound(rect.y()); + const int x2 = qRound(rect.right()); + const int y2 = qRound(rect.bottom()); return QRect(x1, y1, x2 - x1, y2 - y1).normalized(); } @@ -1797,8 +1797,9 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) if (path.shape() == QVectorPath::RectangleHint) { if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxScale) { const qreal *p = path.points(); - QPointF tl = QPointF(p[0], p[1]) * s->matrix; - QPointF br = QPointF(p[4], p[5]) * s->matrix; + const QPointF offs(aliasedCoordinateDelta, aliasedCoordinateDelta); + QPointF tl = QPointF(p[0], p[1]) * s->matrix + offs; + QPointF br = QPointF(p[4], p[5]) * s->matrix + offs; fillRect_normalized(toNormalizedFillRect(QRectF(tl, br)), &s->brushData, d); return; } @@ -2597,12 +2598,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe QRasterPaintEngineState *s = state(); const bool aa = s->flags.antialiased || s->flags.bilinear; 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 - 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; } -- cgit v0.12