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

+31
View File
@@ -97,6 +97,37 @@ pub fn read_frame(width : Int, height : Int) -> @renderer.Pixmap {
{ width, height, data }
}
///| Save the host framebuffer as a PNG at `path` (the pixels never leave the host).
pub fn write_frame_png(path : String) -> Bool {
@hostraster.write_frame_png(path)
}
///| Copy `r` of the host framebuffer into the host's recording frame (pointer drawn at screen
/// position (`px`, `py`) when `pointer`).
pub fn grab_recording_frame(r : @scene.Rect, pointer : Bool, px : Int, py : Int) -> Bool {
@hostraster.grab_recording_frame(r.x, r.y, r.w, r.h, pointer, px, py)
}
///| Write what is left of the recording frame to `fd`: the bytes still left, or -1.
pub fn send_recording_frame(fd : Int) -> Int {
@hostraster.send_recording_frame(fd)
}
///| Freeze the host framebuffer as the screenshot snapshot.
pub fn snapshot_frame() -> Bool {
@hostraster.snapshot_frame()
}
///| `r` of the snapshot, opaque, as PNG bytes.
pub fn snapshot_png(r : @scene.Rect) -> Bytes {
Bytes::from_fixedarray(@hostraster.snapshot_png(r.x, r.y, r.w, r.h))
}
///| `r` of the snapshot scaled to `w` x `h`, opaque.
pub fn snapshot_pixels(r : @scene.Rect, w : Int, h : Int) -> @renderer.Pixmap {
{ width: w, height: h, data: @hostraster.snapshot_pixels(r.x, r.y, r.w, r.h, w, h) }
}
///| Images already loaded, by path (0: it failed, don't ask the host again).
let loaded_images : Map[String, UInt] = {}