From baf61b32cf4aa554ee3dbb4a22b99e854d5ebd34 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Thu, 26 Feb 2009 11:14:12 +0100 Subject: Optimize QGraphicsItem::map(To|From)Parent(const QPainterPath) Now that we have QPainterPath::translate, we can use that instead of itemTransform()/map(To|From)Scene, which lowers the number of QTransform operations involved. Reviewd-by: Andreas --- src/gui/graphicsview/qgraphicsitem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 26fc485..c8a4a14 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4587,7 +4587,9 @@ QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterP */ QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const { - return d_ptr->parent ? itemTransform(d_ptr->parent).map(path) : mapToScene(path); + QPainterPath p(path); + p.translate(d_ptr->pos); + return d_ptr->hasTransform ? transform().map(p) : p; } /*! @@ -4802,9 +4804,9 @@ QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainte */ QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const { - if (d_ptr->parent) - return d_ptr->parent->itemTransform(this).map(path); - return mapFromScene(path); + QPainterPath p(path); + p.translate(-d_ptr->pos); + return d_ptr->hasTransform ? transform().inverted().map(p) : p; } /*! -- cgit v0.12