mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 16:06:19 +00:00
op/clip: don't accept open Paths for Outline
Outline represents a clipping operations that clips all drawing outside a closed path. Before this change, paths not closed we're patched up by adding an implicit line from the endpoint to the beginning. These fixups are inefficient for a rare case, but acceptable because the old renderer post-processes all paths anyway. However, the new compute renderer don't need post-processing in most cases, making fixups too expensive. Given that clipping to an open path is fundamentally undefined and that implicit fixup with a closing line segment is merely a way to force the clip to be well-defined, this change adds a panic to Outline for Paths that are not closed. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -91,6 +91,7 @@ func TestPaintArc(t *testing.T) {
|
||||
p.Arc(f32.Pt(-10, -20), f32.Pt(10, -5), math.Pi)
|
||||
p.Line(f32.Pt(0, -10))
|
||||
p.Line(f32.Pt(-50, 0))
|
||||
p.Close()
|
||||
clip.Outline{
|
||||
Path: p.End(),
|
||||
}.Op().Add(o)
|
||||
@@ -112,6 +113,7 @@ func TestPaintAbsolute(t *testing.T) {
|
||||
p.MoveTo(f32.Pt(20, 20))
|
||||
p.LineTo(f32.Pt(80, 20))
|
||||
p.QuadTo(f32.Pt(80, 80), f32.Pt(20, 80))
|
||||
p.Close()
|
||||
clip.Outline{
|
||||
Path: p.End(),
|
||||
}.Op().Add(o)
|
||||
|
||||
Reference in New Issue
Block a user