diff --git a/crates/algo/examples/bench_selection_morphology.rs b/crates/algo/examples/bench_selection_morphology.rs index 795ba74413..71fbc7438e 100644 --- a/crates/algo/examples/bench_selection_morphology.rs +++ b/crates/algo/examples/bench_selection_morphology.rs @@ -22,7 +22,7 @@ fn old_border(m: &[f32], w: usize, h: usize, r: f32) -> Vec { fn main() -> Result<(), Box> { let (w, h) = (6000, 6000); println!("36 MP; median of three runs including allocation; RAYON_NUM_THREADS={}", std::env::var("RAYON_NUM_THREADS").unwrap_or_default()); - for (case, size) in [("sparse", 50), ("dense", 4000)] { + for (case, size) in [("sparse", 50), ("dense", 4000), ("full", 6000)] { let mut m = vec![0.0; w * h]; let start = (w - size) / 2; for row in m.chunks_exact_mut(w).skip(start).take(size) { diff --git a/crates/algo/src/selection/distance.rs b/crates/algo/src/selection/distance.rs index 53588904f0..73b5b8f2a4 100644 --- a/crates/algo/src/selection/distance.rs +++ b/crates/algo/src/selection/distance.rs @@ -13,6 +13,13 @@ pub(super) fn edt_bounded(seeds: &[bool], w: usize, h: usize, reach: f32) -> Vec if w == 0 || h == 0 || w.checked_mul(h) != Some(seeds.len()) || !(0.0..=6.0).contains(&reach) { return Vec::new(); } + // Select All and empty complements need no sweeps, just as in the general EDT. + if !seeds.iter().any(|seed| *seed) { + return vec![EMPTY_DISTANCE; seeds.len()]; + } + if seeds.iter().all(|seed| *seed) { + return vec![0.0; seeds.len()]; + } let radius = reach.ceil() as usize; let cap = radius as u8 + 1; let mut vertical: Vec = seeds.iter().map(|s| if *s { 0 } else { cap }).collect(); diff --git a/docs/selection-distance-performance.md b/docs/selection-distance-performance.md index 073a941c03..d1abbe6f4c 100644 --- a/docs/selection-distance-performance.md +++ b/docs/selection-distance-performance.md @@ -166,3 +166,9 @@ undoable edit; session creation and full-canvas equality checks are outside timi Three rounds alternate execution order, with radii 3 and 50 on a 50×50 selection in a 6000×6000 canvas. The cropped path dispatches the actual command; the reference calls the prior conversion/edit sequence directly. GUI rendering remains excluded. + +Uniform bounded-distance masks retain the general EDT's no-sweep shortcuts: no seeds +return the finite empty-distance sentinel; all seeds return zero. The current algorithm +benchmark also includes a full-canvas selected mask to check Select All alongside the +sparse and dense partial selections. The historical table above covers its recorded +Expand/Border sparse and dense cases.