From 409c1accefeb7a775c0914c888b469a1e78fc69a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 13 Nov 2026 12:12:22 -0300 Subject: Add reusable GPU backdrop filtering to the shared canvas Draw native GPU frames through the same bounded canvas used by headless capture. Backdrop commands reuse one snapshot and shader state, with an unchanged fallback on unsupported renderers. Verified through native debugger lenses, restart, and repeated font zoom checks. --- src/sketch/root.zig | 3 +++ src/sketch/web.zig | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/sketch') diff --git a/src/sketch/root.zig b/src/sketch/root.zig index b2f9136..52f05b2 100644 --- a/src/sketch/root.zig +++ b/src/sketch/root.zig @@ -142,6 +142,9 @@ pub const Frame = struct { pub fn target(f: *Frame, img: Image) void { f.emit(.{ .target = img }); } + pub fn backdrop(f: *Frame, dst: Rect, fragment: []const u8, uniforms: []const u8) void { + f.emit(.{ .backdrop = .{ .dst = dst, .fragment = fragment, .uniforms = f.keep(u8, uniforms) } }); + } /// How the 2D commands after it blend, until the next `blend` or the /// frame ends (which goes back to `.alpha`). pub fn blend(f: *Frame, mode: BlendMode) void { diff --git a/src/sketch/web.zig b/src/sketch/web.zig index db9d9a8..3e102ad 100644 --- a/src/sketch/web.zig +++ b/src/sketch/web.zig @@ -232,7 +232,7 @@ fn Driver(comptime App: type) type { .open_file => |v| js.openFile(v.command.ptr, v.command.len, v.pattern.ptr, v.pattern.len), // Synthesised voices are not on the web yet; quitting a page // means nothing; `run` lines go after the frame. - .voice, .quit, .run => {}, + .voice, .quit, .run, .backdrop => {}, } } -- cgit v1.3