long_screen/engine/mod.rs
1//! One reconstruction run as a state machine over the [`kernels`](crate::kernels).
2//!
3//! The engine does no I/O and reads no clock. A host drives it one step at a time: each pass (scan, solve, render,
4//! reveal, framing, pyramid) is a session that takes one frame (plus the rows the host stored for that frame
5//! earlier) and returns what that step produced — rows to write or delete, structured diagnostics, how far it got.
6//! The host stores the rows, formats and shows the diagnostics, and checks for pause and stop between steps. The
7//! web page's TypeScript loop is one such host (through WebAssembly); the driver at the crate root is another. See
8//! docs/ARCHITECTURE.md §十三 for the boundary.
9//!
10//! Diagnostics carry a code and parameters, never text. `catalog` (feature `catalog`) turns them into the same zh
11//! or en sentence the web page shows, from the catalogues exported out of `src/i18n`; the web page's WebAssembly
12//! formats them with its own i18n and leaves the feature off.
13//!
14//! This is an implementation layer, used by the driver and the web page's WebAssembly; most users want the driver
15//! at the crate root, which drives every pass in order. Its API follows what those hosts need and may change in
16//! minor versions.
17//!
18//! Run the scan pass by hand over a few frames of a page scrolling up by 6 pixels a frame:
19//!
20//! ```
21//! use long_screen::engine::scan::{FrameMeta, ScanSession};
22//!
23//! let (width, height) = (320, 240);
24//! let page = |x: usize, y: usize| ((x * 37 + y * 101 + (x * y) % 23) % 251) as u8;
25//! let mut scan = ScanSession::new(width, height, 1);
26//! for index in 0..4u32 {
27//! let offset = index as usize * 6;
28//! for (i, pixel) in scan.frame_buffer().chunks_exact_mut(4).enumerate() {
29//! let v = page(i % width, i / width + offset);
30//! pixel.copy_from_slice(&[v, v, v, 255]);
31//! }
32//! let step = scan
33//! .push(FrameMeta { index, time: index as f64 / 30.0, duration: 1.0 / 30.0 }, None)
34//! .expect("a frame was written");
35//! for diagnostic in &step.diagnostics {
36//! println!("frame {index}: {}", diagnostic.code);
37//! }
38//! }
39//! let regions = scan.finish(&[]);
40//! println!("{} region(s)", regions.regions.len());
41//! ```
42
43pub mod attachments;
44#[cfg(feature = "catalog")]
45pub mod catalog;
46pub mod compositor;
47pub mod diagnostic;
48pub mod framing;
49pub mod keyframes;
50pub mod layers;
51pub mod overscroll;
52pub mod pose_graph;
53pub mod pyramid;
54pub mod render;
55pub mod reveal;
56pub mod scan;
57pub mod solve;
58pub mod tiles;
59
60#[cfg(test)]
61mod host_tests;
62#[cfg(test)]
63mod presentation_host_tests;
64#[cfg(test)]
65mod reveal_host_tests;