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