mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
perf: retain uniform-mask shortcuts in bounded selection distances
This commit is contained in:
1 parent
8a2acd5ad6
commit
d2263c6cf2
3 files changed
+14
-1
No files matched your search
@@ -22,7 +22,7 @@ fn old_border(m: &[f32], w: usize, h: usize, r: f32) -> Vec<f32> {
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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) {
|
||||
|
||||
@@ -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<u8> = seeds.iter().map(|s| if *s { 0 } else { cap }).collect();
|
||||
|
||||
@@ -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.
|
||||
Reference in new issue
Block a user