From 68e1d2639d996d2ee7130b90cc865b1489cb7ead Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 20 Nov 2026 13:02:27 +0100 Subject: [PATCH] Add a saved custom picture for blank presentation output --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/pdf-presenter/src/blank.rs | 122 ++++++++++++++++++++++ crates/pdf-presenter/src/lib.rs | 3 + crates/pdf-presenter/src/native.rs | 42 +++++++- crates/pdf-presenter/src/output.rs | 2 + crates/pdf-presenter/src/presenter_ui.rs | 14 +++ crates/pdf-presenter/src/settings.rs | 2 + crates/pdf-presenter/src/studio.rs | 73 ++++++++++++- crates/pdf-presenter/src/worker.rs | 20 ++++ crates/pdf-presenter/tests/blank.rs | 71 +++++++++++++ crates/pdf-presenter/tests/native.rs | 6 ++ docs/changelog.md | 13 +++ docs/interfaces/blank-picture.md | 28 +++++ docs/interfaces/examples/settings-v1.toml | 1 + docs/interfaces/process-protocol.md | 9 ++ docs/interfaces/settings.md | 4 + docs/user-guide.md | 8 ++ 18 files changed, 415 insertions(+), 7 deletions(-) create mode 100644 crates/pdf-presenter/src/blank.rs create mode 100644 crates/pdf-presenter/tests/blank.rs create mode 100644 docs/interfaces/blank-picture.md diff --git a/Cargo.lock b/Cargo.lock index c7227ac..8a8e423 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2245,7 +2245,7 @@ dependencies = [ [[package]] name = "pdf-presenter" -version = "0.1.76" +version = "0.1.77" dependencies = [ "bytemuck", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 4715a33..38f055d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"] resolver = "3" [workspace.package] -version = "0.1.76" +version = "0.1.77" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter" diff --git a/crates/pdf-presenter/src/blank.rs b/crates/pdf-presenter/src/blank.rs new file mode 100644 index 0000000..44bd6b1 --- /dev/null +++ b/crates/pdf-presenter/src/blank.rs @@ -0,0 +1,122 @@ +//! Bounded, worker-only preparation of the optional blank-screen picture. +use crate::{ + document::{Frame, FrameInfo}, + worker::{Bridge, Request}, +}; +use sha2::{Digest, Sha256}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, + time::Duration, +}; + +const EDGE: u32 = 2048; +const MAX_RGBA: usize = EDGE as usize * EDGE as usize * 4; + +/// Copy/normalize a selected image, or load the existing managed copy. +/// Call only in a supervised worker (or tests), never on an input/UI path. +pub fn prepare(source: Option<&Path>, path: &Path) -> Result { + if let Some(source) = source { + let bytes = crate::document::read_limited(source, 64 * 1024 * 1024)?; + let mut reader = image::ImageReader::new(std::io::Cursor::new(bytes)) + .with_guessed_format() + .map_err(|e| e.to_string())?; + let mut limits = image::Limits::default(); + limits.max_alloc = Some(256 * 1024 * 1024); + limits.max_image_width = Some(32768); + limits.max_image_height = Some(32768); + reader.limits(limits); + let image = reader.decode().map_err(|e| e.to_string())?; + let image = if image.width() > EDGE || image.height() > EDGE { + image.resize(EDGE, EDGE, image::imageops::FilterType::Triangle) + } else { + image + } + .to_rgba8(); + let mut data = Vec::with_capacity(image.len() + 40); + data.extend(image.width().to_le_bytes()); + data.extend(image.height().to_le_bytes()); + data.extend(image.as_raw()); + data.extend(Sha256::digest(&data)); + crate::settings::atomic_write(path, &data)?; + } + let data = crate::document::read_limited(path, (MAX_RGBA + 40) as u64)?; + if data.len() < 40 { + return Err("Truncated blank picture".into()); + } + let width = u32::from_le_bytes(data[..4].try_into().unwrap()); + let height = u32::from_le_bytes(data[4..8].try_into().unwrap()); + crate::document::validate_frame(width, height, data.len() - 40)?; + if width > EDGE || height > EDGE { + return Err("Blank picture exceeds 2048 pixels per edge".into()); + } + let end = data.len() - 32; + let hash = Sha256::digest(&data[..end]); + if hash.as_slice() != &data[end..] { + return Err("Blank picture checksum mismatch".into()); + } + Ok(Frame { + info: FrameInfo { + page: 0, + width, + height, + path: path.into(), + sha256: format!("{hash:x}"), + }, + rgba: data[8..end].to_vec(), + }) +} + +/// Output-side loading is independent of slide reads and never reports a picture as a slide. +#[derive(Default)] +pub struct Output { + requested: Option, + loader: Option, + pub picture: Option>, +} +impl Output { + pub fn set(&mut self, info: Option<&FrameInfo>) -> bool { + if self.requested.as_ref().map(identity) == info.map(identity) { + return false; + } + self.requested = info.cloned(); + self.picture = None; + self.loader = info.map(|info| { + let loader = Bridge::new(Duration::from_secs(10)); + loader.submit( + 0, + 0, + Request::BlankPicture { + source: None, + path: info.path.clone(), + }, + ); + loader + }); + true + } + pub fn poll(&mut self) -> Option> { + let completion = self.loader.as_ref()?.rx.try_recv().ok()?; + self.loader = None; + Some((|| { + let packet = completion.result?; + if let Some(error) = packet.reply.error { + return Err(error); + } + let info = packet.reply.frame.ok_or("Missing blank picture")?; + if self.requested.as_ref().map(identity) != Some(identity(&info)) { + return Err( + "Blank picture changed while loading; choose it again to retry.".into(), + ); + } + self.picture = Some(Arc::new(Frame { + info, + rgba: packet.data, + })); + Ok(()) + })()) + } +} +fn identity(info: &FrameInfo) -> (&PathBuf, &str, u32, u32) { + (&info.path, &info.sha256, info.width, info.height) +} diff --git a/crates/pdf-presenter/src/lib.rs b/crates/pdf-presenter/src/lib.rs index 64f7cca..98cd3c1 100644 --- a/crates/pdf-presenter/src/lib.rs +++ b/crates/pdf-presenter/src/lib.rs @@ -101,3 +101,6 @@ pub mod cache; /// Bounded held-input slide navigation. pub mod navigation; + +/// Optional custom blank-screen picture. +pub mod blank; diff --git a/crates/pdf-presenter/src/native.rs b/crates/pdf-presenter/src/native.rs index c5bd7c9..753a413 100644 --- a/crates/pdf-presenter/src/native.rs +++ b/crates/pdf-presenter/src/native.rs @@ -233,7 +233,8 @@ impl NativeWindow { setup.route_trial.is_some(), ); } - if !blank && let Some(frame) = frame { + if let Some(frame) = frame { + let setup = if blank { None } else { setup }; use std::hash::{Hash, Hasher}; let mut hash = std::hash::DefaultHasher::new(); frame.info.path.hash(&mut hash); @@ -289,7 +290,12 @@ impl NativeWindow { ui.max_rect(), tex.id(), [frame.info.width, frame.info.height], - setup.map(|s| s.slide_colors).unwrap_or_default(), + setup + .map(|s| s.slide_colors) + .unwrap_or(crate::settings::SlideColors { + page_background: [0; 3], + fit_padding: [0; 3], + }), crate::zoom::Sync { view, ..setup.map(|s| s.zoom).unwrap_or_default() @@ -441,6 +447,7 @@ struct Host { commands: Receiver, acks: SyncSender, state: HostState, + blank: crate::blank::Output, reader: Bridge, reading: Option, cache: HashMap>, @@ -859,7 +866,11 @@ impl App { repaint |= !actions.is_empty(); for action in actions { #[cfg(target_os = "windows")] - if matches!(action, Action::Pick(_) | Action::PickNotes) && !s.dialog_busy { + if matches!( + action, + Action::Pick(_) | Action::PickNotes | Action::PickBlankPicture + ) && !s.dialog_busy + { use winit::raw_window_handle::{HasWindowHandle, RawWindowHandle}; s.dialog_owner = self .windows @@ -979,6 +990,7 @@ impl App { monitors: s.routes.presentation.clone(), fullscreen: s.presentation_fullscreen(), blanked: s.blanked, + blank_picture: s.blank_picture.as_ref().map(|f| f.info.clone()), ..Default::default() }; if output.tx.try_send(state).is_ok() { @@ -1091,8 +1103,22 @@ impl App { if state.monitors.is_empty() { host.frame = None; } + if host.blank.set(state.blank_picture.as_ref()) { + for w in &mut self.windows { + w.ui.textures.clear(); + } + } host.state = state; } + if let Some(result) = host.blank.poll() { + repaint = true; + if let Err(error) = result { + let _ = host.acks.try_send(Ack { + status: format!("Blank picture: {error}"), + ..Default::default() + }); + } + } if host.zoom_pending && host.parent_connected && Instant::now() >= host.next_zoom_ack { let _ = host.acks.try_send(Ack { zoom: Some(host.state.zoom), @@ -1374,7 +1400,13 @@ impl ApplicationHandler for App { self.windows[index].window.request_redraw() } WindowEvent::RedrawRequested => { - let frame = self.host.as_ref().and_then(|h| h.frame.clone()); + let frame = self.host.as_ref().and_then(|h| { + if h.state.blanked { + h.blank.picture.clone() + } else { + h.frame.clone() + } + }); let blank = self.host.as_ref().is_none_or(|h| h.state.blanked); let result = self.windows[index].render( self.studio.as_mut(), @@ -1598,6 +1630,7 @@ pub fn run_output() -> Result<(), Failure> { commands, acks, state: Default::default(), + blank: Default::default(), reader: Bridge::new(Duration::from_secs(10)), reading: None, cache: HashMap::new(), @@ -1864,6 +1897,7 @@ mod buffer_tests { blanked: false, ..Default::default() }, + blank: Default::default(), reader: Bridge::new(Duration::from_secs(10)), reading: None, cache: HashMap::new(), diff --git a/crates/pdf-presenter/src/output.rs b/crates/pdf-presenter/src/output.rs index c78d98f..5ee0cf4 100644 --- a/crates/pdf-presenter/src/output.rs +++ b/crates/pdf-presenter/src/output.rs @@ -48,6 +48,8 @@ pub struct HostState { pub monitors: Vec, pub fullscreen: bool, pub blanked: bool, + #[serde(default)] + pub blank_picture: Option, pub quit: bool, } /// Actual size of the reference presentation window, never presenter content. diff --git a/crates/pdf-presenter/src/presenter_ui.rs b/crates/pdf-presenter/src/presenter_ui.rs index d98fe54..5af3317 100644 --- a/crates/pdf-presenter/src/presenter_ui.rs +++ b/crates/pdf-presenter/src/presenter_ui.rs @@ -2409,6 +2409,20 @@ fn menu(ui: &mut Ui, s: &mut Studio) { ui.menu_button(tr(&locale,"Preferences"), |ui| { ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| { ui.set_width(370.); + ui.collapsing(if s.settings.language.french() { "Image de présentation masquée" } else { "Blank presentation" }, |ui| { + ui.label(if s.settings.blank_picture { + if s.settings.language.french() { "Image personnalisée sélectionnée" } else { "Custom picture selected" } + } else if s.settings.language.french() { "Écran noir" } else { "Solid black" }); + if ui.add_enabled(s.initialized && !s.dialog_busy && !s.blank_busy, egui::Button::new(if s.settings.language.french() { "Choisir une image…" } else { "Choose picture…" })).clicked() { + s.actions.push(Action::PickBlankPicture); + } + if ui.add_enabled(s.initialized && !s.dialog_busy && (s.settings.blank_picture || s.blank_busy), egui::Button::new(if s.settings.language.french() { "Utiliser un écran noir" } else { "Use solid black" })).clicked() { + s.actions.push(Action::ClearBlankPicture); + } + ui.small(if s.settings.language.french() { "Une copie est conservée et ajustée à tous les écrans de présentation, sur fond noir." } else { "A copy is saved and fitted to all presentation displays against a black background." }); + if s.blank_busy { ui.spinner(); } + }); + ui.separator(); let mut enabled = s.settings.zoom_enabled; if ui.checkbox(&mut enabled, tr(&locale, "Enable page zoom")).changed() { s.enable_zoom(enabled); } if ui.checkbox(&mut s.settings.zoom_keep_fitted_area, tr(&locale, "Keep fitted page area when zooming")).changed() { diff --git a/crates/pdf-presenter/src/settings.rs b/crates/pdf-presenter/src/settings.rs index d438d43..66316dc 100644 --- a/crates/pdf-presenter/src/settings.rs +++ b/crates/pdf-presenter/src/settings.rs @@ -234,6 +234,7 @@ pub struct Settings { pub buffer_mib: u32, pub disk_cache: crate::cache::Policy, pub auto_show: bool, + pub blank_picture: bool, pub zoom_enabled: bool, pub zoom_keep_fitted_area: bool, pub theme: crate::theme::Theme, @@ -279,6 +280,7 @@ impl Default for Settings { buffer_mib: default_buffer_mib(), disk_cache: Default::default(), auto_show: true, + blank_picture: false, zoom_enabled: false, zoom_keep_fitted_area: false, theme: Default::default(), diff --git a/crates/pdf-presenter/src/studio.rs b/crates/pdf-presenter/src/studio.rs index 9eaea28..865a077 100644 --- a/crates/pdf-presenter/src/studio.rs +++ b/crates/pdf-presenter/src/studio.rs @@ -22,6 +22,9 @@ pub enum Action { Open(PathBuf), Pick(bool), PickNotes, + PickBlankPicture, + SetBlankPicture(PathBuf), + ClearBlankPicture, ImportNotes(PathBuf), ApplyNotesImport, Go(usize), @@ -105,6 +108,9 @@ pub struct Studio { pub requested: usize, pub displayed: Option, pub blanked: bool, + pub blank_picture: Option>, + pub blank_busy: bool, + blank_loader: Bridge, pub status: String, pub awake_status: String, pub generation: u64, @@ -215,6 +221,9 @@ impl Studio { requested: 0, displayed: None, blanked: false, + blank_picture: None, + blank_busy: false, + blank_loader: Bridge::with_program(Duration::from_secs(15), worker_program.clone()), status: "Ready — open a PDF or picture folder, or drop it here.".into(), awake_status: "Sleep protection starting…".into(), generation: 0, @@ -424,6 +433,32 @@ impl Studio { self.pending_open = Some(path); self.status = "Opening document in an isolated worker…".into(); } + Action::PickBlankPicture => { + if self.initialized && !self.dialog_busy && !self.blank_busy { + self.dialog_busy = self.dialog.submit( + 0, + 2, + Request::PickBlankPicture { + owner: self.dialog_owner, + }, + ); + } + } + Action::SetBlankPicture(path) => { + if self.initialized && !self.blank_busy { + self.load_blank_picture(Some(path)); + } + } + Action::ClearBlankPicture => { + self.blank_loader = + Bridge::with_program(Duration::from_secs(15), self.worker_program.clone()); + self.blank_busy = false; + self.blank_picture = None; + self.settings.blank_picture = false; + self.new_output = true; + self.pending_save = true; + self.status = "Blank presentation uses solid black.".into(); + } Action::PickNotes => { if !self.dialog_busy && !self.loading @@ -895,7 +930,38 @@ impl Studio { pub fn remember_cache_policy(&mut self) { self.save_preferences(); } + fn load_blank_picture(&mut self, source: Option) { + let path = self.settings_path.with_file_name("blank-picture.rgba"); + self.blank_busy = self.blank_loader.submit( + 0, + u64::from(source.is_some()), + Request::BlankPicture { source, path }, + ); + if self.blank_busy { + self.status = "Preparing blank presentation picture…".into(); + } + } pub fn poll(&mut self) { + while let Ok(c) = self.blank_loader.rx.try_recv() { + self.blank_busy = false; + let result = c.result.and_then(|p| { + if let Some(error) = p.reply.error { + return Err(error); + } + let info = p.reply.frame.ok_or("Missing blank picture")?; + Ok(Arc::new(Frame { info, rgba: p.data })) + }); + match result { + Ok(frame) => { + self.blank_picture = Some(frame); + self.settings.blank_picture = true; + self.pending_save |= c.tag == 1; + self.new_output = true; + self.status = "Blank presentation picture ready.".into(); + } + Err(error) => self.status = format!("Blank picture: {error}"), + } + } while let Ok(c) = self.cache_io.rx.try_recv() { self.cache_busy = false; self.cache_status = match c.result { @@ -991,6 +1057,9 @@ impl Studio { if !self.smoke { self.blanked = !settings.auto_show; self.settings = settings; + if self.settings.blank_picture { + self.load_blank_picture(None); + } self.set_zoom(crate::zoom::View::default()); self.layout = self.settings.for_project(&self.project()); self.presenter_views.clear(); @@ -1028,7 +1097,9 @@ impl Studio { match c.result { Ok(p) => { if let Some(path) = p.reply.picked { - if c.tag == 1 { + if c.tag == 2 { + self.execute(Action::SetBlankPicture(path)); + } else if c.tag == 1 { if c.generation == self.generation { self.execute(Action::ImportNotes(path)); } diff --git a/crates/pdf-presenter/src/worker.rs b/crates/pdf-presenter/src/worker.rs index 3da2911..e998bda 100644 --- a/crates/pdf-presenter/src/worker.rs +++ b/crates/pdf-presenter/src/worker.rs @@ -46,6 +46,13 @@ pub enum Request { source_sha: String, preview: crate::notes::ImportPreview, }, + PickBlankPicture { + owner: Option, + }, + BlankPicture { + source: Option, + path: PathBuf, + }, PickNotes { owner: Option, }, @@ -252,6 +259,19 @@ pub fn run() -> Result<(), String> { preview, )?); } + Request::PickBlankPicture { owner } => { + reply.picked = picker_dialog(owner)? + .add_filter( + "Picture", + &["png", "jpg", "jpeg", "webp", "bmp", "gif", "tif", "tiff"], + ) + .pick_file(); + } + Request::BlankPicture { source, path } => { + let frame = crate::blank::prepare(source.as_deref(), &path)?; + reply.frame = Some(frame.info); + data = frame.rgba; + } Request::PickNotes { owner } => { reply.picked = picker_dialog(owner)? .add_filter("Notes (TXT, Markdown)", &["txt", "md"]) diff --git a/crates/pdf-presenter/tests/blank.rs b/crates/pdf-presenter/tests/blank.rs new file mode 100644 index 0000000..adc0175 --- /dev/null +++ b/crates/pdf-presenter/tests/blank.rs @@ -0,0 +1,71 @@ +mod common; +use pdf_presenter::{ + blank, + studio::{Action, Studio}, +}; +use std::time::{Duration, Instant}; + +#[test] +fn managed_picture_is_bounded_durable_and_checked() { + let dir = tempfile::tempdir().unwrap(); + let source = dir.path().join("source.png"); + let target = dir.path().join("blank-picture.rgba"); + image::RgbaImage::from_pixel(3000, 1500, image::Rgba([10u8, 20, 30, 128])) + .save(&source) + .unwrap(); + let original = std::fs::read(&source).unwrap(); + let frame = blank::prepare(Some(&source), &target).unwrap(); + assert_eq!((frame.info.width, frame.info.height), (2048, 1024)); + assert_eq!(original, std::fs::read(&source).unwrap()); + std::fs::remove_file(&source).unwrap(); + assert_eq!(blank::prepare(None, &target).unwrap().rgba, frame.rgba); + assert!(blank::prepare(Some(&source), &target).is_err()); + assert_eq!( + blank::prepare(None, &target).unwrap().info.sha256, + frame.info.sha256 + ); + let mut data = std::fs::read(&target).unwrap(); + data[8] ^= 1; + std::fs::write(&target, data).unwrap(); + assert!( + blank::prepare(None, &target) + .err() + .unwrap() + .contains("checksum") + ); + std::fs::write(&target, b"bad").unwrap(); + assert!(blank::prepare(None, &target).is_err()); +} + +fn until(s: &mut Studio, done: impl Fn(&Studio) -> bool) { + let deadline = Instant::now() + Duration::from_secs(10); + while !done(s) { + assert!(Instant::now() < deadline, "{}", s.status); + s.poll(); + std::thread::sleep(Duration::from_millis(5)); + } +} +#[test] +fn worker_import_failure_and_clear_preserve_blank_state() { + let dir = tempfile::tempdir().unwrap(); + let source = dir.path().join("picture.png"); + common::image(&source, [20, 50, 90, 255]); + let mut s = Studio::with_program(true, None, env!("CARGO_BIN_EXE_pdf-presenter").into()); + until(&mut s, |s| s.initialized); + s.blanked = true; + s.execute(Action::SetBlankPicture(source.clone())); + until(&mut s, |s| !s.blank_busy); + assert!(s.settings.blank_picture && s.blanked); + let hash = s.blank_picture.as_ref().unwrap().info.sha256.clone(); + std::fs::remove_file(source.clone()).unwrap(); + s.execute(Action::SetBlankPicture(source)); + until(&mut s, |s| !s.blank_busy); + assert_eq!(s.blank_picture.as_ref().unwrap().info.sha256, hash); + assert!(s.blanked); + let encoded = toml::to_string(&s.settings).unwrap(); + let decoded: pdf_presenter::settings::Settings = toml::from_str(&encoded).unwrap(); + assert!(decoded.blank_picture); + s.execute(Action::ClearBlankPicture); + assert!(s.blanked && s.blank_picture.is_none() && !s.settings.blank_picture); + assert!(!pdf_presenter::settings::Settings::default().blank_picture); +} diff --git a/crates/pdf-presenter/tests/native.rs b/crates/pdf-presenter/tests/native.rs index 838dcc5..760f0e2 100644 --- a/crates/pdf-presenter/tests/native.rs +++ b/crates/pdf-presenter/tests/native.rs @@ -109,6 +109,11 @@ fn independent_output_acknowledges_frames_and_blanking() { } let doc = Document::open(temp.path(), temp.path().join("cache")).unwrap(); let frames: Vec<_> = (0..8).map(|page| doc.render(page, 320).unwrap()).collect(); + let blank_picture = pdf_presenter::blank::prepare( + Some(&temp.path().join("slide0.png")), + &temp.path().join("blank-picture.rgba"), + ) + .unwrap(); struct ChildGuard(std::process::Child); impl Drop for ChildGuard { fn drop(&mut self) { @@ -223,6 +228,7 @@ fn independent_output_acknowledges_frames_and_blanking() { monitors: vec![monitor.clone()], fullscreen: false, blanked, + blank_picture: Some(blank_picture.info.clone()), ..Default::default() }, ) diff --git a/docs/changelog.md b/docs/changelog.md index 0bf30d9..f34cdd0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,19 @@ ## Unreleased +### 0.1.77 + +- Add an optional custom picture for Blank presentation in Preferences, shared by + all audience displays, with a control to restore solid black. +- Save a bounded managed copy independently of the slide cache; load and decode + in supervised workers. Fit it against black without slide zoom or annotations. + Failed imports retain the previous choice; unavailable saved pictures fall back + to black without exposing slides. +- Linux workspace/native tests, 13 Python tests, formatting, Clippy, rustdoc and + optimized build pass; whole-application line coverage is 84.56%. Windows and + physical-display acceptance remain pending for this change. + + ### 0.1.76 - Give every presenter display its own complete visual layout, presets, local diff --git a/docs/interfaces/blank-picture.md b/docs/interfaces/blank-picture.md new file mode 100644 index 0000000..c87499e --- /dev/null +++ b/docs/interfaces/blank-picture.md @@ -0,0 +1,28 @@ +# Managed blank picture v1 + +One optional asset lives at `blank-picture.rgba` next to settings.toml. Settings v1 +`blank_picture` selects it; missing/false means solid black. It is independent of +document caches and their cleanup. Reset disables the asset, retaining at most +one bounded file; the next successful import atomically replaces it. + +The v1 binary representation uses the existing frame envelope: unsigned +little-endian u32 width, u32 height, row-major unpremultiplied RGBA8 pixels, then +32 raw SHA256 bytes covering the header and pixels. Width and height must be +1–2048; length must be exactly 8 + width × height × 4 + 32 bytes. Maximum file +size is 16 MiB + 40 bytes. FrameInfo.sha256 is lowercase hex of that same digest. +Invalid dimensions, lengths or checksum are rejected; there is no permissive +interpretation of other versions. No source filename or operator notes are stored. + +A killable worker reads at most 64 MiB of source data, with image decoder limits +of 256 MiB allocation and 32768 pixels per source edge. Images are proportionally +resized to fit 2048 × 2048 without upscaling; animated sources use a still frame. +Import failure preserves the existing copy/selection. The original is read-only. + +The presenter and output each retain at most 16 MiB of decoded blank pixels, +separately from slide-cache budgets; native output textures are bounded per +window. Loading is asynchronous and the output compares the returned digest, +dimensions and path with its request to reject stale replacement reads. +A missing/corrupt asset stays black; no slide is substituted. Output fits the +whole image on black, including transparency, without zoom or annotations. +Tests cover normalized import/load round trips, deleted sources, corruption, +failed replacement, worker import/reset and native blank/show acknowledgements. diff --git a/docs/interfaces/examples/settings-v1.toml b/docs/interfaces/examples/settings-v1.toml index 94638e4..196d551 100644 --- a/docs/interfaces/examples/settings-v1.toml +++ b/docs/interfaces/examples/settings-v1.toml @@ -1,5 +1,6 @@ version = 1 auto_show = true +blank_picture = false zoom_enabled = false zoom_keep_fitted_area = false theme = "midra" diff --git a/docs/interfaces/process-protocol.md b/docs/interfaces/process-protocol.md index f4de0a3..bd03004 100644 --- a/docs/interfaces/process-protocol.md +++ b/docs/interfaces/process-protocol.md @@ -205,3 +205,12 @@ runs on a dedicated 30-second supervised worker, one outstanding job per present The reply adds optional `cleanup` with unsigned `removed_bytes`, `remaining_bytes`, `removed_files`, and `skipped_files`. Errors use the existing error field. No frame payload is transferred. The same-build private protocol requires no migration. + +The optional full HostState field `blank_picture: FrameInfo | null` (0.1.77) +identifies the managed blank image by path, dimensions and content SHA256. +Lightweight updates retain it. A separate supervised worker reads it; the output +validates identity before accepting the pixels. It is never acknowledged as a +slide, and a failed read leaves blank output black. Worker requests +`PickBlankPicture { owner }` and `BlankPicture { source, path }` select and +import/load the asset; source null loads the stored copy. See +[blank picture](blank-picture.md) for bounds. diff --git a/docs/interfaces/settings.md b/docs/interfaces/settings.md index 0dd5d89..ffdfc67 100644 --- a/docs/interfaces/settings.md +++ b/docs/interfaces/settings.md @@ -137,3 +137,7 @@ Transient display trials/startup recovery eligibility, reveals, blank/current/se Change on click and worker state are not persisted. HTML prototype localStorage is separate and is not automatically imported. See `examples/settings-v1.toml` and round-trip/invalid-version tests in `tests/settings.rs`. + +- `blank_picture`: optional boolean (0.1.77), default false. True selects the + managed [blank picture](blank-picture.md); false uses solid black. Missing or + invalid assets fall back to black. Existing v1 files migrate by defaulting false. diff --git a/docs/user-guide.md b/docs/user-guide.md index e8b0ecf..e066e5b 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -413,3 +413,11 @@ available immediately. background. Active decks are protected and may temporarily exceed either limit. The cleanup report shows removed and remaining data; deleted slides regenerate when reopened. Source documents and presenter notes are preserved. + +Choose **Preferences → Blank presentation → Choose picture…** to replace the +black blanking screen with your own picture on every audience display. The app +saves a copy, fits the whole image against black, and remembers it across restarts. +The original may then be moved or removed. Use **Use solid black** to reset. +Pictures are resized to at most 2048 pixels per edge; animated images use a still +frame. Slide zoom, annotations and slide background colors do not affect it. +The existing Blank presentation button and B shortcut still hide/show slides.