summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2010-06-01 10:50:30 +0200
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2010-06-01 10:53:16 +0200
commit1b6d41deebdd8103e2d8abb53bd2bb1dd26bd0ae (patch)
tree828294f13c8f9dbd04a6d3f6b1adea007c7adb7c /src
parent7b581310ceb106664077052abeabbde217ea30dd (diff)
Fix bug in QGraphicsItem::scroll() when called with no QRectF argument.
With a null rect argument, QGraphicsItem::scroll() is supposed to scroll the whole item. When using ItemCoordinateCache, currently the only supported mode for scroll optimization, we simple scrolled the whole cache pixmap. Problem: The cache pixmap has a border of 2 pixels. So we scroll the contents _and_ the border. This leaves white/transparent horizontal and vertical line artifacts when scrolling. This change unifies the two cases - partial and full scrolling - into one (shorter) approach that works without scrolling the margin as well. Reviewed-by: Alexis Menard <alexis.menard@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index d284a29dbc..9d7354ac7b 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -5695,19 +5695,12 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
}
QPixmapCache::remove(cache->key);
+ QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
+ if (!scrollRect.intersects(cache->boundingRect))
+ return; // Nothing to scroll.
+
QRegion exposed;
- const bool scrollEntirePixmap = rect.isNull();
- if (scrollEntirePixmap) {
- // Scroll entire pixmap.
- cachedPixmap.scroll(dx, dy, cachedPixmap.rect(), &exposed);
- } else {
- if (!rect.intersects(cache->boundingRect))
- return; // Nothing to scroll.
- // Scroll sub-rect of pixmap. The rect is in item coordinates
- // so we have to translate it to pixmap coordinates.
- QRect scrollRect = rect.toAlignedRect();
- cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
- }
+ cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
// Reinsert into cache.
cache->key = QPixmapCache::insert(cachedPixmap);
@@ -5715,7 +5708,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
// Translate the existing expose.
for (int i = 0; i < cache->exposed.size(); ++i) {
QRectF &e = cache->exposed[i];
- if (!scrollEntirePixmap && !e.intersects(rect))
+ if (!rect.isNull() && !e.intersects(rect))
continue;
e.translate(dx, dy);
}