From d04f5336f769d9e5d2f9105e1da4a7d23ea91795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 1 Mar 2010 15:08:26 +0100 Subject: Fixed qDrawPixmaps() to draw on integer coordinates on Mac OS X. For some reason, doing a QPainter::translate(-0.5, 0) and then QPainter::drawPixmap(0.5, 0, ...) doesn't result in a zero transformation on Mac OS X. This is a workaround where we calculate the device coords ourselves if it's only a simple translate operation. Task-number: QTBUG-8455 Reviewed-by: Kim --- src/gui/painting/qdrawutil.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 5619a2e..35bf2bf 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1361,14 +1361,21 @@ void qDrawPixmaps(QPainter *painter, const QDrawPixmaps::Data *drawingData, int for (int i = 0; i < dataCount; ++i) { QTransform transform = oldTransform; - transform.translate(drawingData[i].point.x(), drawingData[i].point.y()); - transform.rotate(drawingData[i].rotation); - painter->setOpacity(oldOpacity * drawingData[i].opacity); + qreal xOffset = 0; + qreal yOffset = 0; + if (drawingData[i].rotation == 0) { + xOffset = drawingData[i].point.x(); + yOffset = drawingData[i].point.y(); + } else { + transform.translate(drawingData[i].point.x(), drawingData[i].point.y()); + transform.rotate(drawingData[i].rotation); + } painter->setTransform(transform); + painter->setOpacity(oldOpacity * drawingData[i].opacity); qreal w = drawingData[i].scaleX * drawingData[i].source.width(); qreal h = drawingData[i].scaleY * drawingData[i].source.height(); - painter->drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, drawingData[i].source); + painter->drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, drawingData[i].source); } painter->setOpacity(oldOpacity); -- cgit v0.12