Draw in the host: the wasm compositor sends draw ops, the host rasterises natively
CI / test (push) Failing after 29s
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>
This commit is contained in:
1 parent
66bf293085
commit
c6e31b4a8f
38 files changed
+2141
-220
No files matched your search
@@ -12,6 +12,9 @@ fn wasmImportFrameReady() -> Int = "moonplasma:host/display@0.1.0" "frame-ready"
|
||||
///|
|
||||
fn wasmImportPresent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) = "moonplasma:host/display@0.1.0" "present"
|
||||
|
||||
///|
|
||||
fn wasmImportPresentFrame() = "moonplasma:host/display@0.1.0" "present-frame"
|
||||
|
||||
///|
|
||||
fn wasmImportSetCursorShape(p0 : Int) = "moonplasma:host/display@0.1.0" "set-cursor-shape"
|
||||
|
||||
@@ -21,26 +24,27 @@ fn wasmImportTakeInput(p0 : Int) = "moonplasma:host/display@0.1.0" "take-input"
|
||||
///|
|
||||
fn wasmImportClose() = "moonplasma:host/display@0.1.0" "close"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_loadf64(offset : Int) -> Double =
|
||||
#|(func (param i32) (result f64) local.get 0 f64.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_loadf64(offset : Int) -> Double =
|
||||
#|(func (param i32) (result f64) local.get 0 f64.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
@@ -49,10 +53,9 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
@@ -20,6 +20,11 @@ fn wasmImportPresent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportPresentFrame() -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportSetCursorShape(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
@@ -35,28 +40,18 @@ fn wasmImportClose() -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_loadf64(offset : Int) -> Double {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -66,6 +61,16 @@ fn mbt_ffi_free(position : Int) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
fn mbt_ffi_loadf64(offset : Int) -> Double {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
@@ -74,6 +74,13 @@ pub fn present(pixels : FixedArray[Byte], width : UInt, height : UInt) -> Unit {
|
||||
wasmImportPresent(ptr, pixels.length(), (width).reinterpret_as_int(), (height).reinterpret_as_int());
|
||||
mbt_ffi_free(ptr)
|
||||
|
||||
}
|
||||
///|
|
||||
/// Show the host framebuffer (what `raster.submit` drew) on the output.
|
||||
pub fn present_frame() -> Unit {
|
||||
|
||||
wasmImportPresentFrame();
|
||||
|
||||
}
|
||||
///|
|
||||
/// Show the cursor for a wp_cursor_shape_v1 value.
|
||||
|
||||
@@ -7,9 +7,8 @@ fn wasmImportLoad(p0 : Int, p1 : Int, p2 : Int) -> Int = "moonplasma:host/font@0
|
||||
fn wasmImportRasterise(p0 : Int, p1 : Int, p2 : Int, p3 : Int) = "moonplasma:host/font@0.1.0" "rasterise"
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
@@ -18,6 +17,11 @@ extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
@@ -29,7 +33,3 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
@@ -11,7 +11,7 @@ fn wasmImportRasterise(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
@@ -29,8 +34,3 @@ fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
@@ -46,21 +46,26 @@ fn wasmImportPickerStart() -> Int = "moonplasma:host/plasmoids@0.1.0" "picker-st
|
||||
fn wasmImportPickerPoll(p0 : Int) = "moonplasma:host/plasmoids@0.1.0" "picker-poll"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
|
||||
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
|
||||
#|(func (param i32) (result i64) local.get 0 i64.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
@@ -68,19 +73,6 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
@@ -89,11 +81,19 @@ extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
|
||||
#|(func (param i32) (result i64) local.get 0 i64.load)
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
@@ -75,6 +75,41 @@ fn wasmImportPickerPoll(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load64(offset : Int) -> Int64 {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
@@ -86,22 +121,7 @@ fn mbt_ffi_free(position : Int) -> Unit {
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store64(offset : Int, value : Int64) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
@@ -109,23 +129,3 @@ fn mbt_ffi_load8_u(offset : Int) -> Int {
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load64(offset : Int) -> Int64 {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportCapture(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int) -> Int = "moonplasma:host/raster@0.1.0" "capture"
|
||||
|
||||
///|
|
||||
fn wasmImportRelease(p0 : Int) = "moonplasma:host/raster@0.1.0" "release"
|
||||
|
||||
///|
|
||||
fn wasmImportSubmit(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int, p9 : Int, p10 : Int, p11 : Int, p12 : Int) = "moonplasma:host/raster@0.1.0" "submit"
|
||||
|
||||
///|
|
||||
fn wasmImportReadFrame(p0 : Int) = "moonplasma:host/raster@0.1.0" "read-frame"
|
||||
|
||||
///|
|
||||
fn wasmImportExportMemfd() -> Int = "moonplasma:host/raster@0.1.0" "export-memfd"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
warnings = "-44"
|
||||
|
||||
// ffi.mbt is generated and wasm-only; native builds use native_stub.mbt (scripts/gen-native-stubs.py).
|
||||
options(
|
||||
targets: {
|
||||
"ffi.mbt": ["wasm", "wasm-gc"],
|
||||
"native_stub.mbt": ["native"],
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
// Generated by scripts/gen-native-stubs.py. Native stand-ins for the wasm-only ffi.mbt.
|
||||
|
||||
///|
|
||||
fn wasmImportCapture(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int) -> Int {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportRelease(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportSubmit(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int, p9 : Int, p10 : Int, p11 : Int, p12 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportReadFrame(p0 : Int) -> Unit {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn wasmImportExportMemfd() -> Int {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store8(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_store32(offset : Int, value : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
@@ -0,0 +1,550 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct Rect {
|
||||
x : Int; y : Int; w : Int; h : Int
|
||||
}
|
||||
///|
|
||||
pub(all) struct Color {
|
||||
r : Byte; g : Byte; b : Byte; a : Byte
|
||||
}
|
||||
///|
|
||||
pub(all) struct Fill {
|
||||
area : Rect; color : Color; radius : Int
|
||||
}
|
||||
///|
|
||||
pub(all) struct Stroke {
|
||||
area : Rect; color : Color; width : Int; radius : Int
|
||||
}
|
||||
///|
|
||||
pub(all) struct Segment {
|
||||
x0 : Int; y0 : Int; x1 : Int; y1 : Int; color : Color; width : Int
|
||||
}
|
||||
///|
|
||||
pub(all) struct Disc {
|
||||
cx : Int; cy : Int; radius : Int; color : Color; filled : Bool
|
||||
}
|
||||
///|
|
||||
/// `align`: 0 left, 1 centre, 2 right of `x`; `y` is the text's vertical centre.
|
||||
pub(all) struct Label {
|
||||
x : Int; y : Int; text : String; size : Int; color : Color; align : Byte; bold : Bool; mono : Bool
|
||||
}
|
||||
///|
|
||||
pub(all) enum Op {
|
||||
FillRect(Fill)
|
||||
StrokeRect(Stroke)
|
||||
DrawLine(Segment)
|
||||
DrawCircle(Disc)
|
||||
DrawText(Label)
|
||||
PushClip(Rect)
|
||||
PopClip
|
||||
}
|
||||
///|
|
||||
/// A toplevel: its decoration (drawn at `geometry` minus the insets), then its client surface.
|
||||
pub(all) struct Window {
|
||||
geometry : Rect; inset_top : Int; inset_right : Int; inset_bottom : Int; inset_left : Int; deco : Array[Op]; fullscreen : Bool; surface : UInt
|
||||
}
|
||||
///|
|
||||
pub(all) struct Popup {
|
||||
area : Rect; surface : UInt
|
||||
}
|
||||
///|
|
||||
pub(all) struct Frame {
|
||||
width : Int; height : Int; wallpaper : Array[Op]?; background : Array[Op]; windows : Array[Window]; panel : Array[Op]; popups : Array[Popup]
|
||||
}
|
||||
///|
|
||||
/// Copy a client buffer (`stride * height` bytes at `offset` of the file behind `fd`) into a
|
||||
/// host surface. `format` is the wl_shm format (0 ARGB8888, 1 XRGB8888). 0 on failure.
|
||||
pub fn capture(fd : Int, offset : Int, stride : Int, width : Int, height : Int, format : Int) -> UInt {
|
||||
|
||||
let result : Int = wasmImportCapture(fd, offset, stride, width, height, format);
|
||||
let ret = (result).reinterpret_as_uint()
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn release(id : UInt) -> Unit {
|
||||
|
||||
wasmImportRelease((id).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Draw a frame into the host framebuffer.
|
||||
pub fn submit(f : Frame) -> Unit {
|
||||
let cleanup_list : Array[Int] = []
|
||||
|
||||
let (lowered, lowered8, lowered9) = match ((f).wallpaper) {
|
||||
None => {
|
||||
|
||||
((0), 0, 0)
|
||||
}
|
||||
Some(payload0) => {
|
||||
|
||||
let address = mbt_ffi_malloc((payload0).length() * 32);
|
||||
for index = 0; index < (payload0).length(); index = index + 1 {
|
||||
let iter_elem : Op = (payload0)[(index)]
|
||||
let iter_base = address + (index * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload1) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload1).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload1).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload1).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload1).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload1).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload1).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload1).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload1).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload1).radius)
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload2) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload2).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload2).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload2).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload2).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload2).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload2).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload2).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload2).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload2).width)
|
||||
mbt_ffi_store32((iter_base) + 28, (payload2).radius)
|
||||
|
||||
()
|
||||
}
|
||||
DrawLine(payload3) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload3).x0)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload3).y0)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload3).x1)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload3).y1)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload3).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload3).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload3).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload3).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload3).width)
|
||||
|
||||
()
|
||||
}
|
||||
DrawCircle(payload4) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload4).cx)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload4).cy)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload4).radius)
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload4).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload4).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload4).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload4).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload4).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
DrawText(payload5) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload5).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload5).y)
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((payload5).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload5).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr)
|
||||
mbt_ffi_store32((iter_base) + 20, (payload5).size)
|
||||
mbt_ffi_store8((iter_base) + 24, (((payload5).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, (((payload5).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, (((payload5).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, (((payload5).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload5).align).to_int())
|
||||
mbt_ffi_store8((iter_base) + 29, (if (payload5).bold { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 30, (if (payload5).mono { 1 } else { 0 }))
|
||||
cleanup_list.push(ptr)
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload6) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload6).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload6).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload6).w)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload6).h)
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
cleanup_list.push(address)
|
||||
|
||||
((1), address, (payload0).length())
|
||||
}
|
||||
}
|
||||
|
||||
let address18 = mbt_ffi_malloc(((f).background).length() * 32);
|
||||
for index19 = 0; index19 < ((f).background).length(); index19 = index19 + 1 {
|
||||
let iter_elem : Op = ((f).background)[(index19)]
|
||||
let iter_base = address18 + (index19 * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload10) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload10).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload10).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload10).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload10).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload10).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload10).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload10).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload10).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload10).radius)
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload11) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload11).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload11).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload11).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload11).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload11).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload11).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload11).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload11).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload11).width)
|
||||
mbt_ffi_store32((iter_base) + 28, (payload11).radius)
|
||||
|
||||
()
|
||||
}
|
||||
DrawLine(payload12) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload12).x0)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload12).y0)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload12).x1)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload12).y1)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload12).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload12).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload12).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload12).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload12).width)
|
||||
|
||||
()
|
||||
}
|
||||
DrawCircle(payload13) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload13).cx)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload13).cy)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload13).radius)
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload13).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload13).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload13).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload13).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload13).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
DrawText(payload14) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload14).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload14).y)
|
||||
|
||||
let ptr15 = mbt_ffi_str2ptr((payload14).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload14).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr15)
|
||||
mbt_ffi_store32((iter_base) + 20, (payload14).size)
|
||||
mbt_ffi_store8((iter_base) + 24, (((payload14).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, (((payload14).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, (((payload14).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, (((payload14).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload14).align).to_int())
|
||||
mbt_ffi_store8((iter_base) + 29, (if (payload14).bold { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 30, (if (payload14).mono { 1 } else { 0 }))
|
||||
cleanup_list.push(ptr15)
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload16) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload16).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload16).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload16).w)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload16).h)
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let address30 = mbt_ffi_malloc(((f).windows).length() * 48);
|
||||
for index31 = 0; index31 < ((f).windows).length(); index31 = index31 + 1 {
|
||||
let iter_elem : Window = ((f).windows)[(index31)]
|
||||
let iter_base = address30 + (index31 * 48);
|
||||
mbt_ffi_store32((iter_base) + 0, ((iter_elem).geometry).x)
|
||||
mbt_ffi_store32((iter_base) + 4, ((iter_elem).geometry).y)
|
||||
mbt_ffi_store32((iter_base) + 8, ((iter_elem).geometry).w)
|
||||
mbt_ffi_store32((iter_base) + 12, ((iter_elem).geometry).h)
|
||||
mbt_ffi_store32((iter_base) + 16, (iter_elem).inset_top)
|
||||
mbt_ffi_store32((iter_base) + 20, (iter_elem).inset_right)
|
||||
mbt_ffi_store32((iter_base) + 24, (iter_elem).inset_bottom)
|
||||
mbt_ffi_store32((iter_base) + 28, (iter_elem).inset_left)
|
||||
|
||||
let address28 = mbt_ffi_malloc(((iter_elem).deco).length() * 32);
|
||||
for index29 = 0; index29 < ((iter_elem).deco).length(); index29 = index29 + 1 {
|
||||
let iter_elem : Op = ((iter_elem).deco)[(index29)]
|
||||
let iter_base = address28 + (index29 * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload20) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload20).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload20).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload20).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload20).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload20).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload20).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload20).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload20).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload20).radius)
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload21) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload21).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload21).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload21).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload21).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload21).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload21).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload21).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload21).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload21).width)
|
||||
mbt_ffi_store32((iter_base) + 28, (payload21).radius)
|
||||
|
||||
()
|
||||
}
|
||||
DrawLine(payload22) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload22).x0)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload22).y0)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload22).x1)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload22).y1)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload22).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload22).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload22).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload22).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload22).width)
|
||||
|
||||
()
|
||||
}
|
||||
DrawCircle(payload23) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload23).cx)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload23).cy)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload23).radius)
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload23).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload23).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload23).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload23).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload23).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
DrawText(payload24) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload24).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload24).y)
|
||||
|
||||
let ptr25 = mbt_ffi_str2ptr((payload24).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload24).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr25)
|
||||
mbt_ffi_store32((iter_base) + 20, (payload24).size)
|
||||
mbt_ffi_store8((iter_base) + 24, (((payload24).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, (((payload24).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, (((payload24).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, (((payload24).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload24).align).to_int())
|
||||
mbt_ffi_store8((iter_base) + 29, (if (payload24).bold { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 30, (if (payload24).mono { 1 } else { 0 }))
|
||||
cleanup_list.push(ptr25)
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload26) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload26).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload26).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload26).w)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload26).h)
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mbt_ffi_store32((iter_base) + 36, ((iter_elem).deco).length())
|
||||
mbt_ffi_store32((iter_base) + 32, address28)
|
||||
mbt_ffi_store8((iter_base) + 40, (if (iter_elem).fullscreen { 1 } else { 0 }))
|
||||
mbt_ffi_store32((iter_base) + 44, ((iter_elem).surface).reinterpret_as_int())
|
||||
cleanup_list.push(address28)
|
||||
|
||||
}
|
||||
|
||||
let address40 = mbt_ffi_malloc(((f).panel).length() * 32);
|
||||
for index41 = 0; index41 < ((f).panel).length(); index41 = index41 + 1 {
|
||||
let iter_elem : Op = ((f).panel)[(index41)]
|
||||
let iter_base = address40 + (index41 * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload32) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload32).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload32).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload32).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload32).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload32).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload32).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload32).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload32).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload32).radius)
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload33) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload33).area).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload33).area).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload33).area).w)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload33).area).h)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload33).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload33).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload33).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload33).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload33).width)
|
||||
mbt_ffi_store32((iter_base) + 28, (payload33).radius)
|
||||
|
||||
()
|
||||
}
|
||||
DrawLine(payload34) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload34).x0)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload34).y0)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload34).x1)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload34).y1)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload34).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload34).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload34).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload34).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, (payload34).width)
|
||||
|
||||
()
|
||||
}
|
||||
DrawCircle(payload35) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload35).cx)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload35).cy)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload35).radius)
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload35).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload35).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload35).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload35).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload35).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
DrawText(payload36) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload36).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload36).y)
|
||||
|
||||
let ptr37 = mbt_ffi_str2ptr((payload36).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload36).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr37)
|
||||
mbt_ffi_store32((iter_base) + 20, (payload36).size)
|
||||
mbt_ffi_store8((iter_base) + 24, (((payload36).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, (((payload36).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, (((payload36).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, (((payload36).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload36).align).to_int())
|
||||
mbt_ffi_store8((iter_base) + 29, (if (payload36).bold { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 30, (if (payload36).mono { 1 } else { 0 }))
|
||||
cleanup_list.push(ptr37)
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload38) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload38).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload38).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (payload38).w)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload38).h)
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let address42 = mbt_ffi_malloc(((f).popups).length() * 20);
|
||||
for index43 = 0; index43 < ((f).popups).length(); index43 = index43 + 1 {
|
||||
let iter_elem : Popup = ((f).popups)[(index43)]
|
||||
let iter_base = address42 + (index43 * 20);
|
||||
mbt_ffi_store32((iter_base) + 0, ((iter_elem).area).x)
|
||||
mbt_ffi_store32((iter_base) + 4, ((iter_elem).area).y)
|
||||
mbt_ffi_store32((iter_base) + 8, ((iter_elem).area).w)
|
||||
mbt_ffi_store32((iter_base) + 12, ((iter_elem).area).h)
|
||||
mbt_ffi_store32((iter_base) + 16, ((iter_elem).surface).reinterpret_as_int())
|
||||
|
||||
}
|
||||
wasmImportSubmit((f).width, (f).height, lowered, lowered8, lowered9, address18, ((f).background).length(), address30, ((f).windows).length(), address40, ((f).panel).length(), address42, ((f).popups).length());
|
||||
mbt_ffi_free(address18)
|
||||
mbt_ffi_free(address30)
|
||||
mbt_ffi_free(address40)
|
||||
mbt_ffi_free(address42)
|
||||
|
||||
cleanup_list.each(mbt_ffi_free)
|
||||
|
||||
}
|
||||
///|
|
||||
/// The framebuffer as RGBA8888 (for screenshots and tests; the display path never needs it).
|
||||
pub fn read_frame() -> FixedArray[Byte] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportReadFrame(return_area);
|
||||
|
||||
let result = mbt_ffi_ptr2bytes(mbt_ffi_load32((return_area) + 0), mbt_ffi_load32((return_area) + 4))
|
||||
let ret = result
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// A new memfd holding the framebuffer as little-endian ARGB8888, ready to hand to a Wayland
|
||||
/// compositor as a wl_shm pool. The caller closes it. -1 on failure.
|
||||
pub fn export_memfd() -> Int {
|
||||
|
||||
let result : Int = wasmImportExportMemfd();
|
||||
let ret = result
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,29 @@ fn wasmImportHasExe(p0 : Int, p1 : Int) -> Int = "moonplasma:host/sys@0.1.0" "ha
|
||||
///|
|
||||
fn wasmImportSpawn(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int = "moonplasma:host/sys@0.1.0" "spawn"
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
@@ -86,31 +109,8 @@ extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
#owned(bytes)
|
||||
extern "wasm" fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array8
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
@@ -125,6 +125,26 @@ fn wasmImportSpawn(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
abort("wasm-only host import")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String {
|
||||
abort("wasm-only")
|
||||
@@ -135,27 +155,7 @@ fn mbt_ffi_free(position : Int) -> Unit {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_load32(offset : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_bytes2ptr(bytes : FixedArray[Byte]) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_ptr2bytes(ptr : Int, len : Int) -> FixedArray[Byte] {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_str2ptr(str : String) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
|
||||
///|
|
||||
fn mbt_ffi_malloc(size : Int) -> Int {
|
||||
abort("wasm-only")
|
||||
}
|
||||
Reference in new issue
Block a user