From 2348776791e9dd17afeb12a06ba42a4a71917bcf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 21:34:41 -0300 Subject: sketchbook: a drawing layer on top, host fixes for replay and migration --- src/vector/root.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/vector/root.zig') diff --git a/src/vector/root.zig b/src/vector/root.zig index 0414286..e5e9975 100644 --- a/src/vector/root.zig +++ b/src/vector/root.zig @@ -1,11 +1,12 @@ //! Vector graphics for sketches: SVG in, cubic geometry as data, and two //! interchangeable renderers. The CPU backend computes exact coverage and //! runs anywhere (it is also the reference in tests); the GPU backend -//! describes stencil-then-cover passes for the host to run. The backend is +//! describes passes for the host to run: convex fills drawn directly, the +//! rest stencil-then-cover, batched into a few draws (see `Gpu.zig`). The backend is //! a comptime choice: `vector.Renderer(.gpu)` or `vector.Renderer(.cpu)`. const std = @import("std"); const abi = @import("abi"); -pub const geom = @import("geom.zig"); +pub const geom = @import("math"); pub const Drawing = @import("Drawing.zig"); pub const svg = @import("svg.zig"); pub const Polygons = @import("Polygons.zig"); @@ -57,7 +58,10 @@ pub fn Renderer(comptime backend: Backend) type { } pub fn deinit(r: *Self, host: anytype) void { - if (backend == .cpu) r.target.deinit(); + switch (backend) { + .cpu => r.target.deinit(), + .gpu => r.target.deinit(host), + } r.polys.deinit(); host.freeImage(r.image); } @@ -118,7 +122,10 @@ pub fn Renderer(comptime backend: Backend) type { pub fn present(r: *Self, f: anytype, dst: anytype) void { switch (backend) { .cpu => f.pixels(r.image, r.target.width, r.target.height, r.target.pixels, .{ .premultiplied = true }), - .gpu => f.gpu(r.target.pass()), + .gpu => { + r.target.upload(f); + f.gpu(r.target.pass()); + }, } f.image(r.image, dst, .{}); } -- cgit v1.3