Tile grid overlay: gate rayon to native so the web build compiles

#4217 used rayon's par_iter in ui-egui unconditionally, but rayon is a
native-only dependency there, so cargo xtask wasm failed on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas 2026-10-12 22:30:59 -04:00
parent b4aea45e19
commit 2dd5d16046
1 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,7 @@ use std::sync::Arc;
use egui::{Align2, Color32, FontId, Painter, Shape, Stroke};
use photocraft_geom::{Rect as DRect, TILE_SIZE, TileCoord};
use photocraft_raster::{Surface, Tile};
#[cfg(not(target_arch = "wasm32"))]
use rayon::prelude::*;
use crate::PhotocraftApp;
@ -70,11 +71,18 @@ pub fn tile_infos(s: &Surface, parallel: bool) -> Vec<TileInfo> {
by_ptr.entry(ptr(t)).or_insert(t);
}
let distinct: Vec<(usize, &Arc<Tile>)> = by_ptr.into_iter().collect();
// rayon is a native-only dependency; the web build hashes serially.
#[cfg(not(target_arch = "wasm32"))]
let hashed: Vec<(usize, u64)> = if parallel {
distinct.par_iter().map(|(p, t)| (*p, content_hash(t))).collect()
} else {
distinct.iter().map(|(p, t)| (*p, content_hash(t))).collect()
};
#[cfg(target_arch = "wasm32")]
let hashed: Vec<(usize, u64)> = {
let _ = parallel;
distinct.iter().map(|(p, t)| (*p, content_hash(t))).collect()
};
let hash_of: HashMap<usize, u64> = hashed.into_iter().collect();
let mut count: HashMap<u64, usize> = HashMap::new();
for (_, t) in s.tiles() {