EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge pull request #442 from cdinhoo/codex/live-preview-updates
Claude790f57ef2436
diff --cc crates/ui-egui/src/panels/viewer.rsindex 9bc70cb19,8998236e0..eb6ab56a6--- a/crates/ui-egui/src/panels/viewer.rs+++ b/crates/ui-egui/src/panels/viewer.rs@@@ -667,13 -641,10 +667,13 @@@ pub fn show(app: &mut EffectcraftApp, ulet frame = comp.frame_rate.frame_at(time);let key = app.frame_key(cid, frame, scale);app.request_frame_urgent(cid, frame, scale);- if let Some(img) = app.frames.get(&key) {+ if let Some((key, img)) = app.frames.get_for_viewer(&key, app.viewer_shown.as_ref().map(|(_, k)| k)) {let stale = app.viewer_shown.as_ref().is_none_or(|(_, k)| *k != key);- if stale {- show_frame(app, &ctx, key, img);+ // A CPU frame goes up again when the magnification calls for another factor.+ let minify = minify_factor(app.session.prefs.viewer_zoom_smooth(), scale, (zoom * ppp) as f64);+ let refit = !app.viewer_on_gpu() && app.viewer_tex.as_ref().is_some_and(|(_, _, m)| *m != minify);+ if stale || refit {+ show_frame(app, &ctx, key, img, minify);} else if let Some((_, k)) = app.viewer_shown.as_mut() {// The same frame at a later revision (an edit elsewhere, an undo): it shows that one.k.revision = key.revision;diff --cc docs/architecture.mdindex 6a284b8e3,053ed82ee..4fe5d2cd7--- a/docs/architecture.md+++ b/docs/architecture.md@@@ -161,21 -161,19 +161,25 @@@ collapsed 3D precomps (drawn flattened)A **layer cache** keeps each layer's finished pixels (source, masks and effects) keyed by a hash ofits evaluated inputs, excluding the transform. Static and transform-only layers render once;-editing one layer re-renders only that layer. Effects that read the clock directly are declared in+editing one layer re-renders only that layer. Each Render Queue job keeps its own layer cache+for its frames. Effects that read the clock directly are declared in`effects::TIME_DEPENDENT`, and a test checks every registered effect against that list.- The viewer's **RAM preview** (`ui-egui/src/frames.rs`) keeps finished frames keyed by project- revision, comp, frame, scale, 3D view / region of interest and a hash of the other render- options (Draft / Fast Previews, shadows, nested switches), so frames rendered under other- options are never shown. When the budget (Settings ▸ Memory & CPU) is full the least recently- shown frames go first, and frames of an older revision are dropped as soon as the project- changes. The timeline's green bar counts the frames of exactly what the viewer shows.+ The viewer's **RAM preview** (`ui-egui/src/frames.rs`) keeps finished frames keyed by comp+ content, frame, scale, 3D view / region of interest and a hash of the other render options+ (Draft / Fast Previews, shadows, nested switches). Edits preserve unaffected comps' frames,+ and undo can reuse earlier content. During rapid edits at the same time and view, the viewer+ shows the newest completed revision while the exact requested revision renders; out-of-order+ completions cannot move it backwards. This avoids freezing until a slider or layer drag stops.+ Frames at other times or with other render options are never substituted. Obsolete queued jobs+ are dropped; running jobs finish into the cache. When the budget (Settings ▸ Memory & CPU) is+ full the least recently shown frames go first. The timeline's green bar counts cached frames+ of the current content and viewer settings.+Resolution Auto renders the pixels the magnification needs, as in After Effects (Full above+50 %, Half down to 33.3 %, Third down to 25 %, then Quarter). Below 100 % the viewer averages+instead of skipping pixels (Viewer Zoom Quality More Accurate): GPU frames carry a mip chain+sampled trilinearly, CPU frames go up averaged down by the whole factor that leaves about one+texel per screen pixel.A persistent **disk cache** (`render::disk_cache`, Settings ▸ Media & Disk Cache) backs boththe layer cache and the viewer's RAM preview: layer buffers that were slow to render and every