Screenshots, recording and --gfx-out keep the screen's pixels on the host
CI / test (push) Failing after 17s

New chandra:host/raster functions, on both hosts: write-frame-png (--gfx-out),
grab-recording-frame / send-recording-frame (the recorder streams frames from the
host to ffmpeg) and snapshot-frame / snapshot-png / snapshot-pixels (screenshots
freeze, crop and encode the screen there; the magnifier and the notification's
thumbnail read small scaled copies). The wasm compositor sets them up through
frame_recorder and frame_shots; the native compositor keeps its pixel path.

Moving whole frames as list<u8> is cheap for the Rust host but costs about
0.4 s a 720p frame through the wasmtime C API. A full-screen screenshot now takes
45 ms on the MoonBit host (was 472) and 8 ms on the Rust host (was 112);
recording runs at 30 fps on both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiNfjrw2edja7LiRLB
This commit is contained in:
Claude committed 2026-11-25 20:03:34 +00:00
1 parent 3b15248124
commit caa12058fd
13 files changed
+668 -26

No files matched your search

+20
View File
@@ -69,4 +69,24 @@ interface raster {
/// A new memfd holding the framebuffer as little-endian ARGB8888, ready to hand to a Wayland
/// compositor as a wl_shm pool. The caller closes it. -1 on failure.
export-memfd: func() -> s32;
/// Save the framebuffer as a PNG file at `path` (--gfx-out, tests): the pixels stay on the
/// host. False when it can't be written.
write-frame-png: func(path: string) -> bool;
/// Screen recording, without the pixels crossing into the component: copy the framebuffer's
/// `x`, `y`, `w` x `h` (on screen) into the host's recording frame as opaque RGBA8888, with an
/// arrow pointer drawn at screen position (`px`, `py`) when `pointer`. It replaces a frame
/// still being sent. False when the rectangle is not on screen.
grab-recording-frame: func(x: s32, y: s32, w: s32, h: s32, pointer: bool, px: s32, py: s32) -> bool;
/// Write what is left of the recording frame to `fd` (a socket; made non-blocking): the bytes
/// still left after this (0: it all went out), or -1 when the write failed.
send-recording-frame: func(fd: s32) -> s32;
/// Screenshots, without the whole screen crossing into the component: freeze the framebuffer
/// on the host as the snapshot (replacing the last one). False when there is no framebuffer.
snapshot-frame: func() -> bool;
/// The snapshot's `x`, `y`, `w` x `h` (clipped to it), made opaque, as PNG file bytes. Empty
/// when the rectangle misses it.
snapshot-png: func(x: s32, y: s32, w: s32, h: s32) -> list<u8>;
/// The snapshot's `x`, `y`, `w` x `h` scaled (nearest pixel) to `out-w` x `out-h`, as opaque
/// RGBA8888 (the magnifier, the notification's thumbnail). Pixels off the snapshot are black.
snapshot-pixels: func(x: s32, y: s32, w: s32, h: s32, out-w: s32, out-h: s32) -> list<u8>;
}