summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Erik Nilsen <bjorn.nilsen@nokia.com>2009-03-03 12:30:33 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-06 11:49:39 (GMT)
commitb67dffcccea9166918ac93c281d87fd5eb3baf84 (patch)
tree1140732030f78aa7a0e1a9e27c703ee22f68b2f7
parent7f50f45da0ad4a9eedd3ad7d8a82f719f7f8dd73 (diff)
downloadQt-b67dffcccea9166918ac93c281d87fd5eb3baf84.zip
Qt-b67dffcccea9166918ac93c281d87fd5eb3baf84.tar.gz
Qt-b67dffcccea9166918ac93c281d87fd5eb3baf84.tar.bz2
Fixes: Small optimization in QGraphicsItem::clipPath().
RevBy: Andreas Details: Use QPainterPath::addRect() rather than addPolygon() and closeSubPath().
-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 8b37648..fa77fd9 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;