diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-03 15:06:24 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-06-09 07:33:17 (GMT) |
commit | b6b0469e2d3aba2a163fab8c4b2fda4ab775b7f7 (patch) | |
tree | 5ce445d6bc9ce26911f79ab36494e4783027eee9 /src | |
parent | 728179ed60b43187d28c77a2d6930a74a62791d6 (diff) | |
download | Qt-b6b0469e2d3aba2a163fab8c4b2fda4ab775b7f7.zip Qt-b6b0469e2d3aba2a163fab8c4b2fda4ab775b7f7.tar.gz Qt-b6b0469e2d3aba2a163fab8c4b2fda4ab775b7f7.tar.bz2 |
Add BSP tree support to the recursive drawing algorithm.
The code looks ugly and needs to be refactored, but at least this
reintroduces the BSP so the chip demo works fine again.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 96800a3..7a6c21c 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5167,22 +5167,49 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * } // Find and sort children. - QList<QGraphicsItem *> &children = item ? item->d_ptr->children : (topLevelItems ? *topLevelItems : this->topLevelItems); + QList<QGraphicsItem *> tmp; + QList<QGraphicsItem *> *children = 0; + if (item) { + children = &item->d_ptr->children; + } else if (topLevelItems) { + children = topLevelItems; + } else if (indexMethod == QGraphicsScene::NoIndex || !exposedRegion) { + children = &this->topLevelItems; + } else { + tmp = estimateItemsInRect(viewTransform.inverted().mapRect(exposedRegion->boundingRect())); + + QList<QGraphicsItem *> tli; + for (int i = 0; i < tmp.size(); ++i) { + QGraphicsItem *it = tmp.at(i)->topLevelItem(); + if (!it->d_ptr->itemDiscovered) { + tli << it; + it->d_ptr->itemDiscovered = 1; + } + } + for (int i = 0; i < tli.size(); ++i) + tli.at(i)->d_ptr->itemDiscovered = 0; + + tmp = tli; + children = &tmp; + } + if (!dontDrawChildren) { if (item && item->d_ptr->needSortChildren) { item->d_ptr->needSortChildren = 0; - qStableSort(children.begin(), children.end(), qt_notclosestLeaf); + qStableSort(children->begin(), children->end(), qt_notclosestLeaf); } else if (!item && needSortTopLevelItems) { needSortTopLevelItems = false; - qStableSort(children.begin(), children.end(), qt_notclosestLeaf); + qStableSort(children->begin(), children->end(), qt_notclosestLeaf); + } else if (!item && children == &tmp) { + qStableSort(children->begin(), children->end(), qt_notclosestLeaf); } } // Draw children behind int i = 0; if (!dontDrawChildren) { - for (i = 0; i < children.size(); ++i) { - QGraphicsItem *child = children.at(i); + for (i = 0; i < children->size(); ++i) { + QGraphicsItem *child = children->at(i); if (wasDirtyParentSceneTransform) child->d_ptr->dirtySceneTransform = 1; if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent)) @@ -5213,8 +5240,8 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * // Draw children in front if (!dontDrawChildren) { - for (; i < children.size(); ++i) { - QGraphicsItem *child = children.at(i); + for (; i < children->size(); ++i) { + QGraphicsItem *child = children->at(i); if (wasDirtyParentSceneTransform) child->d_ptr->dirtySceneTransform = 1; drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, |