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>
- Fix all qmllint warnings.
(except for main.qml, interactive.qml, and sampling.qml)
- Translate user facing strings when it makes sense to do so.
- Mark readonly properties as 'readonly'.
- Avoid binding on multiple properties on a single line.
(except for tiger.qml).
Pick-to: 6.5
Change-Id: Idbf8a472ca5ba5385d1368aadd608e95231a07f0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.
Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
As long as we had the funcs array, it would have been nice to be able to
directly get an index from whatever "tool" is selected. For example,
TabBar has currentIndex; but TabBar is otherwise not a great fit here.
But the funcs array wasn't so elegant anyway.
So that prompts switching to the known OO design pattern in which
drawing tools are objects containing functions that "do" the drawing, so
that there's no conditional dispatch: just ask the tool to handle each
mouse state change. I.e. here the DragHandler on the canvas uses the
tool's shapeType Component to create the shape, but the DragHandler
doesn't have to care which shape it is.
Handles for moving the shapes' control points are also shape-agnostic:
- a handle is a sort of template taking the path x and y properties to
read and write
- the handle initializes its position from those properties
- the DragHandler inside gets to do what it does best: just drag the
handle, nothing else (instead of needing to script the movement of
both the handle and the control point, we don't script either one)
- declarative bindings on the handle's position update the path
properties whenever the handle moves
And some styling:
- Switch looks better than Button for toggling
- use palette colors so that it looks good in dark mode too
- fix handle colors getting stuck on yellow
- borders on handles (yellow on white makes it hard to see the edge otherwise)
- reorder curve types by mathematical order (line, quadratic, cubic)
Pick-to: 6.2
Change-Id: Iefd980f428601840deb55370aad9256748855f07
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Drop the confusing alias mangling on all the QML files. Instead move
them into the base "shapes" directory. Also, use a QML module in CMake
and use the "shared" module as intended.
Pick-to: 6.2
Change-Id: I6a8fc3f2b2f86f58a54e188cf83ec7e2d4e8f468
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>