summaryrefslogtreecommitdiff
path: root/src/vector/root.zig
diff options
context:
space:
mode:
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, .{});
}