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>
87 lines
3.5 KiB
Plaintext
87 lines
3.5 KiB
Plaintext
package moonplasma:host@0.1.0;
|
|
|
|
/// The operating-system surface the compositor component needs, nothing more. The native host
|
|
/// implements it with real syscalls; the component holds only integer handles (fds) and bytes.
|
|
/// Mirrors compositor/sys.
|
|
interface sys {
|
|
/// Listen on a unix socket at `path`; -1 on failure.
|
|
unix-listen: func(path: string) -> s32;
|
|
/// Accept a pending client (non-blocking); -1 when none.
|
|
unix-accept: func(listen-fd: s32) -> s32;
|
|
unix-connect: func(path: string) -> s32;
|
|
close-fd: func(fd: s32);
|
|
unlink: func(path: string);
|
|
/// 1 when `fd` is readable within `timeout-ms`, 0 on timeout, <0 on error.
|
|
poll-read: func(fd: s32, timeout-ms: s32) -> s32;
|
|
|
|
/// Result of `recvmsg`: byte count (-1 would-block, -2 error, 0 EOF), an fd received over
|
|
/// SCM_RIGHTS (-1 when none), and the bytes read.
|
|
record received {
|
|
count: s32,
|
|
fd: s32,
|
|
data: list<u8>,
|
|
}
|
|
recvmsg: func(fd: s32, max-len: u32) -> received;
|
|
/// Send `data`, with `send-fd` (or -1) as SCM_RIGHTS; bytes sent or <0.
|
|
sendmsg: func(fd: s32, data: list<u8>, send-fd: s32) -> s32;
|
|
|
|
memfd-create: func(name: string, size: s32) -> s32;
|
|
pwrite: func(fd: s32, data: list<u8>, offset: s32) -> s32;
|
|
/// Copy `size` bytes of the file behind `fd` (mapped read-only by the host).
|
|
mmap-read: func(fd: s32, size: s32) -> list<u8>;
|
|
/// Copy `len` bytes starting at `offset` of the file behind `fd` (a client's buffer inside its
|
|
/// shared pool; a pool can be far larger than any one buffer, so never read from byte 0).
|
|
mmap-read-at: func(fd: s32, offset: s32, len: s32) -> list<u8>;
|
|
|
|
read-file: func(path: string) -> list<u8>;
|
|
write-file: func(path: string, data: list<u8>) -> s32;
|
|
/// Contents of a small /proc or /sys file ("" when unreadable).
|
|
read-proc: func(path: string) -> list<u8>;
|
|
mkdir-p: func(path: string) -> bool;
|
|
/// Names of the *.desktop files directly in `dir`.
|
|
list-desktop-files: func(dir: string) -> list<string>;
|
|
|
|
sleep-ms: func(ms: s32);
|
|
/// Milliseconds on a monotonic clock (event timestamps).
|
|
monotonic-ms: func() -> u64;
|
|
/// Print a line to the host's stderr.
|
|
log: func(message: string);
|
|
getpid: func() -> s32;
|
|
/// 0 year, 1 month (1-12), 2 day, 3 hour, 4 minute, 5 second, 6 weekday (0 = Sunday).
|
|
wall-time-field: func(which: s32) -> s32;
|
|
getenv: func(name: string) -> string;
|
|
has-exe: func(name: string) -> bool;
|
|
/// Launch `cmd` detached with WAYLAND_DISPLAY set to `display`.
|
|
spawn: func(cmd: string, display: string) -> bool;
|
|
}
|
|
|
|
/// Glyph rasterisation. The component has no C rasteriser, so the host draws glyphs from TTF files
|
|
/// it loads (mirrors compositor/font's native backend: sizes are em sizes in pixels).
|
|
interface font {
|
|
/// Load the TTF file at `path` into `slot` (0..3). False when it can't be read or parsed.
|
|
load: func(slot: u32, path: string) -> bool;
|
|
|
|
/// One rendered glyph: an 8-bit coverage bitmap `width` x `height`, whose top-left sits at
|
|
/// (`xoff`, `yoff`) from the pen on the baseline (y grows downward), and the pen advance.
|
|
record glyph {
|
|
width: s32,
|
|
height: s32,
|
|
xoff: s32,
|
|
yoff: s32,
|
|
advance: s32,
|
|
coverage: list<u8>,
|
|
}
|
|
rasterise: func(slot: u32, codepoint: u32, size: u32) -> glyph;
|
|
}
|
|
|
|
/// The compositor as one component: it imports the OS surface and exports its entry point.
|
|
world compositor {
|
|
import sys;
|
|
import font;
|
|
import plasmoids;
|
|
import display;
|
|
import raster;
|
|
/// Run the compositor until it exits. `args` are the command-line arguments (without argv[0]).
|
|
export run: func(args: list<string>) -> s32;
|
|
}
|