aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-09-06 12:45:55 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-05-26 14:45:21 +0200
commitbe813b9955aad4628dba4a270ba1de226a7c9496 (patch)
treea952ebee2528e684196d5721b84b73c6420c64ee /tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp
parentf6e5a11f0c382dfd831e4ec0bb1c34ff2e6540e6 (diff)
Introduce hardware accelerated curve renderer for Shapes
This implements the Loop/Blinn algorithm for quadratic curves as an optional backend for Qt Quick Shapes, basically distance fields where the distance to curves are calculated in the fragment shader. This means cubic curves are approximated, which will give varying results, but for many shapes (such as text) this is efficient and means the shapes can be zoomed indefinitely while still retaining curvature as well as anti-aliasing working without MSAA. Preliminary results give some frame rate improvements compared to doing MSAA and GeometryRenderer, but the major improvement is that you can get smooth curves at any zoom level without re-triangulating the shape. Note that the renderer currently does not do antialiasing for straight lines. This would still require MSAA, but at a lower cost than for GeometryRenderer since there are much fewer triangles. Adding AA here as well is work in progress. Task-number: QTBUG-104122 Done-with: Paul Olav Tvete <paul.tvete@qt.io> Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io> Done-with: Amr Elsayed <amr.elsayed@qt.io> Change-Id: I6b4a1103546fbdfe760906f7a183101f8eedb9d3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp')
-rw-r--r--tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp b/tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp
new file mode 100644
index 0000000000..c16f2ad20d
--- /dev/null
+++ b/tests/manual/painterpathquickshape/debugvisualizationcontroller.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "debugvisualizationcontroller.h"
+#include <private/qquickshapecurverenderer_p.h>
+
+DebugVisualizationController::DebugVisualizationController(QObject *parent)
+ : QObject{parent}
+{
+}
+
+bool DebugVisualizationController::showCurves() const
+{
+ return m_showCurves;
+}
+
+void DebugVisualizationController::setShowCurves(bool newShowCurves)
+{
+ if (m_showCurves == newShowCurves)
+ return;
+ m_showCurves = newShowCurves;
+ update();
+ emit showCurvesChanged();
+}
+
+bool DebugVisualizationController::showWireframe() const
+{
+ return m_showWireframe;
+}
+
+void DebugVisualizationController::setWireframe(bool newShowWireframe)
+{
+ if (m_showWireframe == newShowWireframe)
+ return;
+ m_showWireframe = newShowWireframe;
+ update();
+ emit showWireframeChanged();
+}
+
+void DebugVisualizationController::update()
+{
+ int flags = (m_showCurves ? QQuickShapeCurveRenderer::DebugCurves : 0)
+ | (m_showWireframe ? QQuickShapeCurveRenderer::DebugWireframe : 0);
+ QQuickShapeCurveRenderer::setDebugVisualization(flags);
+ emit settingsChanged();
+}