summaryrefslogtreecommitdiff
path: root/src/vector/root.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 21:34:41 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commit2348776791e9dd17afeb12a06ba42a4a71917bcf (patch)
tree780c4b12b76c8b97a28408dd40944d65f159fdc7 /src/vector/root.zig
parent590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff)
downloadsketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz
sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip
sketchbook: a drawing layer on top, host fixes for replay and migration
Diffstat (limited to 'src/vector/root.zig')
-rw-r--r--src/vector/root.zig15
1 files changed, 11 insertions, 4 deletions
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, .{});
}