aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickshapes
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2023-11-23 12:59:41 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2024-01-17 15:36:27 +0100
commit96bd963cb7af37fd3b20ce3a1c9fd50939bed6fc (patch)
treeb130df39d127039ca1fc5b1688c3913827b6f7e1 /src/quickshapes
parente7d8ebb25be6a3f11c7cf3f42660804c58650e19 (diff)
Use shape hints in the curve renderer
We don't need to do expensive operations if we already know that the path is well behaved. Task-number: QTBUG-112340 Pick-to: 6.7 Change-Id: Ic386b7f293045c28294f56ad433bdae2b3b6b0e5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quickshapes')
-rw-r--r--src/quickshapes/qquickshapecurverenderer.cpp11
-rw-r--r--src/quickshapes/qquickshapecurverenderer_p.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/src/quickshapes/qquickshapecurverenderer.cpp b/src/quickshapes/qquickshapecurverenderer.cpp
index df24d6df9a..93ccca4596 100644
--- a/src/quickshapes/qquickshapecurverenderer.cpp
+++ b/src/quickshapes/qquickshapecurverenderer.cpp
@@ -148,6 +148,9 @@ void QQuickShapeCurveRenderer::setPath(int index, const QQuickPath *path)
auto &pathData = m_paths[index];
pathData.originalPath = path->path();
pathData.m_dirty |= PathDirty;
+ const auto *shapePath = qobject_cast<const QQuickShapePath *>(path);
+ if (shapePath)
+ pathData.pathHints = shapePath->pathHints();
}
void QQuickShapeCurveRenderer::setStrokeColor(int index, const QColor &color)
@@ -419,14 +422,16 @@ void QQuickShapeCurveRenderer::processPath(PathData *pathData)
static const bool doIntersetionSolving = !qEnvironmentVariableIntValue("QT_QUICKSHAPES_DISABLE_INTERSECTION_SOLVER");
static const bool useTriangulatingStroker = qEnvironmentVariableIntValue("QT_QUICKSHAPES_TRIANGULATING_STROKER");
static const bool simplifyPath = qEnvironmentVariableIntValue("QT_QUICKSHAPES_SIMPLIFY_PATHS");
+ static const QSGCurveProcessor::OverlapSolveMode overlapMode = qEnvironmentVariableIntValue("QT_QUICKSHAPES_WIP_CONCAVE_JOINT")
+ ? QSGCurveProcessor::FullOverlapSolve : QSGCurveProcessor::SkipConcaveJoinsSolve;
int &dirtyFlags = pathData->m_dirty;
if (dirtyFlags & PathDirty) {
if (simplifyPath)
- pathData->path = QQuadPath::fromPainterPath(pathData->originalPath.simplified());
+ pathData->path = QQuadPath::fromPainterPath(pathData->originalPath.simplified(), QQuadPath::PathLinear | QQuadPath::PathNonIntersecting | QQuadPath::PathNonOverlappingControlPointTriangles);
else
- pathData->path = QQuadPath::fromPainterPath(pathData->originalPath);
+ pathData->path = QQuadPath::fromPainterPath(pathData->originalPath, QQuadPath::PathHints(int(pathData->pathHints)));
pathData->path.setFillRule(pathData->fillRule);
pathData->fillPath = {};
dirtyFlags |= (FillDirty | StrokeDirty);
@@ -440,7 +445,7 @@ void QQuickShapeCurveRenderer::processPath(PathData *pathData)
QSGCurveProcessor::solveIntersections(pathData->fillPath);
pathData->fillPath.addCurvatureData();
if (doOverlapSolving)
- QSGCurveProcessor::solveOverlaps(pathData->fillPath);
+ QSGCurveProcessor::solveOverlaps(pathData->fillPath, overlapMode);
}
pathData->fillNodes = addFillNodes(*pathData);
dirtyFlags |= StrokeDirty;
diff --git a/src/quickshapes/qquickshapecurverenderer_p.h b/src/quickshapes/qquickshapecurverenderer_p.h
index 4b192a9218..f46521d4f7 100644
--- a/src/quickshapes/qquickshapecurverenderer_p.h
+++ b/src/quickshapes/qquickshapecurverenderer_p.h
@@ -98,6 +98,7 @@ private:
QPen pen;
bool validPenWidth = true;
int m_dirty = 0;
+ QQuickShapePath::PathHints pathHints;
QPainterPath originalPath;
QQuadPath path;