mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
#11009 added a check that rasterize_rgba8 renders 500 nested opacity groups. #10953, merged after it, refuses whole-drawing rasterisation past 200 nested layers. The test now expects that refusal as an error, and still renders a drawing within the limit on the same 512 KiB stack.
This commit is contained in:
1 parent
e17091578e
commit
cb5243bf78
1 file changed
+10
-1
@@ -448,7 +448,16 @@ fn retained_deep_svg_groups_lower_render_and_drop_on_a_bounded_worker() {
|
||||
let (preview, _) = svg::import_svg_preview_with_work("retained.svg", source.as_bytes(), u64::MAX).unwrap();
|
||||
assert_eq!(preview.document.max_group_depth(), 100);
|
||||
assert!(pixel(&preview.document)[3] > 0.5);
|
||||
let (w, h, pixels) = svg::rasterize_rgba8(source.as_bytes()).unwrap();
|
||||
// Whole-drawing rasterisation refuses more than 200 nested layers (#10953) with an
|
||||
// error, not a crash; a drawing within that limit still renders on this small stack.
|
||||
let refused = svg::rasterize_rgba8(source.as_bytes()).unwrap_err().to_string();
|
||||
assert!(refused.contains("layers are nested too deeply"), "{refused}");
|
||||
let within = format!(
|
||||
"<svg {NS} width=\"8\" height=\"8\">{}<rect width=\"8\" height=\"8\"/>{}</svg>",
|
||||
"<g opacity=\"0.99\"><rect width=\"1\" height=\"1\"/>".repeat(150),
|
||||
"</g>".repeat(150)
|
||||
);
|
||||
let (w, h, pixels) = svg::rasterize_rgba8(within.as_bytes()).unwrap();
|
||||
assert_eq!((w, h), (8, 8));
|
||||
assert!(pixels[3] > 127);
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user