summaryrefslogtreecommitdiff
path: root/test/veil.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/veil.zig')
-rw-r--r--test/veil.zig37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/veil.zig b/test/veil.zig
new file mode 100644
index 00000000..ed49e1c3
--- /dev/null
+++ b/test/veil.zig
@@ -0,0 +1,37 @@
+//! A test addon whose GPU picture is translucent: its pass draws nothing
+//! and clears to a premultiplied half-alpha colour, so the window's addon
+//! pipeline blends it over the pane (the frame corpus's case for the
+//! pipeline's colour factor, which an opaque picture never shows).
+const std = @import("std");
+const addon = @import("addon");
+const scene = @import("gpu_scene");
+
+pub const Veil = extern struct {
+ painted: u32,
+
+ pub const head: addon.Head = .{ .name = "veil", .version = 1, .words = &.{
+ .{ .name = "Veil", .opens = true, .doc = "a translucent GPU picture over the pane (a test addon)" },
+ } };
+
+ pub fn open(v: *Veil, _: ?[]const u8, _: ?[]const u8) void {
+ v.painted = 0;
+ }
+
+ pub fn paint(_: *const Veil, w: addon.Window, out: addon.Paint) void {
+ w.put(0, 0, "veil over this", .{});
+ const width: u32 = @min(4096, @max(1, @as(u32, w.cols) * w.cell_w));
+ const height: u32 = @min(4096, @max(1, @as(u32, w.rows) * w.cell_h));
+ var buffer: [256]u8 = undefined;
+ var writer: std.Io.Writer = .fixed(&buffer);
+ scene.encode(&writer, .{ .image = .none, .width = width, .height = height, .clear = .{ 0.30, 0.10, 0.20, 0.5 }, .pipelines = &.{}, .draws = &.{} }) catch return;
+ _ = out.gpu(writer.buffered());
+ }
+
+ pub const dump = addon.dumpBytes;
+ pub const load = addon.loadBytes;
+};
+
+pub const pardes_addon = addon.ops(Veil);
+comptime {
+ addon.exportLib(&pardes_addon);
+}