diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-05-29 12:40:32 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:29:43 (GMT) |
commit | a10e4b983e228284202df536846e6b6d4a8cf40e (patch) | |
tree | 589d3de80233d9196bcc5f032361b88e61649826 | |
parent | 669679d389ff0585bad30d41b085a4189d0e7a91 (diff) | |
download | Qt-a10e4b983e228284202df536846e6b6d4a8cf40e.zip Qt-a10e4b983e228284202df536846e6b6d4a8cf40e.tar.gz Qt-a10e4b983e228284202df536846e6b6d4a8cf40e.tar.bz2 |
Simplify the QTransform calculations.
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a5ac9d9..434cc8e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5059,28 +5059,18 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * return; // Calculate the full transform for this item. - QTransform transform; + QTransform transform = parentTransform; QRect viewBoundingRect; if (item) { if (!item->d_ptr->hasValidDeviceTransform) { - if (item->d_ptr->itemIsUntransformable()) { - transform = item->deviceTransform(viewTransform); - } else { - const QPointF &pos = item->d_ptr->pos; - bool posNull = pos.isNull(); - if (!posNull || item->d_ptr->transform) { - if (item->d_ptr->transform) { - QTransform x = *item->d_ptr->transform; - if (!posNull) - x *= QTransform::fromTranslate(pos.x(), pos.y()); - transform = x * parentTransform; - } else { - transform = QTransform::fromTranslate(pos.x(), pos.y()) * parentTransform; - } + if (item->d_ptr->itemIsUntransformable()) { + transform = item->deviceTransform(viewTransform); } else { - transform = parentTransform; + const QPointF &pos = item->d_ptr->pos; + transform.translate(pos.x(), pos.y()); + if (item->d_ptr->transform) + transform = *item->d_ptr->transform * transform; } - } } else { transform = item->d_ptr->deviceTransform; item->d_ptr->hasValidDeviceTransform = 0; @@ -5093,8 +5083,6 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * item->d_ptr->paintedViewBoundingRects.insert(widget, paintedViewBoundingRect); viewBoundingRect = paintedViewBoundingRect & exposedRegion.boundingRect(); } - } else { - transform = parentTransform; } bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)); @@ -5215,28 +5203,16 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, cons Q_ASSERT(!item || item->d_ptr->dirty || item->d_ptr->dirtyChildren); // Calculate the full transform for this item. - QTransform transform; + QTransform transform = parentTransform; if (item) { if (item->d_ptr->itemIsUntransformable()) { transform = item->deviceTransform(views.at(0)->viewportTransform()); } else { const QPointF &pos = item->d_ptr->pos; - bool posNull = pos.isNull(); - if (!posNull || item->d_ptr->transform) { - if (item->d_ptr->transform) { - transform = *item->d_ptr->transform; - if (!posNull) - transform *= QTransform::fromTranslate(pos.x(), pos.y()); - transform *= parentTransform; - } else { - transform = QTransform::fromTranslate(pos.x(), pos.y()) * parentTransform; - } - } else { - transform = parentTransform; - } + transform.translate(pos.x(), pos.y()); + if (item->d_ptr->transform) + transform = *item->d_ptr->transform * transform; } - } else { - transform = parentTransform; } // Process item. |