Skip to content

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

Merge branch 'main' into worktree-agent-aecd35c3421bad4ae

Brandon Thomas3c644f7faa34
diff --cc crates/ui-egui/src/control.rs
index 6fc4434ed,74d9792d4..f08da7037
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@@ -77,10 -77,10 +77,11 @@@ pub fn inspect(app: &LightcraftApp, ctx
"selection": app.session.selection.ids.iter().map(|p| p.0).collect::<Vec<_>>(),
"activeMask": app.session.active_mask,
"widgetCount": app.widgets.len(),
- "perf": {"frameMs": app.perf.frame_ms, "fps": app.perf.fps, "lastRenderMs": app.renderer.last_main_ms, "renderQueue": app.renderer.queued(), "rendersInFlight": app.renderer.in_flight(), "mergeRunning": app.merge.busy(), "lastMerge": app.merge.last_result, "rendersDone": app.renderer.completed, "thumbTextures": app.renderer.thumb_textures(), "gpu": (lightcraft_engine::gpu::ready() && lightcraft_engine::gpu::available()).then(lightcraft_engine::gpu::adapter_name).flatten()},
+ "perf": {"frameMs": app.perf.frame_ms, "fps": app.perf.fps, "lastRenderMs": app.renderer.last_main_ms, "renderQueue": app.renderer.queued(), "rendersInFlight": app.renderer.in_flight(), "mergeRunning": app.merge.busy(), "lastMerge": app.merge.last_result, "rendersDone": app.renderer.completed, "thumbTextures": app.renderer.thumb_textures(), "variantTextures": app.renderer.variant_textures(), "gpu": (lightcraft_engine::gpu::ready() && lightcraft_engine::gpu::available()).then(lightcraft_engine::gpu::adapter_name).flatten()},
"loupe": app.loupe_shown.map(|(p, src)| json!({"photo": p.0, "source": src, "pending": app.renderer.is_pending(crate::render::Slot::Main)})),
+ "hoverPreview": app.hover_preview.as_ref().map(|h| h.label.clone()),
"status": app.ui.status,
+ "memory": memory(app),
})
}
diff --cc crates/ui-egui/src/render.rs
index 0ba004761,86fa8d516..5aceea139
--- a/crates/ui-egui/src/render.rs
+++ b/crates/ui-egui/src/render.rs
@@@ -101,12 -90,15 +101,19 @@@ pub struct Renderer
quick_tried: HashMap<Slot, u64>,
/// Prefetch slot → key of the last job submitted (each runs once).
prefetched: HashMap<Slot, u64>,
+ /// Variant key → frame it was last asked for (LRU of [`Slot::Variant`] textures).
+ variant_used: HashMap<u64, u64>,
+ /// Frames polled so far.
+ frame: u64,
+ /// Since when nothing has been pending, and whether the GPU pool was trimmed since.
+ #[cfg(not(target_arch = "wasm32"))]
+ idle: Option<(std::time::Instant, bool)>,
}
+ /// After this long without renders the GPU renderer's pool of recycled buffers is freed.
+ #[cfg(not(target_arch = "wasm32"))]
+ const IDLE_TRIM: std::time::Duration = std::time::Duration::from_secs(3);
+
impl Default for Renderer {
fn default() -> Self {
let threads = if cfg!(target_arch = "wasm32") { 0 } else { JobPool::<Slot, RenderResult>::default_threads().min(6) };
@@@ -123,8 -115,8 +130,10 @@@
stages: HashMap::new(),
quick_tried: HashMap::new(),
prefetched: HashMap::new(),
+ variant_used: HashMap::new(),
+ frame: 0,
+ #[cfg(not(target_arch = "wasm32"))]
+ idle: None,
}
}
}
@@@ -371,7 -307,8 +386,9 @@@ impl Renderer
}
changed = true;
}
+ self.evict_variants();
+ #[cfg(not(target_arch = "wasm32"))]
+ self.trim_when_idle(ctx);
if !self.pending.is_empty() {
ctx.request_repaint_after(std::time::Duration::from_millis(16));
}
diff --cc docs/control-protocol.md
index 68a6a6621,b013a2ea4..15ee1fd87
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@@ -21,9 -21,9 +21,9 @@@ mode ([mcp.md](mcp.md)) is a thin laye
| `engine.commands` | — | Engine + UI commands: id, label, menu, shortcut, params doc, enabled |
| `ui.menu.list` | — | Menu entries (flat: id, label, menu path, shortcut, enabled) |
| `ui.menu.tree` | — | The menu bar as shown (File … Help): items `{id, params?, label, shortcut?, enabled, checked?}`, separators, submenus — the model behind the native macOS menu bar and the in-window menus |
- | `ui.inspect` | — | UI state, window, canvas/image rects, active photo, selection, perf, status |
+ | `ui.inspect` | — | UI state, window, canvas/image rects, active photo, selection, perf, status, memory (bytes per cache, see `library.memory`; plus stage caches and textures) |
| `ui.widgets` | `{filter?}` | On-screen widgets `{id, rect: [x, y, w, h]}` (screen points) |
-| `ui.clickWidget` / `ui.dragWidget` | `{id, count?, fx?, fy?}` / `{id, toX?, toY?, dx?, dy?, steps?}` | Real egui input on a widget |
+| `ui.clickWidget` / `ui.dragWidget` / `ui.hoverWidget` | `{id, count?, fx?, fy?}` / `{id, toX?, toY?, dx?, dy?, steps?}` / `{id, fx?, fy?}` | Real egui input on a widget (hover: the pointer rests on it, e.g. for preset/profile previews) |
| `ui.move` / `ui.click` / `ui.drag` | `{x, y, count?, button?}` / `{x, y, toX, toY, steps?}` | Raw pointer input, screen points |
| `ui.pointer` | `{events: [{kind: down\|drag\|up, x, y}], alt?, shift?, cmd?}` | Gesture in normalized image coordinates (Detail view) |
| `ui.key` | `{key, cmd?, shift?, alt?, ctrl?}` | Key press |
diff --cc docs/parity.md
index 32ca31030,97cada6d8..5e893d298
--- a/docs/parity.md
+++ b/docs/parity.md
@@@ -32,7 -32,7 +32,7 @@@ and prints the summary; `cargo xtask pa
| I. Remove / healing (REM) | 3 | 3 | 4 | 2 | 2/4 (50%) | 1/3 (33%) |
| J. Red eye (EYE) | 0 | 0 | 2 | 0 | — | 0/1 (0%) |
| K. Masking (MASK) | 6 | 10 | 7 | 0 | 4/8 (50%) | 2/5 (40%) |
--| L. Presets (PRE) | 1 | 4 | 2 | 1 | 0/2 (0%) | 1/2 (50%) |
++| L. Presets (PRE) | 3 | 2 | 2 | 1 | 2/2 (100%) | 1/2 (50%) |
| M. Versions & history (VER) | 3 | 1 | 1 | 0 | 1/1 (100%) | 2/3 (67%) |
| N. Copy / paste / sync (SYNC) | 4 | 0 | 1 | 0 | 3/3 (100%) | 1/1 (100%) |
| O. Merge (MERGE) | 3 | 0 | 1 | 0 | — | — |
@@@ -44,11 -44,11 +44,11 @@@
| U. Map & location (MAP) | 0 | 1 | 1 | 0 | — | 0/1 (0%) |
| V. Preferences (PREF) | 0 | 3 | 5 | 3 | 0/1 (0%) | 0/4 (0%) |
| W. Cloud & AI infrastructure (CLOUD / AI) | 0 | 1 | 1 | 2 | — | — |
--| X. Cross-cutting behaviours (BEHAV) | 10 | 2 | 5 | 1 | 7/8 (88%) | 3/5 (60%) |
++| X. Cross-cutting behaviours (BEHAV) | 10 | 3 | 4 | 1 | 7/8 (88%) | 3/5 (60%) |
| Y. Menus | 46 | 18 | 21 | 8 | 37/47 (79%) | 7/23 (30%) |
| Z. Keyboard shortcuts (desktop) | 46 | 16 | 18 | 1 | 39/52 (75%) | 7/23 (30%) |
| Lightroom Classic extras | 4 | 19 | 56 | 9 | — | 3/21 (14%) |
- | **Total** | 211 | 102 | 187 | 37 | 153/198 (77%) | 49/144 (34%) |
-| **Total** | 208 | 103 | 189 | 37 | 152/198 (77%) | 48/144 (33%) |
++| **Total** | 213 | 101 | 186 | 37 | 155/198 (78%) | 49/144 (34%) |
<!-- /parity:summary -->
## Top gaps