diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-03 05:35:06 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:32:18 (GMT) |
commit | 8af81877bb11d58099189bfab21d21e3021b7b8b (patch) | |
tree | ea17960b08a13715fc86d8be91a6fb847d55d0cc | |
parent | 062b7b1280ef228567d16187951fe43e2ac0f78c (diff) | |
download | Qt-8af81877bb11d58099189bfab21d21e3021b7b8b.zip Qt-8af81877bb11d58099189bfab21d21e3021b7b8b.tar.gz Qt-8af81877bb11d58099189bfab21d21e3021b7b8b.tar.bz2 |
Add QGraphicsView::isTransformed(), and use it to avoid view transforms.
Ensure that we don't ask for or multiply with the view transform if the
view is not transformed.
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 10 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 12 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.h | 1 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 2773bdd..7bf58c3 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5314,10 +5314,12 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item) viewPrivate->updateRect(item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport)); QTransform deviceTransform = item->d_ptr->sceneTransform; - if (!untransformableItem) - deviceTransform *= view->viewportTransform(); - else - deviceTransform = item->deviceTransform(view->viewportTransform()); + if (view->isTransformed()) { + if (!untransformableItem) + deviceTransform *= view->viewportTransform(); + else + deviceTransform = item->deviceTransform(view->viewportTransform()); + } if (item->d_ptr->hasBoundingRegionGranularity) viewPrivate->updateRegion(deviceTransform.map(QRegion(dirtyRect.toRect()))); else diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index e9a432e..c91e0d1 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3555,6 +3555,18 @@ QTransform QGraphicsView::viewportTransform() const } /*! + Returns true if the view is transformed (i.e., a non-identity transform + has been assigned, or the scrollbars are adjusted). + + \sa setTransform(), horizontalScrollBar(), verticalScrollBar() +*/ +bool QGraphicsView::isTransformed() const +{ + Q_D(const QGraphicsView); + return !d->identityMatrix || d->horizontalScroll() || d->verticalScroll(); +} + +/*! Sets the view's current transformation matrix to \a matrix. If \a combine is true, then \a matrix is combined with the current matrix; diff --git a/src/gui/graphicsview/qgraphicsview.h b/src/gui/graphicsview/qgraphicsview.h index b7a9906..387fa01 100644 --- a/src/gui/graphicsview/qgraphicsview.h +++ b/src/gui/graphicsview/qgraphicsview.h @@ -170,6 +170,7 @@ public: void resetMatrix(); QTransform transform() const; QTransform viewportTransform() const; + bool isTransformed() const; void setTransform(const QTransform &matrix, bool combine = false); void resetTransform(); void rotate(qreal angle); |