summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-18 14:53:35 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-18 15:00:53 (GMT)
commit40fef756b1e27aaceead7baaf3225c023f0da121 (patch)
tree66a32b2b1b77e34218923a30679e9b18e25aaeda /src
parente51e71cc3f7b79f2e87888f298eb8968a1929fe0 (diff)
downloadQt-40fef756b1e27aaceead7baaf3225c023f0da121.zip
Qt-40fef756b1e27aaceead7baaf3225c023f0da121.tar.gz
Qt-40fef756b1e27aaceead7baaf3225c023f0da121.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp18
1 files 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;
}