CI / test (push) Failing after 29s
The wasm software renderer cost ~10-20 ns/pixel, so any changed frame took ~100+ ms at 1080p and the desktop swung between idle and very slow. The compositor still builds the scene (windows, decorations, panel, wallpaper) but a new moonplasma:host/raster interface turns it into pixels in the host: - host-wasm/src/raster.rs: a port of compositor/renderer (same blend arithmetic: fills, strokes, lines, circles, text, clips, shadows, surface blits), a wallpaper+desktop-card cache, and captured client surfaces (copied out of the shared memory once at commit, converted to RGBA, solid ones blit as row copies). 9 unit tests; a full frame matches the native software renderer except for text antialiasing (0.3% of pixels). - compositor/raster sends a SceneGraph as ops; compositor.compose_scene() returns it only when something changed. The login session shows the host framebuffer directly (display.present-frame), the nested window gets it as a memfd (raster.export-memfd), --gfx-out reads it (read-frame). - Client buffers never enter wasm: snapshot_shm_buffer captures in the host and keeps an id. - Loop pacing sleeps the rest of the frame budget instead of a fixed 16/8 ms. Full-screen terminal flooding output at 1080p: ~2 fps / 94% CPU -> ~57 fps; idle ~9%. The native build keeps the software renderer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
73 lines
2.2 KiB
MoonBit
73 lines
2.2 KiB
MoonBit
///| Wasm display backend: the same API as kms_native.mbt, but the host owns the display and the
|
|
/// seat (`moonplasma:host/display`). The component sends frames out and reads events in.
|
|
|
|
///|
|
|
pub(all) struct Kms {
|
|
width : Int
|
|
height : Int
|
|
keymap : Bytes
|
|
}
|
|
|
|
///| Take over the first connected output and the seat's input. None when this is not an active
|
|
/// login VT (the host prints why).
|
|
pub fn Kms::open() -> Kms? {
|
|
match @hostdisplay.open() {
|
|
None => None
|
|
Some(o) =>
|
|
Some({
|
|
width: o.width.reinterpret_as_int(),
|
|
height: o.height.reinterpret_as_int(),
|
|
keymap: Bytes::from_fixedarray(o.keymap),
|
|
})
|
|
}
|
|
}
|
|
|
|
///| Service the seat, DRM and input fds. False once Ctrl+Alt+Backspace was pressed.
|
|
pub fn Kms::poll(_self : Kms) -> Bool {
|
|
@hostdisplay.poll()
|
|
}
|
|
|
|
///| True when a new frame can be presented (seat active, no page flip in flight).
|
|
pub fn Kms::frame_ready(_self : Kms) -> Bool {
|
|
@hostdisplay.frame_ready()
|
|
}
|
|
|
|
///| Present a composed frame (its size must match the output mode).
|
|
pub fn Kms::present(_self : Kms, pixmap : @renderer.Pixmap) -> Unit {
|
|
@hostdisplay.present(
|
|
pixmap.data,
|
|
pixmap.width.reinterpret_as_uint(),
|
|
pixmap.height.reinterpret_as_uint(),
|
|
)
|
|
}
|
|
|
|
///| Show the host framebuffer (what the host rasteriser drew) on the output: nothing is copied
|
|
/// through this program.
|
|
pub fn Kms::present_frame(_self : Kms) -> Unit {
|
|
@hostdisplay.present_frame()
|
|
}
|
|
|
|
///| Show the cursor for a wp_cursor_shape_v1 value.
|
|
pub fn Kms::set_cursor_shape(_self : Kms, shape : UInt) -> Unit {
|
|
@hostdisplay.set_cursor_shape(shape)
|
|
}
|
|
|
|
///| Input queued since the last call, in the compositor's event type.
|
|
pub fn Kms::take_input(_self : Kms) -> Array[@nested.InputEvent] {
|
|
let out : Array[@nested.InputEvent] = []
|
|
for ev in @hostdisplay.take_input() {
|
|
match ev {
|
|
PointerMove(p) => out.push(PointerMove(p.x, p.y))
|
|
PointerButton(k) => out.push(PointerButton(k.code, k.pressed))
|
|
Key(k) => out.push(Key(k.code, k.pressed))
|
|
Modifiers(m) => out.push(Modifiers(m.depressed, m.latched, m.locked, m.group))
|
|
}
|
|
}
|
|
out
|
|
}
|
|
|
|
///| Restore the previous video mode and release the seat.
|
|
pub fn Kms::close(_self : Kms) -> Unit {
|
|
@hostdisplay.close()
|
|
}
|