Files
chandra/compositor/raster/raster_native.mbt
T
Claude 9f7489cfea
CI / test (push) Failing after 12m30s
Face unlock window: live camera preview, Snap, thumbnails, one password on Apply
Settings > Session "Add or remove faces…" (and "Remove…" on a face) opens a
compositor-drawn Face unlock window instead of running root steps one by one:

- chandra-face camera runs as the user (no password): it streams a small live
  picture with the face box and a cropped thumbnail per snap; the snaps'
  embeddings stay in that process, nothing is written to disk.
- Click a snap to drop it; mark saved faces Remove/Keep.
- Apply saves the snaps as one face and removes the marked ones in one root
  `chandra-face apply` (JSON on stdin, validated) through run0/pkexec: one
  password prompt.
- New raster host function image-pixels (host-wasm, wasmhost, native) for the
  window's pictures.

Tests: camera session and apply in face/test_face.py; the window end to end
against a fake tool in compositor/host/face_test.mbt. Docs explain why the
change itself still needs root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhiJfJNAYqWzQiuKMf
2026-11-26 02:36:29 +00:00

79 lines
2.3 KiB
MoonBit

///| The native build draws with the software renderer (`@renderer.render_scene`); there is no host
/// to send a scene to.
///|
pub fn submit(_scene : @scene.SceneGraph) -> Unit {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn read_frame(_width : Int, _height : Int) -> @renderer.Pixmap {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn write_frame_png(_path : String) -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn grab_recording_frame(_r : @scene.Rect, _pointer : Bool, _px : Int, _py : Int) -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn send_recording_frame(_fd : Int) -> Int {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_frame() -> Bool {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_png(_r : @scene.Rect) -> Bytes {
abort("the host rasteriser is only available to the wasm compositor")
}
///|
pub fn snapshot_pixels(_r : @scene.Rect, _w : Int, _h : Int) -> @renderer.Pixmap {
abort("the host rasteriser is only available to the wasm compositor")
}
///| `w` x `h` RGBA pixels as an image (`reuse`: an earlier handle of this kind to overwrite, or 0).
pub fn image_pixels(w : Int, h : Int, rgba : Bytes, reuse : UInt) -> UInt {
if w <= 0 || h <= 0 || w > 1024 || h > 1024 || rgba.length() < w * h * 4 {
return 0U
}
let p : @renderer.Pixmap = { width: w, height: h, data: rgba.to_fixedarray() }
if reuse == 0U {
@renderer.add_image(p)
} else {
@renderer.set_image(reuse, p)
}
}
///| Images already loaded, by path (0: it failed, don't try again).
let loaded_images : Map[String, UInt] = {}
///| Load the image file at `path` for `Image` draw ops: a handle, or 0 when it can't be decoded.
/// The software renderer only reads PNG (an SVG icon gets 0, and the caller's fallback).
pub fn load_image(path : String) -> UInt {
match loaded_images.get(path) {
Some(h) => h
None => {
let h = if path.has_suffix(".png") {
match @renderer.decode_png(@sys.read_file_bytes(path)) {
Some(p) => @renderer.add_image(p)
None => 0U
}
} else {
0U
}
loaded_images.set(path, h)
h
}
}
}