summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-05-12 10:47:07 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-05-21 13:19:04 (GMT)
commitabc0bd321356907dafc4a5cbca57a335a9f6ae3e (patch)
tree780148556f72bff96ad1a906ece1562bd5f350bb /src/gui/graphicsview
parent4b1ddaa519c3fcf20cd1627fa8d580ebe6cafd4f (diff)
downloadQt-abc0bd321356907dafc4a5cbca57a335a9f6ae3e.zip
Qt-abc0bd321356907dafc4a5cbca57a335a9f6ae3e.tar.gz
Qt-abc0bd321356907dafc4a5cbca57a335a9f6ae3e.tar.bz2
Fixes wrong QGraphicsItemCache::boundingRect.
The boundingRect were in some cases not updated correctly, causing full item exposure. Another problem was that we used QRectF::toRect() instead of QRectF::toAlignedRect() when converting a QRectF to QRect. This commit also reduces the probability of doing pixmap scaling since we only pass an offset to QPainter::drawPixmap, instead of passing target and source rects. Task-number: Required by QTBUG-8378
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 4b09a7e..344df30 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4372,11 +4372,6 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
bool pixmapFound;
QGraphicsItemCache *itemCache = itemd->extraItemCache();
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
- if (itemCache->boundingRect != brect.toRect()) {
- itemCache->boundingRect = brect.toRect();
- itemCache->allExposed = true;
- itemCache->exposed.clear();
- }
pixmapKey = itemCache->key;
} else {
pixmapKey = itemCache->deviceData.value(widget).key;
@@ -4389,19 +4384,24 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
QSize pixmapSize;
bool fixedCacheSize = false;
- QRectF brectAligned = brect.toAlignedRect();
+ QRect br = brect.toAlignedRect();
if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
pixmapSize = itemCache->fixedSize;
} else {
- pixmapSize = brectAligned.size().toSize();
+ pixmapSize = br.size();
}
// Create or recreate the pixmap.
int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
QSize adjustSize(adjust*2, adjust*2);
- QRectF br = brectAligned.adjusted(-adjust, -adjust, adjust, adjust);
+ br.adjust(-adjust, -adjust, adjust, adjust);
if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
pix = QPixmap(pixmapSize + adjustSize);
+ itemCache->boundingRect = br;
+ itemCache->exposed.clear();
+ itemCache->allExposed = true;
+ } else if (itemCache->boundingRect != br) {
+ itemCache->boundingRect = br;
itemCache->exposed.clear();
itemCache->allExposed = true;
}
@@ -4455,10 +4455,10 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// qpixmap-image-transform-pixmap roundtrip.
if (newPainterOpacity != oldPainterOpacity) {
painter->setOpacity(newPainterOpacity);
- painter->drawPixmap(br, pix, QRectF(QPointF(), pix.size()));
+ painter->drawPixmap(br.topLeft(), pix);
painter->setOpacity(oldPainterOpacity);
} else {
- painter->drawPixmap(br, pix, QRectF(QPointF(), pix.size()));
+ painter->drawPixmap(br.topLeft(), pix);
}
return;
}