summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-03-03 12:30:33 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-04-15 10:16:22 (GMT)
commit920e77d9da68643aae483838b21330d032c00058 (patch)
tree87d4e62781096d30c00c0ba10324fb45c656e430
parent06244063a852e4d8b8d2d5641ae65ddcd83150c7 (diff)
downloadQt-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.cpp13
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;