summaryrefslogtreecommitdiff
path: root/src/kinds
diff options
context:
space:
mode:
Diffstat (limited to 'src/kinds')
-rw-r--r--src/kinds/addon.zig18
-rw-r--r--src/kinds/pardes_addon.h12
2 files changed, 22 insertions, 8 deletions
diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig
index 11635f7a..54f26893 100644
--- a/src/kinds/addon.zig
+++ b/src/kinds/addon.zig
@@ -36,9 +36,9 @@ pub const c = @import("pardes_addon");
const Allocator = std.mem.Allocator;
/// The ABI this file speaks: a header of another needs it brought along.
-pub const abi = 0x30000;
+pub const abi = 0x30001;
comptime {
- if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.0 and the header another");
+ if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.1 and the header another");
}
/// A word the kind brings: `opens` a pane of it, else goes to the pane's
@@ -157,6 +157,12 @@ pub const Window = struct {
/// as the header has them.
pub const Paint = struct {
out: *c.pa_paint,
+ /// Optional display data; always paint a text/raster fallback too.
+ pub fn gpu(p: Paint, bytes: []const u8) bool {
+ if (api.abi < 0x00030001 or bytes.len > 4 << 20) return false;
+ const emit = p.out.gpu orelse return false;
+ return emit(p.out.gpu_ctx, bytes.ptr, @intCast(bytes.len)) == c.PA_OK;
+ }
/// A picture over the cells (pa_placement), lowest first.
pub fn place(p: Paint, at: c.pa_placement) void {
if (p.out.n == p.out.cap) return;
@@ -349,10 +355,10 @@ pub fn ops(comptime T: type) c.pa_ops {
var o: c.pa_ops = .{ .init = F.init, .open = F.open, .paint = F.paint, .head = .{ .size = @sizeOf(c.pa_head), .abi = c.PA_ABI, .name = name, .version = T.head.version, .flags = if (T.head.pictures) c.PA_PICTURES else 0, .exts = T.head.exts, .words = &F.words, .nwords = F.words.len } };
// The kind's function, then the pa_ops field its wrapper fills.
const fns = .{
- .{ "close", "close" }, .{ "tick", "tick" }, .{ "prefix", "tick" }, .{ "view", "view" }, .{ "key", "key" },
- .{ "mouse", "mouse" }, .{ "body", "body_len" }, .{ "body", "body" }, .{ "address", "address" }, .{ "where", "where" },
- .{ "ctl", "ctl" }, .{ "ctlRead", "ctl_read" }, .{ "jobRun", "job_run" }, .{ "jobDone", "job_done" }, .{ "dump", "dump" },
- .{ "load", "load" }, .{ "search", "search" },
+ .{ "close", "close" }, .{ "tick", "tick" }, .{ "prefix", "tick" }, .{ "view", "view" }, .{ "key", "key" },
+ .{ "mouse", "mouse" }, .{ "body", "body_len" }, .{ "body", "body" }, .{ "address", "address" }, .{ "where", "where" },
+ .{ "ctl", "ctl" }, .{ "ctlRead", "ctl_read" }, .{ "jobRun", "job_run" }, .{ "jobDone", "job_done" }, .{ "dump", "dump" },
+ .{ "load", "load" }, .{ "search", "search" },
};
inline for (fns) |m| if (@hasDecl(T, m[0])) {
@field(o, m[1]) = @field(F, m[1]);
diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h
index c3bfb354..9c101fee 100644
--- a/src/kinds/pardes_addon.h
+++ b/src/kinds/pardes_addon.h
@@ -37,7 +37,7 @@
/* Major in the high half: an addon of another major is refused. */
#define PA_ABI_MAJOR 3u
-#define PA_ABI_MINOR 0u
+#define PA_ABI_MINOR 1u
#define PA_ABI ((PA_ABI_MAJOR << 16) | PA_ABI_MINOR)
#define PA_OK 0
#define PA_RASTER_MAX (32u << 20) /* a placement's w*h*4 above this is dropped, said once */
@@ -121,6 +121,14 @@ typedef struct pa_paint {
uint32_t cap, n;
float at, span;
uint32_t pointer, pad;
+ /* Optional since 3.1: one sketchbook SGPU v1 scene for this pane.
+ * Check api->abi >= 3.1 BEFORE reading these fields on an older host.
+ * NULL means unsupported. Copies bytes during the call (stack is OK);
+ * returns PA_OK or refuses. At most 4 MiB, last successful call wins.
+ * Keep cells/rasters as fallback: accepting a scene does not promise a
+ * GPU in every view. GPU scenes are display data, never saved state. */
+ int (*gpu)(void *ctx, const uint8_t *bytes, uint32_t n);
+ void *gpu_ctx;
} pa_paint;
/* ---- input ---- */
@@ -352,7 +360,7 @@ _Static_assert(sizeof(pa_cell) == 20, "pa_cell");
_Static_assert(sizeof(pa_window) == 24, "pa_window");
_Static_assert(sizeof(pa_rect) == 16 && sizeof(pa_cells) == 8, "pa_rect");
_Static_assert(sizeof(pa_placement) == 80, "pa_placement");
-_Static_assert(sizeof(pa_paint) == 32 && sizeof(pa_view) == 32 && sizeof(pa_tick) == 128, "pa_paint");
+_Static_assert(sizeof(pa_paint) == 48 && sizeof(pa_view) == 32 && sizeof(pa_tick) == 128, "pa_paint");
_Static_assert(sizeof(pa_key) == 8 && sizeof(pa_mouse) == 16, "pa_key");
_Static_assert(sizeof(pa_api) == 112 && sizeof(pa_out) == 16, "pa_api");
_Static_assert(sizeof(pa_word) == 32 && sizeof(pa_head) == 56, "pa_head");