diff --git a/pkg/pixman/image.zig b/pkg/pixman/image.zig index e6bb950c8..e1e055be0 100644 --- a/pkg/pixman/image.zig +++ b/pkg/pixman/image.zig @@ -61,6 +61,20 @@ pub const Image = opaque { @ptrCast([*c]const c.pixman_box32_t, boxes.ptr), ) == 0) return pixman.Error.PixmanFailure; } + + pub fn rasterizeTrapezoid( + self: *Image, + trap: pixman.Trapezoid, + x_off: c_int, + y_off: c_int, + ) void { + c.pixman_rasterize_trapezoid( + @ptrCast(*c.pixman_image_t, self), + @ptrCast(*const c.pixman_trapezoid_t, &trap), + x_off, + y_off, + ); + } }; test "create and destroy" { diff --git a/pkg/pixman/types.zig b/pkg/pixman/types.zig index d3cad88ae..9b520896a 100644 --- a/pkg/pixman/types.zig +++ b/pkg/pixman/types.zig @@ -68,6 +68,38 @@ pub const Color = extern struct { alpha: u16, }; +pub const Fixed = enum(i32) { + _, + + pub fn init(v: anytype) Fixed { + return switch (@TypeOf(v)) { + comptime_int, u32 => @intToEnum(Fixed, v << 16), + f64 => @intToEnum(Fixed, @floatToInt(i32, v * 65536)), + else => { + @compileLog(@TypeOf(v)); + @compileError("unsupported type"); + }, + }; + } +}; + +pub const PointFixed = extern struct { + x: Fixed, + y: Fixed, +}; + +pub const LineFixed = extern struct { + p1: PointFixed, + p2: PointFixed, +}; + +pub const Trapezoid = extern struct { + top: Fixed, + bottom: Fixed, + left: LineFixed, + right: LineFixed, +}; + pub const Box32 = extern struct { x1: i32, y1: i32,