Avoid processing bezier curves that will be clipped anyway
Simplify curves ourside the clipped area with a straight line that closes the path, but saves us a lot of time and memory when zooming in on a path. Change-Id: I437f7eab564b805ebbefccd6755060156227c88d Reviewed-by: Gunnar Sletta <gunnar@sletta.org>bb10
parent
b159a1c3e0
commit
4077e28daa
|
|
@ -78,10 +78,23 @@ void QOutlineMapper::curveTo(const QPointF &cp1, const QPointF &cp2, const QPoin
|
|||
#endif
|
||||
|
||||
QBezier bezier = QBezier::fromPoints(m_elements.last(), cp1, cp2, ep);
|
||||
bezier.addToPolygon(m_elements, m_curve_threshold);
|
||||
m_element_types.reserve(m_elements.size());
|
||||
for (int i = m_elements.size() - m_element_types.size(); i; --i)
|
||||
m_element_types << QPainterPath::LineToElement;
|
||||
|
||||
bool outsideClip = false;
|
||||
// Test one point first before doing a full intersection test.
|
||||
if (!QRectF(m_clip_rect).contains(m_transform.map(ep))) {
|
||||
QRectF potentialCurveArea = m_transform.mapRect(bezier.bounds());
|
||||
outsideClip = !potentialCurveArea.intersects(m_clip_rect);
|
||||
}
|
||||
if (outsideClip) {
|
||||
// The curve is entirely outside the clip rect, so just
|
||||
// approximate it with a line that closes the path.
|
||||
lineTo(ep);
|
||||
} else {
|
||||
bezier.addToPolygon(m_elements, m_curve_threshold);
|
||||
m_element_types.reserve(m_elements.size());
|
||||
for (int i = m_elements.size() - m_element_types.size(); i; --i)
|
||||
m_element_types << QPainterPath::LineToElement;
|
||||
}
|
||||
Q_ASSERT(m_elements.size() == m_element_types.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue