op/clip: remove complex stroke support

In a discussion with Raph Levien, the author of our compute renderer
implementation, it became clear to me that it's not at all certain that
complex strokes will ever be efficiently supported by a GPU renderer.

At the same time, the machinery for converting a complex stroke to a
GPU-friendly outline has a significant maintenance cost. Further, it is
surprising to users that complex strokes are significantly slower and
allocate memory.

This change removes support for complex strokes, leaving only
round-capped, round-joined strokes supported by the compute renderer.
The default renderer still converts all strokes to outline, but it also
caches the result.

This is an API change. The complex stroke conversion code has been moved
to the external gioui.org/x/stroke package, with a similar API.

Updats gio#282 (Inkeliz brought up the allocation issue)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-10-08 17:56:50 +02:00
parent 391725b9d0
commit bd1ef92dc4
19 changed files with 60 additions and 1159 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ func (b Border) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
b.Color,
clip.Stroke{
Path: clip.UniformRRect(r, rr).Path(gtx.Ops),
Style: clip.StrokeStyle{Width: width},
Width: width,
}.Op(),
)
+2 -5
View File
@@ -74,10 +74,7 @@ func clipLoader(ops *op.Ops, startAngle, endAngle, radius float32) clip.Op {
p.Move(pen)
p.Arc(center, center, delta)
return clip.Stroke{
Path: p.End(),
Style: clip.StrokeStyle{
Width: width,
Cap: clip.FlatCap,
},
Path: p.End(),
Width: width,
}.Op()
}