diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-08-31 11:26:34 +0200 |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-08-31 12:01:31 +0200 |
commit | f2dbfdccfab0648cf353ef56ced269468984840c (patch) | |
tree | 85751c3a8294f22f56eac729c05511ebb22b39f4 /src/svg | |
parent | 266f578ebe20b9885421effec0a91f9c025fd11e (diff) |
Find the cached bounds only when necessary.
We delay computing the bounding rect as late as possible. This speeds-up
QSvgPath construction.
Reviewed-by: Kim
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvggraphics.cpp | 9 | ||||
-rw-r--r-- | src/svg/qsvggraphics_p.h | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index 6f30b90171..1b7744401f 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -193,8 +193,6 @@ void QSvgLine::draw(QPainter *p, QSvgExtraStates &states) QSvgPath::QSvgPath(QSvgNode *parent, const QPainterPath &qpath) : QSvgNode(parent), m_path(qpath) { - //m_cachedBounds = m_path.controlPointRect(); - m_cachedBounds = m_path.boundingRect(); } void QSvgPath::draw(QPainter *p, QSvgExtraStates &states) @@ -208,8 +206,13 @@ void QSvgPath::draw(QPainter *p, QSvgExtraStates &states) QRectF QSvgPath::bounds() const { qreal sw = strokeWidth(); - if (qFuzzyIsNull(sw)) + if (qFuzzyIsNull(sw)) { + if (m_cachedBounds.isNull()) + //m_cachedBounds = m_path.controlPointRect(); + m_cachedBounds = m_path.boundingRect(); + return m_cachedBounds; + } else { return boundsOnStroke(m_path, sw); } diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h index 02c312b667..246a8c9fa1 100644 --- a/src/svg/qsvggraphics_p.h +++ b/src/svg/qsvggraphics_p.h @@ -145,7 +145,7 @@ public: } private: QPainterPath m_path; - QRectF m_cachedBounds; + mutable QRectF m_cachedBounds; }; class QSvgPolygon : public QSvgNode |