diff --git a/crates/ui-egui/src/presenter_view.rs b/crates/ui-egui/src/presenter_view.rs index 712c9f3a0..a7bd5c286 100644 --- a/crates/ui-egui/src/presenter_view.rs +++ b/crates/ui-egui/src/presenter_view.rs @@ -68,7 +68,7 @@ pub struct PresenterModel<'a> { pub zoom_frame: Option, /// The frame shown to the audience. pub current: PreviewPic<'a>, - /// The next slide's first frame, its pending state, or the end of the show. + /// The whole next slide, its pending state, or the end of the show. pub next: NextPic<'a>, /// Pictures for this presenter's All slides grid. pub slides: GridSource<'a>, diff --git a/crates/ui-egui/src/show/frames.rs b/crates/ui-egui/src/show/frames.rs index 99488c768..881f0ec2b 100644 --- a/crates/ui-egui/src/show/frames.rs +++ b/crates/ui-egui/src/show/frames.rs @@ -1,5 +1,6 @@ use super::render::{ - below_playing_video, hidden_on_entry, part_textures, prefetch_job, quad_mesh, render_backdrop, render_frame, render_overlay, render_threads, + below_playing_video, hidden_on_entry, part_textures, prefetch_job, preview_job, quad_mesh, render_backdrop, render_frame, render_overlay, + render_threads, }; use super::{BackKey, Key, Layer, Presentation, RenderOpts, ShapeId, ShapeState, Show, ShowState, Source, state_for}; use crate::media::MediaHost; @@ -65,7 +66,7 @@ pub(crate) struct PreviewFrame { pub doc: Arc, /// The slide rendered. pub slide: usize, - /// The rendered first frame. + /// The rendered slide, every shape shown. pub image: ColorImage, } @@ -182,7 +183,7 @@ impl ShowFrames { if self.next.is_none() && !queues.previews.contains(&NextPreview) && queues.previews.counts().finished == 0 { let (doc, slide, size) = (wanted.doc.clone(), wanted.slide, wanted.size); queues.previews.submit(NextPreview, Priority::NEAR, move |cancel| { - let image = prefetch_job(doc.clone(), slide, size)(cancel); + let image = preview_job(doc.clone(), slide, size)(cancel); PreviewFrame { doc, slide, image } }); } diff --git a/crates/ui-egui/src/show/presenter.rs b/crates/ui-egui/src/show/presenter.rs index 560702e29..d40b8e16e 100644 --- a/crates/ui-egui/src/show/presenter.rs +++ b/crates/ui-egui/src/show/presenter.rs @@ -135,7 +135,9 @@ pub(super) fn presenter_pass(ui: &mut Ui, app: &mut crate::SlideApp, show: &mut slides: super::GridSource::Deck { doc, thumbs: &thumbs, source: &source }, }; ViewportWindow::new(Word::plain("Presenter View — DeckCraft")) - .overlay(|overlay| overlay.size(egui::vec2(1100.0, 700.0))) + // The view lays itself out over the window's room: the pictures, notes and slide grid fit it, and the + // notes and the grid scroll themselves. + .overlay(|overlay| overlay.size(egui::vec2(1100.0, 700.0)).body_scroll(false)) .takes_unfocused_keys() .opens_over_full_screen() .show(ui, |ui, cx| { diff --git a/crates/ui-egui/src/show/render.rs b/crates/ui-egui/src/show/render.rs index 005e9ffd1..0143971cb 100644 --- a/crates/ui-egui/src/show/render.rs +++ b/crates/ui-egui/src/show/render.rs @@ -136,6 +136,21 @@ pub(super) fn prefetch_job( } } +/// The Presenter View's picture of slide `next`: the whole slide, every shape shown, not the frame it enters with, +/// so the presenter sees what the slide holds before its builds play. +pub(super) fn preview_job( + doc: std::sync::Arc, + next: usize, + size: (u32, u32), +) -> impl FnOnce(&craft::host::queue::Cancel) -> egui::ColorImage + Send { + move |_cancel| { + // Leave a core for the UI thread; wasm's renderer must remain sequential. + let threads = if cfg!(target_arch = "wasm32") { 0 } else { render_threads().saturating_sub(1).max(1) }; + let opts = RenderOpts { scale: f64::from(size.0) / doc.slide_size.width.max(1.0), size: Some(size), threads, ..Default::default() }; + crate::textures::to_color_image(&deckcraft_render::render_slide(&doc, next, &opts), false) + } +} + /// A transition layer as an egui mesh: [`deckcraft_anim::layer_mesh`]'s triangles (perspective /// cards subdivided so their pictures stay straight) with per-vertex opacity. pub(super) fn quad_mesh(tex: Option, rect: Rect, l: &Layer, color: Color32) -> Mesh { diff --git a/crates/ui-egui/src/show/tests.rs b/crates/ui-egui/src/show/tests.rs index 8e397dcfb..3936a0008 100644 --- a/crates/ui-egui/src/show/tests.rs +++ b/crates/ui-egui/src/show/tests.rs @@ -1234,6 +1234,39 @@ fn a_preview_of_an_edited_presentation_is_rendered_again() { assert!(harness.state().show.as_ref().unwrap().frames.next_texture().is_some()); } +/// The presenter's Next picture shows the whole next slide, with the shapes that build in on a click, not the frame +/// the slide enters with. +#[test] +fn the_next_preview_shows_the_shapes_that_build_in() { + let mut session = deckcraft_engine::Session::with_new(); + session.execute("slide.new", &json!({"layout": "blank"})).unwrap(); + session.execute("shape.insert", &json!({"preset": "rect", "rect": [100.0, 100.0, 300.0, 200.0]})).unwrap(); + session.execute("animation.set", &json!({"effect": "fade", "duration": 500})).unwrap(); + let doc = session.active().unwrap().doc.clone(); + let mut harness = harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1100.0, 700.0)), |_| {}); + let ctx = harness.ctx.clone(); + let host = harness.state().host.clone(); + let mut show = Show::new(&doc, 0, false, true); + initialize_inline_frames(&mut show, &ctx, &host); + harness.state_mut().show = Some(show); + for _ in 0..60 { + harness.state_mut().show.as_mut().unwrap().frames.run_inline(16); + harness.step(); + if harness.state().show.as_ref().unwrap().frames.next_texture().is_some() { + break; + } + } + let preview = harness.state().show.as_ref().unwrap().frames.next_source(&ctx).expect("the preview lands").image.clone(); + let [w, h] = preview.size; + let inside = |image: &egui::ColorImage| { + let (x, y) = ((200.0 / doc.slide_size.width * w as f64) as usize, (150.0 / doc.slide_size.height * h as f64) as usize); + image.pixels[y * image.size[0] + x] + }; + let entry = super::render::prefetch_job(doc.clone(), 1, (w as u32, h as u32))(&craft::host::queue::Cancel::default()); + assert_eq!(inside(&entry), entry.pixels[0], "the slide enters without its shape"); + assert_ne!(inside(&preview), preview.pixels[0], "the preview shows the shape that builds in"); +} + /// #1654: Preview on the Transitions ribbon plays the current slide's transition from the /// previous slide into the current slide, and exits when finished. #[test]