Fix wrong issuing of `pop_clip` command
diff --git a/sparse_strips/vello_common/src/coarse.rs b/sparse_strips/vello_common/src/coarse.rs index c7d497e..1e2ef62 100644 --- a/sparse_strips/vello_common/src/coarse.rs +++ b/sparse_strips/vello_common/src/coarse.rs
@@ -688,8 +688,9 @@ // If fill extends to next tile, pop current and handle next if x2 > (cur_wtile_x + 1) * WideTile::WIDTH { - self.get_mut(cur_wtile_x, cur_wtile_y).pop_clip(); - pop_pending = false; + if core::mem::take(&mut pop_pending) { + self.get_mut(cur_wtile_x, cur_wtile_y).pop_clip(); + } let width2 = x2 % WideTile::WIDTH; cur_wtile_x = x2 / WideTile::WIDTH;
diff --git a/sparse_strips/vello_sparse_tests/tests/issues.rs b/sparse_strips/vello_sparse_tests/tests/issues.rs index 7eb78ba..fba010d 100644 --- a/sparse_strips/vello_sparse_tests/tests/issues.rs +++ b/sparse_strips/vello_sparse_tests/tests/issues.rs
@@ -250,3 +250,14 @@ ctx.fill_rect(&Rect::new(0.0, 0.0, 100.0, 100.0)); ctx.pop_layer(); } + +#[vello_test(no_ref, width = 300, height = 4)] +// https://github.com/linebender/vello/issues/1032 +fn nested_clip_path_panic(ctx: &mut impl Renderer) { + let path1 = Rect::new(256.0, 0.0, 257.0, 2.0).to_path(0.1); + ctx.push_clip_layer(&path1); + let path2 = Rect::new(181.0, -200.0, 760.0, 618.0).to_path(0.1); + ctx.push_clip_layer(&path2); + ctx.pop_layer(); + ctx.pop_layer(); +}