mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/pixman: rasterize trapezoids
This commit is contained in:
@ -61,6 +61,20 @@ pub const Image = opaque {
|
|||||||
@ptrCast([*c]const c.pixman_box32_t, boxes.ptr),
|
@ptrCast([*c]const c.pixman_box32_t, boxes.ptr),
|
||||||
) == 0) return pixman.Error.PixmanFailure;
|
) == 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" {
|
test "create and destroy" {
|
||||||
|
@ -68,6 +68,38 @@ pub const Color = extern struct {
|
|||||||
alpha: u16,
|
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 {
|
pub const Box32 = extern struct {
|
||||||
x1: i32,
|
x1: i32,
|
||||||
y1: i32,
|
y1: i32,
|
||||||
|
Reference in New Issue
Block a user