42bool QQuickGenerator::generate()
44 m_errorState = QQuickVectorImageGenerator::NoError;
45 QSvgVisitorImpl loader(m_fileName,
this, m_flags.testFlag(QQuickVectorImageGenerator::AssumeTrustedSource));
46 return loader.doTraversal();
49void QQuickGenerator::optimizePaths(
const PathNodeInfo &info,
const QRectF &overrideBoundingRect)
51 if (Q_UNLIKELY(errorState()))
54 QPainterPath pathCopy = info.path.defaultValue().value<QPainterPath>();
55 pathCopy.setFillRule(info.fillRule);
57 const QRectF &boundingRect = overrideBoundingRect.isNull() ? pathCopy.boundingRect() : overrideBoundingRect;
58 if (m_flags.testFlag(QQuickVectorImageGenerator::GeneratorFlag::OptimizePaths) && !info.path.isAnimated()) {
59 QQuadPath strokePath = QQuadPath::fromPainterPath(pathCopy);
60 bool fillPathNeededClose;
61 QQuadPath fillPath = strokePath.subPathsClosed(&fillPathNeededClose);
62 const bool intersectionsFound = QSGCurveProcessor::solveIntersections(fillPath,
false);
63 fillPath.addCurvatureData();
64 QSGCurveProcessor::solveOverlaps(fillPath);
65 const bool compatibleStrokeAndFill = !fillPathNeededClose && !intersectionsFound;
67 if (compatibleStrokeAndFill || m_flags.testFlag(QQuickVectorImageGenerator::GeneratorFlag::OutlineStrokeMode)) {
68 outputShapePath(info,
nullptr, &fillPath, QQuickVectorImageGenerator::FillAndStroke, boundingRect);
70 outputShapePath(info,
nullptr, &fillPath, QQuickVectorImageGenerator::FillPath, boundingRect);
71 outputShapePath(info,
nullptr, &strokePath, QQuickVectorImageGenerator::StrokePath, boundingRect);
74 outputShapePath(info, &pathCopy,
nullptr, QQuickVectorImageGenerator::FillAndStroke, boundingRect);