diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-07 06:15:37 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-07 06:15:37 (GMT) |
commit | 4976130171033abdd8323a19229dcbfc5b008cfe (patch) | |
tree | 06fb286c8831e943941a9dabf081fe704fcfda88 /src/gui/painting/qpathclipper.cpp | |
parent | 65d04843759d14f15f559c78df94626568bc0cb8 (diff) | |
download | Qt-4976130171033abdd8323a19229dcbfc5b008cfe.zip Qt-4976130171033abdd8323a19229dcbfc5b008cfe.tar.gz Qt-4976130171033abdd8323a19229dcbfc5b008cfe.tar.bz2 |
Avoid many unnecessary allocations, so so that paint engines attached to pixmaps
do not consume excessive amounts of memory, and so can still be reasonably kept
cached with the pixmap.
Saves 8K for every pixmaps drawn to on raster paint engine. Saves about 2K for other graphicssystems.
Task-number: QTBUG-10215
Reviewed-by: Gunnar
Diffstat (limited to 'src/gui/painting/qpathclipper.cpp')
-rw-r--r-- | src/gui/painting/qpathclipper.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index c910024..78553c9 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -278,7 +278,8 @@ private: }; SegmentTree::SegmentTree(QPathSegments &segments) - : m_segments(segments) + : m_segments(segments), + m_intersections(0) { m_bounds.x1 = qt_inf(); m_bounds.y1 = qt_inf(); @@ -806,7 +807,7 @@ void QWingedEdge::intersectAndAdd() for (int i = 0; i < m_segments.points(); ++i) addVertex(m_segments.pointAt(i)); - QDataBuffer<QPathSegments::Intersection> intersections; + QDataBuffer<QPathSegments::Intersection> intersections(m_segments.segments()); for (int i = 0; i < m_segments.segments(); ++i) { intersections.reset(); @@ -857,11 +858,17 @@ void QWingedEdge::intersectAndAdd() } } -QWingedEdge::QWingedEdge() +QWingedEdge::QWingedEdge() : + m_edges(0), + m_vertices(0), + m_segments(0) { } -QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) +QWingedEdge::QWingedEdge(const QPainterPath &subject, const QPainterPath &clip) : + m_edges(subject.length()), + m_vertices(subject.length()), + m_segments(subject.length()) { m_segments.setPath(subject); m_segments.addPath(clip); @@ -1414,9 +1421,9 @@ bool QPathClipper::intersect() else if (clipIsRect) return subjectPath.intersects(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; @@ -1459,9 +1466,9 @@ bool QPathClipper::contains() if (clipIsRect) return subjectPath.contains(r2); - QPathSegments a; + QPathSegments a(subjectPath.length()); a.setPath(subjectPath); - QPathSegments b; + QPathSegments b(clipPath.length()); b.setPath(clipPath); QIntersectionFinder finder; |