mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 08:46:06 -10:00
A video takes the fed path (pages handed to the encoder on the GPU), whose program has no camera row; runtime/view's camera_bg then gave raea's old dark blue (13,10,26), so every transparent part of an mp4 or mov was navy while the same frame as a PNG (raea-export's program, which clears 2D pages to #000000) was black. #13's snapcn sweep met it: text-swap, text-build, text-highlight and cursor-track read as a 0.52 SSIM drop against Chrome until the harness's page took the navy. The default is now black, as program.rs's. bench/clear-backdrop/check.sh: white text on nothing to an mp4 and a PNG, both corners black. Before: the mp4's 13,9,26 (the 02:20 build), the PNG 0,0,0. After: both 0,0,0.
28 lines
1.6 KiB
Rust
28 lines
1.6 KiB
Rust
//! The direct render's views: an edit's frames without the Bevy frame loop, on the GPU (gpuview.rs: the GPU pool,
|
|
//! the Blitz overlay and one composite.k dispatch a frame) or on the CPU (cpuview.rs, the same frames by the kernels'
|
|
//! native twins), and what they share with the engine's overlay: the 2D rows (rows.rs) drawn by Blitz (rows2d.rs),
|
|
//! clips' masks (masks.rs), and the paint device as Bevy's renderer with the frame pool's budget (device.rs).
|
|
|
|
pub mod cpuview;
|
|
mod device;
|
|
pub use device::*;
|
|
pub mod gpuview;
|
|
pub mod masks;
|
|
pub mod rows;
|
|
pub mod rows2d;
|
|
|
|
/// The camera's clear colour (its `bg`, #rrggbb or #rrggbbaa) as a premultiplied RGBA texel; black when it has none,
|
|
/// as raea-export's program clears under 2D pages (a fed video's program has no camera: its transparent parts were
|
|
/// raea's dark blue, 13,10,26, where a PNG of the same frame is black). An alpha under ff (an HTML page's canvas under
|
|
/// --alpha, #00000000) stays: it was read as opaque, so the clear canvas came out black (#32).
|
|
pub(crate) fn camera_bg(rows: &[raea_core_program::eval::Tup]) -> [u8; 4] {
|
|
let hex = rows.iter().find(|t| t.kind == "camera").and_then(|t| match t.vals.get("bg") {
|
|
Some(raea_core_program::ir::V::S(s)) => Some(s.trim_start_matches('#').to_string()),
|
|
_ => None,
|
|
});
|
|
let b = |h: &str, i: usize| u8::from_str_radix(h.get(i..i + 2)?, 16).ok();
|
|
let Some((rgb, a)) = hex.and_then(|h| Some(([b(&h, 0)?, b(&h, 2)?, b(&h, 4)?], if h.len() == 8 { b(&h, 6)? } else { 255 }))) else { return [0, 0, 0, 255] };
|
|
let pre = |c: u8| ((c as u32 * a as u32 + 127) / 255) as u8;
|
|
[pre(rgb[0]), pre(rgb[1]), pre(rgb[2]), a]
|
|
}
|