Fix another panic in nested clip paths
diff --git a/sparse_strips/vello_common/src/coarse.rs b/sparse_strips/vello_common/src/coarse.rs index 1e2ef62..f3847fa 100644 --- a/sparse_strips/vello_common/src/coarse.rs +++ b/sparse_strips/vello_common/src/coarse.rs
@@ -615,7 +615,7 @@ let next_strip = &strips[i + 1]; let strip_width = ((next_strip.alpha_idx - strip.alpha_idx) / u32::from(Tile::HEIGHT)) as u16; - let x1 = x0 + strip_width; + let mut x1 = x0 + strip_width; let wtile_x0 = (x0 / WideTile::WIDTH).max(clip_bbox.x0()); let wtile_x1 = x1.div_ceil(WideTile::WIDTH).min(clip_bbox.x1()); @@ -626,6 +626,7 @@ if clip_x > x { col += u32::from(clip_x - x); x = clip_x; + x1 = clip_x.max(x1); } // Render clip strips for each affected tile and mark for popping
diff --git a/sparse_strips/vello_sparse_tests/snapshots/nested_clip_path_panic_2.png b/sparse_strips/vello_sparse_tests/snapshots/nested_clip_path_panic_2.png new file mode 100644 index 0000000..5d19ffe --- /dev/null +++ b/sparse_strips/vello_sparse_tests/snapshots/nested_clip_path_panic_2.png
@@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b0ecf76b64dbbc5b5d4e45bacae78062751daab68373b1d22c5d7afc77332f3 +size 96
diff --git a/sparse_strips/vello_sparse_tests/tests/issues.rs b/sparse_strips/vello_sparse_tests/tests/issues.rs index fba010d..6f8ee9e 100644 --- a/sparse_strips/vello_sparse_tests/tests/issues.rs +++ b/sparse_strips/vello_sparse_tests/tests/issues.rs
@@ -7,6 +7,7 @@ use vello_common::color::palette::css::{DARK_BLUE, LIME, REBECCA_PURPLE}; use vello_common::kurbo::{BezPath, Rect, Shape, Stroke}; use vello_common::peniko::Fill; +use vello_cpu::color::palette::css::RED; use vello_dev_macros::vello_test; #[vello_test(width = 8, height = 8)] @@ -261,3 +262,16 @@ ctx.pop_layer(); ctx.pop_layer(); } + +#[vello_test(width = 612, height = 4)] +// https://github.com/linebender/vello/issues/1034 +fn nested_clip_path_panic_2(ctx: &mut impl Renderer) { + let path1 = Rect::new(256.0, 0.0, 280.0, 2.0).to_path(0.1); + ctx.push_clip_layer(&path1); + let path2 = &Rect::new(0.0, 0.0, 511.0, 4.0).to_path(0.1); + ctx.push_clip_layer(&path2); + ctx.set_paint(RED); + ctx.fill_path(&Rect::new(0.0, 0.0, 511.0, 4.0).to_path(0.1)); + ctx.pop_layer(); + ctx.pop_layer(); +}