diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-02 09:26:30 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:30:37 (GMT) |
commit | 1fc2406f35594706a9aafa9374694cf0a65cee30 (patch) | |
tree | c9182e121a12db04681e10a5fbde87903ea55643 /src/gui/graphicsview/qgraphicsscene.cpp | |
parent | bc3804458f29c8f13426ef53fcbacbf0877fc896 (diff) | |
download | Qt-1fc2406f35594706a9aafa9374694cf0a65cee30.zip Qt-1fc2406f35594706a9aafa9374694cf0a65cee30.tar.gz Qt-1fc2406f35594706a9aafa9374694cf0a65cee30.tar.bz2 |
Refactor QTransform combining code, and mark all code that combines.
This change introduces two helper functions in QGraphicsItemPrivate,
that combine the item's transform into the current transform, effectively
merging the code that calculates any item's combined to-parent transform.
This makes the code more readable, and also makes it easier for us to
reintroduce the componentized transform API in QGraphicsItem (which
was previously reverted).
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscene.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 30c7f97..b1d1742 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5075,14 +5075,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * 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; - transform.translate(pos.x(), pos.y()); - if (item->d_ptr->transform) - transform = *item->d_ptr->transform * transform; - } + item->d_ptr->combineTransformFromParent(&transform, &viewTransform); } else { transform = item->d_ptr->deviceTransform; item->d_ptr->hasValidDeviceTransform = 0; @@ -5226,12 +5219,10 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, cons QTransform transform = parentTransform; if (item) { if (item->d_ptr->itemIsUntransformable()) { - transform = item->deviceTransform(views.at(0)->viewportTransform()); + QTransform x = views.at(0)->viewportTransform(); + item->d_ptr->combineTransformFromParent(&transform, &x); } else { - const QPointF &pos = item->d_ptr->pos; - transform.translate(pos.x(), pos.y()); - if (item->d_ptr->transform) - transform = *item->d_ptr->transform * transform; + item->d_ptr->combineTransformFromParent(&transform); } } @@ -5325,8 +5316,16 @@ void QGraphicsScene::drawItems(QPainter *painter, QTransform viewTransform = painter->worldTransform(); Q_UNUSED(options); - // Draw each toplevel recursively. + // Determine view, expose and flags. QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; + QRegion expose; + QGraphicsView::OptimizationFlags flags; + if (view) { + expose = view->d_func()->exposedRegion; + flags = view->optimizationFlags(); + } + + // Draw each toplevel recursively. QList<QGraphicsItem *> topLevelItems; for (int i = 0; i < numItems; ++i) { QGraphicsItem *item = items[i]->topLevelItem(); @@ -5335,8 +5334,7 @@ void QGraphicsScene::drawItems(QPainter *painter, if (!item->d_ptr->itemDiscovered) { item->d_ptr->itemDiscovered = 1; d->drawSubtreeRecursive(item, painter, viewTransform, viewTransform, - view->d_func()->exposedRegion, widget, - view->optimizationFlags()); + expose, widget, flags); } } |