summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-06-18 15:31:28 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-06-18 15:31:28 (GMT)
commit1fa6b99c373e0dab9e0a0b7f190e3085190be668 (patch)
tree1c5181e125a7ebae7b10d8a3fbb53e1cf0e63b3a /src/gui/graphicsview
parenta18e5288324aa13da014ee52daffbfc589c87be3 (diff)
parentf9f08de9d41fd55d9c7d01578191ef5d4099c9e6 (diff)
downloadQt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.zip
Qt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.tar.gz
Qt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qt-main/qgraphicssceneindex
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h16
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp114
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h5
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp79
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h4
6 files changed, 145 insertions, 87 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 75683d8..050aace 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -978,7 +978,8 @@ void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rec
bool hasPos = !childd->pos.isNull();
if (hasPos || childd->transformData) {
// COMBINE
- QTransform matrix = childd->transformToParent() * *x;
+ QTransform matrix = childd->transformToParent();
+ matrix *= *x;
*rect |= matrix.mapRect(child->boundingRect());
if (!childd->children.isEmpty())
childd->childrenBoundingRectHelper(&matrix, rect);
@@ -3195,8 +3196,7 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c
QPointF mappedPoint = (untransformedAncestor->sceneTransform() * viewportTransform).map(QPointF(0, 0));
// COMBINE
- QTransform matrix;
- matrix.translate(mappedPoint.x(), mappedPoint.y());
+ QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());
if (untransformedAncestor->d_ptr->transformData)
matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
@@ -3294,9 +3294,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
bool cousins = other != commonAncestor && this != commonAncestor;
if (cousins) {
bool good = false;
- QTransform thisToScene;
- QTransform otherToScene;
- thisToScene = itemTransform(commonAncestor, &good);
+ QTransform thisToScene = itemTransform(commonAncestor, &good);
+ QTransform otherToScene(Qt::Uninitialized);
if (good)
otherToScene = other->itemTransform(commonAncestor, &good);
if (!good) {
@@ -4143,8 +4142,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
p.end();
// Transform QRegion back to device space
- QTransform unscale;
- unscale.scale(1 / granularity, 1 / granularity);
+ QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
QRegion r;
QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
foreach (const QRect &rect, QRegion( colorMask ).rects()) {
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 1c95a62..1dfb140 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -55,6 +55,7 @@
#include "qgraphicsitem.h"
#include "qpixmapcache.h"
+#include "qgraphicsview_p.h"
#include <QtCore/qpoint.h>
@@ -150,6 +151,8 @@ public:
geometryChanged(0),
inDestructor(0),
isObject(0),
+ ignoreVisible(0),
+ ignoreOpacity(0),
globalStackingOrder(-1),
q_ptr(0)
{
@@ -336,6 +339,15 @@ public:
return calcEffectiveOpacity();
}
+ inline qreal combineOpacityFromParent(qreal parentOpacity) const
+ {
+ if (parent && !(flags & QGraphicsItem::ItemIgnoresParentOpacity)
+ && !(parent->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) {
+ return parentOpacity * opacity;
+ }
+ return opacity;
+ }
+
inline bool childrenCombineOpacity() const
{
if (!children.size())
@@ -416,7 +428,9 @@ public:
quint32 geometryChanged : 1;
quint32 inDestructor : 1;
quint32 isObject : 1;
- quint32 unused : 14; // feel free to use
+ quint32 ignoreVisible : 1;
+ quint32 ignoreOpacity : 1;
+ quint32 unused : 12; // feel free to use
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 28dd3be..2f7ae04 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4060,14 +4060,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (item) {
if (!item->d_ptr->visible)
return;
- QGraphicsItem *p = item->d_ptr->parent;
- bool itemIgnoresParentOpacity = item->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity;
- bool parentDoesntPropagateOpacity = (p && (p->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren));
- if (!itemIgnoresParentOpacity && !parentDoesntPropagateOpacity) {
- opacity = parentOpacity * item->opacity();
- } else {
- opacity = item->d_ptr->opacity;
- }
+ opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
if (opacity == 0.0 && !(item->d_ptr->flags & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)) {
invisibleButChildIgnoresParentOpacity = !item->d_ptr->childrenCombineOpacity();
if (!invisibleButChildIgnoresParentOpacity)
@@ -4084,7 +4077,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
// Calculate the full transform for this item.
bool wasDirtyParentSceneTransform = false;
bool dontDrawItem = true;
- QTransform transform;
+ QTransform transform(Qt::Uninitialized);
if (item) {
if (item->d_ptr->itemIsUntransformable()) {
transform = item->deviceTransform(viewTransform);
@@ -4207,7 +4200,11 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (clipsToShape)
painter->setClipPath(item->shape(), Qt::IntersectClip);
painter->setOpacity(opacity);
- drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
+
+ if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
+ item->paint(painter, &styleOptionTmp, widget);
+ else
+ drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
if (savePainter)
painter->restore();
@@ -4291,6 +4288,11 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b
item->d_ptr->dirtyChildren = 1;
}
+ if (force)
+ item->d_ptr->ignoreVisible = 1;
+ if (ignoreOpacity)
+ item->d_ptr->ignoreOpacity = 1;
+
QGraphicsItem *p = item->d_ptr->parent;
while (p && !p->d_ptr->dirtyChildren) {
p->d_ptr->dirtyChildren = 1;
@@ -4298,34 +4300,58 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b
}
}
-void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren)
+static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item,
+ const QRectF &rect, const QTransform &xform)
+{
+ Q_ASSERT(view);
+ Q_ASSERT(item);
+ if (item->hasBoundingRegionGranularity)
+ return view->updateRegion(xform.map(QRegion(rect.toRect())));
+ return view->updateRect(xform.mapRect(rect).toRect());
+}
+
+void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren,
+ qreal parentOpacity)
{
Q_Q(QGraphicsScene);
- // Calculate the full scene transform for this item.
+ bool wasDirtyParentViewBoundingRects = false;
bool wasDirtyParentSceneTransform = false;
- if (item && item->d_ptr->dirtySceneTransform && !item->d_ptr->itemIsUntransformable()) {
- item->d_ptr->sceneTransform = item->d_ptr->parent ? item->d_ptr->parent->d_ptr->sceneTransform
- : QTransform();
- item->d_ptr->combineTransformFromParent(&item->d_ptr->sceneTransform);
- item->d_ptr->dirtySceneTransform = 0;
- wasDirtyParentSceneTransform = true;
+ qreal opacity = parentOpacity;
+
+ if (item) {
+ wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;
+ opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
+ const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible;
+ const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity && opacity == 0.0;
+
+ if (item->d_ptr->dirtySceneTransform && !itemIsHidden && !item->d_ptr->itemIsUntransformable()
+ && !(itemIsFullyTransparent && item->d_ptr->childrenCombineOpacity())) {
+ // Calculate the full scene transform for this item.
+ item->d_ptr->sceneTransform = item->d_ptr->parent ? item->d_ptr->parent->d_ptr->sceneTransform
+ : QTransform();
+ item->d_ptr->combineTransformFromParent(&item->d_ptr->sceneTransform);
+ item->d_ptr->dirtySceneTransform = 0;
+ wasDirtyParentSceneTransform = true;
+ }
+
+ if (itemIsHidden || itemIsFullyTransparent || (item->d_ptr->flags & QGraphicsItem::ItemHasNoContents)) {
+ // Make sure we don't process invisible items or items with no content.
+ item->d_ptr->dirty = 0;
+ item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
+ }
}
// Process item.
- bool wasDirtyParentViewBoundingRects = false;
if (item && (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint)) {
const bool useCompatUpdate = views.isEmpty() || (connectedSignals & changedSignalMask);
const bool untransformableItem = item->d_ptr->itemIsUntransformable();
- const QRectF itemBoundingRect = item->boundingRect();
+ const QRectF itemBoundingRect = adjustedItemBoundingRect(item);
if (item->d_ptr->geometryChanged) {
// Update growingItemsBoundingRect.
- if (!hasSceneRect) {
- QRectF itemSceneBoundingRect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
- _q_adjustRect(&itemSceneBoundingRect);
- growingItemsBoundingRect |= itemSceneBoundingRect;
- }
+ if (!hasSceneRect)
+ growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
item->d_ptr->geometryChanged = 0;
}
@@ -4354,11 +4380,12 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
break;
}
+ QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];
if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
wasDirtyParentViewBoundingRects = true;
- QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);
- rect.translate(viewPrivate->dirtyScrollOffset);
- viewPrivate->updateRect(rect);
+ paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);
+ if (!viewPrivate->updateRect(paintedViewBoundingRect))
+ paintedViewBoundingRect = QRect();
}
if (!item->d_ptr->dirty)
@@ -4366,7 +4393,6 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
if (uninitializedDirtyRect) {
dirtyRect = itemBoundingRect;
- _q_adjustRect(&dirtyRect);
if (!item->d_ptr->fullUpdatePending) {
_q_adjustRect(&item->d_ptr->needsRepaint);
dirtyRect &= item->d_ptr->needsRepaint;
@@ -4377,17 +4403,19 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
if (dirtyRect.isEmpty())
continue; // Discard updates outside the bounding rect.
- QTransform deviceTransform = item->d_ptr->sceneTransform;
- if (view->isTransformed()) {
- if (!untransformableItem)
- deviceTransform *= view->viewportTransform();
- else
- deviceTransform = item->deviceTransform(view->viewportTransform());
+ bool valid = false;
+ if (untransformableItem) {
+ valid = updateHelper(viewPrivate, item->d_ptr, dirtyRect,
+ item->deviceTransform(view->viewportTransform()));
+ } else if (!view->isTransformed()) {
+ valid = updateHelper(viewPrivate, item->d_ptr, dirtyRect, item->d_ptr->sceneTransform);
+ } else {
+ QTransform deviceTransform = item->d_ptr->sceneTransform;
+ deviceTransform *= view->viewportTransform();
+ valid = updateHelper(viewPrivate, item->d_ptr, dirtyRect, deviceTransform);
}
- if (item->d_ptr->hasBoundingRegionGranularity)
- viewPrivate->updateRegion(deviceTransform.map(QRegion(dirtyRect.toRect())));
- else
- viewPrivate->updateRect(deviceTransform.mapRect(dirtyRect).toRect());
+ if (!valid)
+ paintedViewBoundingRect = QRect();
}
}
}
@@ -4400,12 +4428,18 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
dirtyAncestorContainsChildren = item && item->d_ptr->fullUpdatePending
&& (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
}
+ const bool parentIgnoresVisible = item && item->d_ptr->ignoreVisible;
+ const bool parentIgnoresOpacity = item && item->d_ptr->ignoreOpacity;
for (int i = 0; i < children->size(); ++i) {
QGraphicsItem *child = children->at(i);
if (wasDirtyParentSceneTransform)
child->d_ptr->dirtySceneTransform = 1;
if (wasDirtyParentViewBoundingRects)
child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
+ if (parentIgnoresVisible)
+ child->d_ptr->ignoreVisible = 1;
+ if (parentIgnoresOpacity)
+ child->d_ptr->ignoreOpacity = 1;
if (allChildrenDirty) {
child->d_ptr->dirty = 1;
@@ -4428,7 +4462,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
child->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
}
- processDirtyItemsRecursive(child, dirtyAncestorContainsChildren);
+ processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);
}
} else if (wasDirtyParentSceneTransform) {
item->d_ptr->invalidateChildrenSceneTransform();
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index fd25283..ea65707 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -198,7 +198,8 @@ public:
void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false,
bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false,
bool removingItemFromScene = false);
- void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false);
+ void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false,
+ qreal parentOpacity = qreal(1.0));
inline void resetDirtyItem(QGraphicsItem *item)
{
@@ -210,6 +211,8 @@ public:
item->d_ptr->needsRepaint = QRectF();
item->d_ptr->allChildrenDirty = 0;
item->d_ptr->fullUpdatePending = 0;
+ item->d_ptr->ignoreVisible = 0;
+ item->d_ptr->ignoreOpacity = 0;
}
QStyle *style;
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a1e6d9c..ec1746a 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -815,19 +815,22 @@ void QGraphicsViewPrivate::processPendingUpdates()
dirtyRegion = QRegion();
}
-void QGraphicsViewPrivate::updateRegion(const QRegion &r)
+bool QGraphicsViewPrivate::updateRegion(const QRegion &r)
{
- if (r.isEmpty() || fullUpdatePending)
- return;
+ if (fullUpdatePending || viewportUpdateMode == QGraphicsView::NoViewportUpdate || r.isEmpty())
+ return false;
+
+ const QRect boundingRect = r.boundingRect();
+ if (!boundingRect.intersects(viewport->rect()))
+ return false; // Update region outside viewport.
- // Rect intersects viewport - update everything?
switch (viewportUpdateMode) {
case QGraphicsView::FullViewportUpdate:
fullUpdatePending = true;
viewport->update();
break;
case QGraphicsView::BoundingRectViewportUpdate:
- dirtyBoundingRect |= r.boundingRect();
+ dirtyBoundingRect |= boundingRect;
if (dirtyBoundingRect.contains(viewport->rect())) {
fullUpdatePending = true;
viewport->update();
@@ -845,18 +848,20 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r)
}
break;
}
- case QGraphicsView::NoViewportUpdate:
- // Unreachable
+ default:
break;
}
+
+ return true;
}
-void QGraphicsViewPrivate::updateRect(const QRect &r)
+bool QGraphicsViewPrivate::updateRect(const QRect &r)
{
- if (r.isEmpty() || fullUpdatePending)
- return;
+ if (fullUpdatePending || viewportUpdateMode == QGraphicsView::NoViewportUpdate
+ || !r.intersects(viewport->rect())) {
+ return false;
+ }
- // Rect intersects viewport - update everything?
switch (viewportUpdateMode) {
case QGraphicsView::FullViewportUpdate:
fullUpdatePending = true;
@@ -876,10 +881,11 @@ void QGraphicsViewPrivate::updateRect(const QRect &r)
else
dirtyRegion += r.adjusted(-2, -2, 2, 2);
break;
- case QGraphicsView::NoViewportUpdate:
- // Unreachable
+ default:
break;
}
+
+ return true;
}
QStyleOptionGraphicsItem *QGraphicsViewPrivate::allocStyleOptionsArray(int numItems)
@@ -1904,8 +1910,7 @@ void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect
itemList.clear();
// Setup painter matrix.
- QTransform moveMatrix;
- moveMatrix.translate(-d->horizontalScroll(), -d->verticalScroll());
+ QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
QTransform painterMatrix = d->matrix * moveMatrix;
painterMatrix *= QTransform()
.translate(targetRect.left(), targetRect.top())
@@ -2187,9 +2192,9 @@ QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const
QPainterPath QGraphicsView::mapToScene(const QPainterPath &path) const
{
Q_D(const QGraphicsView);
- QTransform moveMatrix;
- moveMatrix.translate(d->horizontalScroll(), d->verticalScroll());
- return (moveMatrix * d->matrix.inverted()).map(path);
+ QTransform matrix = QTransform::fromTranslate(d->horizontalScroll(), d->verticalScroll());
+ matrix *= d->matrix.inverted();
+ return matrix.map(path);
}
/*!
@@ -2283,9 +2288,9 @@ QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const
QPainterPath QGraphicsView::mapFromScene(const QPainterPath &path) const
{
Q_D(const QGraphicsView);
- QTransform moveMatrix;
- moveMatrix.translate(-d->horizontalScroll(), -d->verticalScroll());
- return (d->matrix * moveMatrix).map(path);
+ QTransform matrix = d->matrix;
+ matrix *= QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
+ return matrix.map(path);
}
/*!
@@ -3129,10 +3134,6 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
// Determine the exposed region
d->exposedRegion = event->region();
- if (!d->accelerateScrolling)
- d->exposedRegion = viewport()->rect();
- else if (d->viewportUpdateMode == BoundingRectViewportUpdate)
- d->exposedRegion = event->rect();
QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect();
// Set up the painter
@@ -3146,8 +3147,10 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
painter.setRenderHints(d->renderHints, true);
// Set up viewport transform
- const QTransform viewTransform = viewportTransform();
- painter.setWorldTransform(viewTransform);
+ const bool viewTransformed = isTransformed();
+ if (viewTransformed)
+ painter.setWorldTransform(viewportTransform());
+ const QTransform viewTransform = painter.worldTransform();
// Draw background
if ((d->cacheMode & CacheBackground)
@@ -3172,16 +3175,21 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
if (!d->backgroundPixmapExposed.isEmpty()) {
QPainter backgroundPainter(&d->backgroundPixmap);
backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip);
- backgroundPainter.setTransform(viewportTransform());
+ if (viewTransformed)
+ backgroundPainter.setTransform(viewTransform);
backgroundPainter.setCompositionMode(QPainter::CompositionMode_Source);
drawBackground(&backgroundPainter, exposedSceneRect);
d->backgroundPixmapExposed = QRegion();
}
// Blit the background from the background pixmap
- painter.setWorldTransform(QTransform());
- painter.drawPixmap(QPoint(), d->backgroundPixmap);
- painter.setWorldTransform(viewTransform);
+ if (viewTransformed) {
+ painter.setWorldTransform(QTransform());
+ painter.drawPixmap(QPoint(), d->backgroundPixmap);
+ painter.setWorldTransform(viewTransform);
+ } else {
+ painter.drawPixmap(QPoint(), d->backgroundPixmap);
+ }
} else {
if (!(d->optimizationFlags & DontSavePainterState))
painter.save();
@@ -3204,8 +3212,10 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
const int numItems = itemList.size();
QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
- for (int i = 0; i < numItems; ++i)
- itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems);
+ for (int i = 0; i < numItems; ++i) {
+ itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], viewTransform,
+ d->exposedRegion, allItems);
+ }
// Draw the items.
drawItems(&painter, numItems, itemArray, styleOptionArray);
d->freeStyleOptionsArray(styleOptionArray);
@@ -3444,8 +3454,7 @@ QTransform QGraphicsView::transform() const
QTransform QGraphicsView::viewportTransform() const
{
Q_D(const QGraphicsView);
- QTransform moveMatrix;
- moveMatrix.translate(-d->horizontalScroll(), -d->verticalScroll());
+ QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
return d->identityMatrix ? moveMatrix : d->matrix * moveMatrix;
}
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 760f54e..d0c5e6e 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -167,8 +167,8 @@ public:
dirtyBoundingRect = QRect();
dirtyRegion = QRegion();
}
- void updateRect(const QRect &rect);
- void updateRegion(const QRegion &region);
+ bool updateRect(const QRect &rect);
+ bool updateRegion(const QRegion &region);
bool updateSceneSlotReimplementedChecked;
QRegion exposedRegion;