summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-03 05:50:33 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:32:24 (GMT)
commitb5d987298b0502dd593dd09d7e4e1233d6e30dd6 (patch)
tree88eb782bc2f3d34e756d119101e6cc05e818cd5e /src/gui/graphicsview
parent8af81877bb11d58099189bfab21d21e3021b7b8b (diff)
downloadQt-b5d987298b0502dd593dd09d7e4e1233d6e30dd6.zip
Qt-b5d987298b0502dd593dd09d7e4e1233d6e30dd6.tar.gz
Qt-b5d987298b0502dd593dd09d7e4e1233d6e30dd6.tar.bz2
Avoid constructing empty temporary QTransforms.
This is a microoptimization.
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h1
2 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 7bf58c3..188165d 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5110,29 +5110,28 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
}
// Calculate the full transform for this item.
- QTransform transform;
QRect viewBoundingRect;
bool wasDirtyParentSceneTransform = false;
if (item) {
if (item->d_ptr->itemIsUntransformable()) {
- transform = item->deviceTransform(viewTransform);
+ transformTmp = item->deviceTransform(viewTransform);
} else {
if (item->d_ptr->dirtySceneTransform) {
item->d_ptr->sceneTransform = item->d_ptr->parent ? item->d_ptr->parent->d_ptr->sceneTransform
- : transform;
+ : QTransform();
item->d_ptr->combineTransformFromParent(&item->d_ptr->sceneTransform);
item->d_ptr->dirtySceneTransform = 0;
wasDirtyParentSceneTransform = true;
}
- transform = item->d_ptr->sceneTransform;
- transform *= viewTransform;
+ transformTmp = item->d_ptr->sceneTransform;
+ transformTmp *= viewTransform;
}
-
+
QRectF brect = item->boundingRect();
if (!brect.size().isNull()) {
// ### This does not take the clip into account.
_q_adjustRect(&brect);
- viewBoundingRect = transform.mapRect(brect).toRect().adjusted(-1, -1, 1, 1);
+ viewBoundingRect = transformTmp.mapRect(brect).toRect().adjusted(-1, -1, 1, 1);
item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
if (exposedRegion)
viewBoundingRect &= exposedRegion->boundingRect();
@@ -5149,7 +5148,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
// Clip children.
if (childClip) {
painter->save();
- painter->setWorldTransform(transform);
+ painter->setWorldTransform(transformTmp);
painter->setClipPath(item->shape(), Qt::IntersectClip);
}
@@ -5181,14 +5180,14 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
// Draw item
if (!dontDrawItem) {
- item->d_ptr->initStyleOption(&styleOptionTmp, transform, exposedRegion ? *exposedRegion : QRegion(), exposedRegion == 0);
+ item->d_ptr->initStyleOption(&styleOptionTmp, transformTmp, exposedRegion ? *exposedRegion : QRegion(), exposedRegion == 0);
bool clipsToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsToShape);
bool savePainter = clipsToShape || !(optimizationFlags & QGraphicsView::DontSavePainterState);
if (savePainter)
painter->save();
if (!childClip)
- painter->setWorldTransform(transform);
+ painter->setWorldTransform(transformTmp);
if (clipsToShape)
painter->setClipPath(item->shape(), Qt::IntersectClip);
painter->setOpacity(opacity);
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index e0c48a6..8bc25b6 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -287,6 +287,7 @@ public:
void updatePalette(const QPalette &palette);
QStyleOptionGraphicsItem styleOptionTmp;
+ QTransform transformTmp;
};
QT_END_NAMESPACE