diff options
author | Bjoern Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-03-03 12:30:33 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-04-15 10:16:22 (GMT) |
commit | 920e77d9da68643aae483838b21330d032c00058 (patch) | |
tree | 87d4e62781096d30c00c0ba10324fb45c656e430 | |
parent | 06244063a852e4d8b8d2d5641ae65ddcd83150c7 (diff) | |
download | Qt-920e77d9da68643aae483838b21330d032c00058.zip Qt-920e77d9da68643aae483838b21330d032c00058.tar.gz Qt-920e77d9da68643aae483838b21330d032c00058.tar.bz2 |
Fixes: Small optimization in QGraphicsItem::clipPath().
RevBy: Andreas
Details: Use QPainterPath::addRect() rather than addPolygon() and
closeSubPath().
(cherry picked from commit b67dffcccea9166918ac93c281d87fd5eb3baf84)
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 6169d6a..9b6dfde 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3259,8 +3259,8 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection return false; } - QRectF rectA = _q_adjustedRect(boundingRect()); - QRectF rectB = _q_adjustedRect(path.controlPointRect()); + const QRectF rectA = _q_adjustedRect(boundingRect()); + const QRectF rectB = _q_adjustedRect(path.controlPointRect()); if (!rectA.intersects(rectB)) { // This we can determine efficiently. If the two rects neither // intersect nor contain eachother, then the two items do not collide. @@ -3269,12 +3269,11 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection // For further testing, we need this item's shape or bounding rect. QPainterPath thisShape; - if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) { + if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape(); - } else { - thisShape.addPolygon(_q_adjustedRect(boundingRect())); - thisShape.closeSubpath(); - } + else + thisShape.addRect(rectA); + if (thisShape == QPainterPath()) { // Empty shape? No collision. return false; |