Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickgenerator.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquickgenerator_p.h"
5#include "qsvgvisitorimpl_p.h"
6#include "qquicknodeinfo_p.h"
7
8#include <private/qsgcurveprocessor_p.h>
9#include <private/qquickshape_p.h>
10#include <private/qquadpath_p.h>
11#include <private/qquickitem_p.h>
12#include <private/qquickimagebase_p_p.h>
13
14#include <QtCore/qloggingcategory.h>
15
17
18Q_LOGGING_CATEGORY(lcQuickVectorImage, "qt.quick.vectorimage", QtWarningMsg)
19
21 : m_flags(flags)
22 , m_fileName(fileName)
23 , m_loader(nullptr)
24{
25}
26
28{
29 delete m_loader;
30}
31
32void QQuickGenerator::setGeneratorFlags(QQuickVectorImageGenerator::GeneratorFlags flags)
33{
34 m_flags = flags;
35}
36
37QQuickVectorImageGenerator::GeneratorFlags QQuickGenerator::generatorFlags()
38{
39 return m_flags;
40}
41
43{
44 m_loader = new QSvgVisitorImpl(m_fileName, this);
45 m_loader->traverse();
46}
47
49{
50 QPainterPath pathCopy = info.painterPath;
51 pathCopy.setFillRule(info.fillRule);
52
54 QQuadPath strokePath = QQuadPath::fromPainterPath(pathCopy);
55 bool fillPathNeededClose;
56 QQuadPath fillPath = strokePath.subPathsClosed(&fillPathNeededClose);
57 const bool intersectionsFound = QSGCurveProcessor::solveIntersections(fillPath, false);
58 fillPath.addCurvatureData();
60 const bool compatibleStrokeAndFill = !fillPathNeededClose && !intersectionsFound;
61 if (compatibleStrokeAndFill || m_flags.testFlag(QQuickVectorImageGenerator::GeneratorFlag::OutlineStrokeMode)) {
62 outputShapePath(info, nullptr, &fillPath, QQuickVectorImageGenerator::FillAndStroke, pathCopy.boundingRect());
63 } else {
64 outputShapePath(info, nullptr, &fillPath, QQuickVectorImageGenerator::FillPath, pathCopy.boundingRect());
65 outputShapePath(info, nullptr, &strokePath, QQuickVectorImageGenerator::StrokePath, pathCopy.boundingRect());
66 }
67 } else {
68 outputShapePath(info, &pathCopy, nullptr, QQuickVectorImageGenerator::FillAndStroke, pathCopy.boundingRect());
69 }
70}
71
73{
74 if (!info.isVisible || !info.isDisplayed)
75 return false;
76
77 return true;
78}
79
\inmodule QtGui
QQuadPath subPathsClosed(bool *didClose=nullptr) const
static QQuadPath fromPainterPath(const QPainterPath &path, PathHints hints={})
void addCurvatureData()
virtual void outputShapePath(const PathNodeInfo &info, const QPainterPath *path, const QQuadPath *quadPath, QQuickVectorImageGenerator::PathSelector pathSelector, const QRectF &boundingRect)=0
void optimizePaths(const PathNodeInfo &info)
QQuickVectorImageGenerator::GeneratorFlags m_flags
friend class QSvgVisitorImpl
void setGeneratorFlags(QQuickVectorImageGenerator::GeneratorFlags flags)
bool isNodeVisible(const NodeInfo &info)
QQuickVectorImageGenerator::GeneratorFlags generatorFlags()
virtual ~QQuickGenerator()
static bool solveOverlaps(QQuadPath &path)
static bool solveIntersections(QQuadPath &path, bool removeNestedPaths=true)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
@ QtWarningMsg
Definition qlogging.h:31
#define Q_LOGGING_CATEGORY(name,...)
GLbitfield flags
QHostInfo info
[0]