mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
clip: check Path ops are not mixed with others
Multiple operations Op, such as clip.Path, cannot be interleaved with other ops. This patch adds a mechanism to ensure that is the case by starting multi ops with ops.BeginMulti and ending them with ops.EndMulti while operations are written to op.Ops with ops.WriteMulti. This mechanism is applied to clip.Path. Fixes: https://todo.sr.ht/~eliasnaur/gio/336 Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
@@ -227,3 +227,27 @@ func TestPathReuse(t *testing.T) {
|
||||
}, func(r result) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestPathInterleave(t *testing.T) {
|
||||
t.Run("interleave op in clip.Path", func(t *testing.T) {
|
||||
defer func() {
|
||||
if err := recover(); err == nil {
|
||||
t.Error("expected panic did not occur")
|
||||
}
|
||||
}()
|
||||
ops := new(op.Ops)
|
||||
var path clip.Path
|
||||
path.Begin(ops)
|
||||
path.LineTo(f32.Point{X: 123, Y: 456})
|
||||
paint.ColorOp{}.Add(ops)
|
||||
path.End()
|
||||
})
|
||||
t.Run("use ops after clip.Path", func(t *testing.T) {
|
||||
ops := new(op.Ops)
|
||||
var path clip.Path
|
||||
path.Begin(ops)
|
||||
path.LineTo(f32.Point{X: 123, Y: 456})
|
||||
path.End()
|
||||
paint.ColorOp{}.Add(ops)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user