mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 07:57:29 +00:00
884e7d27e2
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>
23 lines
364 B
Go
23 lines
364 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package clip
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gioui.org/f32"
|
|
"gioui.org/op"
|
|
)
|
|
|
|
func TestOpenPathOutlinePanic(t *testing.T) {
|
|
defer func() {
|
|
if err := recover(); err == nil {
|
|
t.Error("Outline of an open path didn't panic")
|
|
}
|
|
}()
|
|
var p Path
|
|
p.Begin(new(op.Ops))
|
|
p.Line(f32.Pt(10, 10))
|
|
Outline{Path: p.End()}.Op()
|
|
}
|