From 55820e48b44893dd46e9e55b90ad020b75d5f8c5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 09:43:19 -0800 Subject: [PATCH] Image Trace: Overlapping's trace is checked across thread orders, and its memory bound names the kept components The overlapping test now traces the same image eight times with several levels found at a time and compares each result with the one traced a level at a time. The doc comment of the stacked rounds says that the components kept for the second pass take up to 256 MiB outside the half gigabyte that sets how many levels are traced at once. --- crates/trace/src/layers.rs | 3 ++- crates/trace/src/tests.rs | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/trace/src/layers.rs b/crates/trace/src/layers.rs index dba52ee3cd..1a592cd292 100644 --- a/crates/trace/src/layers.rs +++ b/crates/trace/src/layers.rs @@ -722,7 +722,8 @@ impl Layers<'_> { /// /// The marks take two bytes a pixel of the image. In an image with a transparent pixel or a color left out, the /// runs of such pixels take up to four bytes a pixel more during the first round (eight bytes a run). Both count - /// against the half gigabyte that sets how many levels are traced at a time. + /// against the half gigabyte that sets how many levels are traced at a time. The components kept for the second pass + /// take up to [`KEPT_BYTES`] more, outside that half gigabyte. pub(crate) fn stacked( &self, layers: &[(usize, usize)], diff --git a/crates/trace/src/tests.rs b/crates/trace/src/tests.rs index 934ed55880..46d3c7604b 100644 --- a/crates/trace/src/tests.rs +++ b/crates/trace/src/tests.rs @@ -557,7 +557,8 @@ fn overlapping_lines_and_outlines_leave_out_areas_without_their_color() { /// Overlapping: a level's components found with the areas that higher levels fill left out give the same trace as /// those found whole, and as those found again in the second pass (as past the memory kept for them), on a framed -/// image of rings and scattered blobs of eight colors, whatever the Noise. +/// image of rings and scattered blobs of eight colors, whatever the Noise. Traced with several levels at a time, in +/// whatever order the threads take them, it gives the same trace each time. #[test] fn overlapping_gives_the_same_trace_with_covered_areas_left_out() { let colors: [[u8; 4]; 8] = [ @@ -588,6 +589,9 @@ fn overlapping_gives_the_same_trace_with_covered_areas_left_out() { assert!(left_out.palette.len() >= 6 && left_out.paths.len() > 20, "{} colors, {} paths", left_out.palette.len(), left_out.paths.len()); assert_eq!(left_out, whole, "noise {noise}"); assert_eq!(left_out, again, "noise {noise}: found again"); + for run in 0..8 { + assert_eq!(left_out, trace(&img, &p), "noise {noise}: run {run} with several levels at a time"); + } assert_draws(&img, &left_out, &[]); } }