Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge main into persistence branch (keep JobPool renderer; wasm inline job timing via now_ms)

Brandon Thomas1da0263d56eb
diff --cc README.md
index 812a12ac8,9fdb5c173..1cf517475
--- a/README.md
+++ b/README.md
@@@ -221,10 -235,11 +235,12 @@@ LightCraft is young and moving fast �
```sh
git clone https://github.com/storytold/lightcraft && cd lightcraft
-cargo run --release -p lightcraft # opens with a procedurally generated demo library
-cargo run --release -p lightcraft -- ~/Pictures/trip # or point it at your photos (folders are scanned)
+cargo run --release -p lightcraft # opens your library (~/Pictures/LightCraft Library; a new one starts with demo photos)
+cargo run --release -p lightcraft -- ~/Pictures/trip # import your photos (folders are scanned, duplicates skipped)
+cargo run --release -p lightcraft -- --memory # a throwaway in-memory demo session (writes nothing)
cargo run --release -p lightcraft -- --control 7980 # with the automation channel
+ cargo xtask web --serve # the same app in the browser: http://127.0.0.1:8080/
+ cargo run --release -p lightcraft-cli -- render photo.jpg -o out.jpg --set light.exposure=0.5
cargo xtask ci # fmt, clippy, tests, layering, wasm checks
```
diff --cc crates/engine/src/lib.rs
index ddc6f7845,d740ac29d..01ae5da90
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@@ -12,9 -12,8 +12,10 @@@
pub mod cmd;
pub mod demo;
+ pub mod export;
pub mod files;
+pub mod import;
+pub mod library;
pub mod media;
pub mod presets;
mod view;
diff --cc crates/ui-egui/Cargo.toml
index 21e287f78,7c38bd3b9..499dbfdd1
--- a/crates/ui-egui/Cargo.toml
+++ b/crates/ui-egui/Cargo.toml
@@@ -15,8 -15,8 +15,9 @@@ lightcraft-raster = { workspace = true
lightcraft-develop = { workspace = true }
lightcraft-pipeline = { workspace = true }
lightcraft-catalog = { workspace = true }
+ web-time = { workspace = true }
lightcraft-engine = { workspace = true }
+lightcraft-preview = { workspace = true }
egui = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
diff --cc crates/ui-egui/src/render.rs
index dab06d337,90df55e6b..ecfe694b3
--- a/crates/ui-egui/src/render.rs
+++ b/crates/ui-egui/src/render.rs
@@@ -86,14 -125,25 +86,21 @@@ impl Renderer
/// Collect finished jobs into textures. Returns true if anything changed.
pub fn poll(&mut self, ctx: &egui::Context, session: &mut Session) -> bool {
++ // wasm: run one job per frame on this thread, timed with the host clock
#[cfg(target_arch = "wasm32")]
- self.pool.run_inline(1);
- {
- // inline: run one job per frame
- let job = {
- let mut g = self.queue.0.lock().unwrap_or_else(|e| e.into_inner());
- let best = g.iter().enumerate().max_by_key(|(i, (_, p, _))| (*p, *i)).map(|(i, _)| i);
- best.map(|b| g.remove(b))
- };
- if let Some((slot, _, job)) = job {
- let t0 = now();
- let r = job.run();
- let _ = self.results_tx.send((slot, r, now() - t0));
- }
- }
++ let inline_ms = {
++ let t0 = crate::now_ms();
++ self.pool.run_inline(1);
++ crate::now_ms() - t0
++ };
++ #[cfg(not(target_arch = "wasm32"))]
++ let inline_ms = 0.0;
let mut changed = false;
- while let Ok((slot, r, ms)) = self.results.try_recv() {
+ while let Some(done) = self.pool.try_recv() {
- let (slot, r, ms) = (done.slot, done.result, done.ms);
++ let (slot, r, ms) = (done.slot, done.result, if done.ms > 0.0 { done.ms } else { inline_ms });
session.accept(&r);
self.completed += 1;
- if self.pending.get(&slot) == Some(&r.key) {
+ if self.pending.get(&slot).is_some_and(|p| p.0 == r.key) {
self.pending.remove(&slot);
}
let Ok(rendered) = r.rendered else {