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