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

+13 -2
View File
@@ -144,12 +144,23 @@ pub fn run(args : Array[String]) -> Int {
comp.shell.screen_w = width
// Screenshots and recordings read the host's framebuffer (it draws the desktop).
comp.frame_source = Some(fn() { Some(@raster.read_frame(comp.output_w, comp.output_h)) })
// Recording streams frames from the host straight to the encoder.
comp.frame_recorder = Some({
grab: fn(r, pointer, px, py) { @raster.grab_recording_frame(r, pointer, px, py) },
send: fn(fd) { @raster.send_recording_frame(fd) },
})
// And screenshots crop and encode the frozen screen there.
comp.frame_shots = Some({
snapshot: fn() { @raster.snapshot_frame() },
png: fn(r) { @raster.snapshot_png(r) },
pixels: fn(r, w, h) { @raster.snapshot_pixels(r, w, h) },
})
if gfx_out.length() > 0 && !serve {
match comp.compose_scene() {
Some(sg) => @raster.submit(sg)
None => ()
}
ignore(@sys.write_file_bytes(gfx_out, @renderer.encode_png(@raster.read_frame(width, height))))
ignore(@raster.write_frame_png(gfx_out))
comp.close()
@sys.log("frame written to " + gfx_out)
return 0
@@ -329,7 +340,7 @@ pub fn run(args : Array[String]) -> Int {
}
// No display: --serve keeps a PNG of the latest frame for looking at a live compositor.
if serve && gfx_out.length() > 0 && frames % 30 == 0 && need_present {
ignore(@sys.write_file_bytes(gfx_out, @renderer.encode_png(@raster.read_frame(width, height))))
ignore(@raster.write_frame_png(gfx_out))
need_present = false
}
busy = busy || need_present