pixman.zig (36719B)
1 const Bool = c_int; 2 3 pub const Fixed_32_32 = enum(i64) { _ }; 4 pub const Fixed_48_16 = enum(i64) { _ }; 5 pub const Fixed_1_31 = enum(u32) { _ }; 6 pub const Fixed_1_16 = enum(u32) { _ }; 7 pub const Fixed_16_16 = enum(i32) { _ }; 8 pub const Fixed = Fixed_16_16; 9 10 pub const PointFixed = extern struct { 11 x: Fixed, 12 y: Fixed, 13 }; 14 15 pub const LineFixed = extern struct { 16 p1: PointFixed, 17 p2: PointFixed, 18 }; 19 20 pub const Vector = extern struct { 21 vector: [3]Fixed, 22 }; 23 24 pub const Transform = extern struct { 25 matrix: [3][3]Fixed, 26 27 extern fn pixman_transform_init_identity(matrix: *Transform) void; 28 pub const initIdentity = pixman_transform_init_identity; 29 30 extern fn pixman_transform_point_3d(transform: *const Transform, vector: *Vector) Bool; 31 pub fn point3d(transform: *const Transform, vector: *Vector) bool { 32 return pixman_transform_point_3d(transform, vector) != 0; 33 } 34 35 extern fn pixman_transform_point(transform: *const Transform, vector: *Vector) Bool; 36 pub fn point(transform: *const Transform, vector: *Vector) bool { 37 return pixman_transform_point(transform, vector) != 0; 38 } 39 40 extern fn pixman_transform_multiply(dst: *Transform, l: *const Transform, r: *const Transform) Bool; 41 pub fn multiply(dst: *Transform, l: *const Transform, r: *const Transform) bool { 42 return pixman_transform_multiply(dst, l, r) != 0; 43 } 44 45 extern fn pixman_transform_init_scale(t: *Transform, sx: Fixed, sy: Fixed) void; 46 pub const initScale = pixman_transform_init_scale; 47 48 extern fn pixman_transform_scale(forward: *Transform, reverse: *Transform, sx: Fixed, sy: Fixed) Bool; 49 pub fn scale(forward: *Transform, reverse: *Transform, sx: Fixed, sy: Fixed) bool { 50 return pixman_transform_scale(forward, reverse, sx, sy) != 0; 51 } 52 53 extern fn pixman_transform_init_rotate(t: *Transform, cos: Fixed, sin: Fixed) void; 54 pub const initRotate = pixman_transform_init_rotate; 55 56 extern fn pixman_transform_rotate(forward: *Transform, reverse: *Transform, c: Fixed, s: Fixed) Bool; 57 pub fn rotate(forward: *Transform, reverse: *Transform, c: Fixed, s: Fixed) bool { 58 return pixman_transform_rotate(forward, reverse, c, s) != 0; 59 } 60 61 extern fn pixman_transform_init_translate(t: *Transform, tx: Fixed, ty: Fixed) void; 62 pub const initTranslate = pixman_transform_init_translate; 63 64 extern fn pixman_transform_translate(forward: *Transform, reverse: *Transform, tx: Fixed, ty: Fixed) Bool; 65 pub fn translate(forward: *Transform, reverse: *Transform, tx: Fixed, ty: Fixed) bool { 66 return pixman_transform_translate(forward, reverse, tx, ty) != 0; 67 } 68 69 extern fn pixman_transform_bounds(matrix: *const Transform, b: *Box16) Bool; 70 pub fn bounds(matrix: *const Transform, b: *Box16) bool { 71 return pixman_transform_bounds(matrix, b) != 0; 72 } 73 74 extern fn pixman_transform_invert(dst: *Transform, src: *const Transform) Bool; 75 pub fn invert(dst: *Transform, src: *const Transform) bool { 76 return pixman_transform_invert(dst, src) != 0; 77 } 78 79 extern fn pixman_transform_is_identity(t: *const Transform) Bool; 80 pub fn isIdentity(t: *const Transform) bool { 81 return pixman_transform_is_identity(t) != 0; 82 } 83 84 extern fn pixman_transform_is_scale(t: *const Transform) Bool; 85 pub fn isScale(t: *const Transform) bool { 86 return pixman_transform_is_scale(t) != 0; 87 } 88 89 extern fn pixman_transform_is_int_translate(t: *const Transform) Bool; 90 pub fn isIntTranslate(t: *const Transform) bool { 91 return pixman_transform_is_int_translate(t) != 0; 92 } 93 94 extern fn pixman_transform_is_inverse(a: *const Transform, b: *const Transform) Bool; 95 pub fn isInverse(a: *const Transform, b: *const Transform) bool { 96 return pixman_transform_is_inverse(a, b) != 0; 97 } 98 99 extern fn pixman_transform_from_pixman_f_transform(t: *Transform, ft: *const FTransform) Bool; 100 pub fn fromFTransform(t: *Transform, ft: *const FTransform) bool { 101 return pixman_transform_from_pixman_f_transform(t, ft) != 0; 102 } 103 }; 104 105 pub const FVector = extern struct { 106 vector: [3]f64, 107 }; 108 109 pub const FTransform = extern struct { 110 matrix: [3][3]f64, 111 112 extern fn pixman_f_transform_from_pixman_transform(ft: *FTransform, t: *const Transform) void; 113 pub const fromPixmanTransform = pixman_f_transform_from_pixman_transform; 114 115 extern fn pixman_f_transform_invert(dst: *FTransform, src: *const FTransform) Bool; 116 pub fn invert(dst: *FTransform, src: *const FTransform) bool { 117 return pixman_f_transform_invert(dst, src) != 0; 118 } 119 120 extern fn pixman_f_transform_point(t: *const FTransform, v: FVector) Bool; 121 pub fn point(t: *const FTransform, v: FVector) bool { 122 return pixman_f_transform_point(t, v) != 0; 123 } 124 125 extern fn pixman_f_transform_point_3d(t: *const FTransform, v: FVector) void; 126 pub const point3d = pixman_f_transform_point_3d; 127 128 extern fn pixman_f_transform_multiply(dst: *FTransform, l: *const FTransform, r: *const FTransform) void; 129 pub const multiply = pixman_f_transform_multiply; 130 131 extern fn pixman_f_transform_init_scale(t: *FTransform, sx: f64, sy: f64) void; 132 pub const initScale = pixman_f_transform_init_scale; 133 134 extern fn pixman_f_transform_scale(forward: *FTransform, reverse: *FTransform, sx: f64, sy: f64) Bool; 135 pub fn scale(forward: *FTransform, reverse: *FTransform, sx: f64, sy: f64) bool { 136 return pixman_f_transform_scale(forward, reverse, sx, sy) != 0; 137 } 138 139 extern fn pixman_f_transform_init_rotate(t: *FTransform, cos: f64, sin: f64) void; 140 pub const initRotate = pixman_f_transform_init_rotate; 141 142 extern fn pixman_f_transform_rotate(forward: *FTransform, reverse: *FTransform, c: f64, s: f64) Bool; 143 pub fn rotate(forward: *FTransform, reverse: *FTransform, c: f64, s: f64) bool { 144 return pixman_f_transform_rotate(forward, reverse, c, s) != 0; 145 } 146 147 extern fn pixman_f_transform_init_translate(t: *FTransform, tx: f64, ty: f64) void; 148 pub const initTranslate = pixman_f_transform_init_translate; 149 150 extern fn pixman_f_transform_translate(forward: *FTransform, reverse: *FTransform, tx: f64, ty: f64) Bool; 151 pub fn translate(forward: *FTransform, reverse: *FTransform, tx: f64, ty: f64) bool { 152 return pixman_f_transform_translate(forward, reverse, tx, ty) != 0; 153 } 154 155 extern fn pixman_f_transform_bounds(t: *const FTransform, b: *Box16) Bool; 156 pub fn bounds(t: *const FTransform, b: *Box16) bool { 157 return pixman_f_transform_bounds(t, b) != 0; 158 } 159 160 extern fn pixman_f_transform_init_identity(t: *FTransform) void; 161 pub const initIdentity = pixman_f_transform_init_identity; 162 }; 163 164 pub const RegionOverlap = enum(c_int) { 165 out, 166 in, 167 part, 168 }; 169 170 pub const Region16Data = extern struct { 171 size: c_long, 172 num_rects: c_long, 173 // In memory but not explicity declared 174 //rects: [size]Box16, 175 }; 176 177 pub const Rectangle16 = extern struct { 178 x: i16, 179 y: i16, 180 width: u16, 181 height: u16, 182 }; 183 184 pub const Box16 = extern struct { 185 x1: i16, 186 y1: i16, 187 x2: i16, 188 y2: i16, 189 }; 190 191 pub const Region16 = extern struct { 192 extents: Box16, 193 data: ?*Region16Data, 194 195 extern fn pixman_region_init(region: *Region16) void; 196 pub const init = pixman_region_init; 197 198 extern fn pixman_region_init_rect(region: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) void; 199 pub const initRect = pixman_region_init_rect; 200 201 extern fn pixman_region_init_rects(region: *Region16, boxes: *const Box16, count: c_int) Bool; 202 pub fn initRects(region: *Region16, boxes: *const Box16, count: c_int) bool { 203 return pixman_region_init_rects(region, boxes, count) != 0; 204 } 205 206 extern fn pixman_region_init_with_extents(region: *Region16, extents: *Box16) void; 207 pub const initWithExtents = pixman_region_init_with_extents; 208 209 // TODO 210 extern fn pixman_region_init_from_image(region: *Region16, image: ?*Image) void; 211 pub const initFromImage = pixman_region_init_from_image; 212 213 extern fn pixman_region_fini(region: *Region16) void; 214 pub const deinit = pixman_region_fini; 215 216 extern fn pixman_region_translate(region: *Region16, x: c_int, y: c_int) void; 217 pub const translate = pixman_region_translate; 218 219 extern fn pixman_region_copy(dest: *Region16, source: *Region16) Bool; 220 pub fn copy(dest: *Region16, source: *Region16) bool { 221 return pixman_region_copy(dest, source) != 0; 222 } 223 224 extern fn pixman_region_intersect(new_reg: *Region16, reg1: *Region16, reg2: *Region16) Bool; 225 pub fn intersect(new_reg: *Region16, reg1: *Region16, reg2: *Region16) bool { 226 return pixman_region_intersect(new_reg, reg1, reg2) != 0; 227 } 228 229 extern fn pixman_region_union(new_reg: *Region16, reg1: *Region16, reg2: *Region16) Bool; 230 pub fn @"union"(new_reg: *Region16, reg1: *Region16, reg2: *Region16) bool { 231 return pixman_region_union(new_reg, reg1, reg2) != 0; 232 } 233 234 extern fn pixman_region_union_rect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool; 235 pub fn unionRect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) bool { 236 return pixman_region_union_rect(dest, source, x, y, width, height) != 0; 237 } 238 239 extern fn pixman_region_intersect_rect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool; 240 pub fn intersectRect(dest: *Region16, source: *Region16, x: c_int, y: c_int, width: c_uint, height: c_uint) bool { 241 return pixman_region_intersect_rect(dest, source, x, y, width, height) != 0; 242 } 243 244 extern fn pixman_region_subtract(reg_d: *Region16, reg_m: *Region16, reg_s: *Region16) Bool; 245 pub fn subtract(reg_d: *Region16, reg_m: *Region16, reg_s: *Region16) bool { 246 return pixman_region_subtract(reg_d, reg_m, reg_s) != 0; 247 } 248 249 extern fn pixman_region_inverse(new_reg: *Region16, reg1: *Region16, inv_rect: *Box16) Bool; 250 pub fn inverse(new_reg: *Region16, reg1: *Region16, inv_rect: *Box16) bool { 251 return pixman_region_inverse(new_reg, reg1, inv_rect) != 0; 252 } 253 254 extern fn pixman_region_contains_point(region: *Region16, x: c_int, y: c_int, box: ?*Box16) Bool; 255 pub fn containsPoint(region: *Region16, x: c_int, y: c_int, box: ?*Box16) bool { 256 return pixman_region_contains_point(region, x, y, box) != 0; 257 } 258 259 extern fn pixman_region_contains_rectangle(region: *Region16, prect: *Box16) RegionOverlap; 260 pub const containsRectangle = pixman_region_contains_rectangle; 261 262 extern fn pixman_region_not_empty(region: *Region16) Bool; 263 pub fn notEmpty(region: *Region16) bool { 264 return pixman_region_not_empty(region) != 0; 265 } 266 267 extern fn pixman_region_extents(region: *Region16) *Box16; 268 // Conflicts with the extents struct field, just access the field directly. 269 //pub const extents = pixman_region_extents; 270 271 extern fn pixman_region_n_rects(region: *Region16) c_int; 272 pub const nRects = pixman_region_n_rects; 273 274 extern fn pixman_region_rectangles(region: *Region16, n_rects: *c_int) [*]Box16; 275 pub fn rectangles(region: *Region16) []Box16 { 276 var n_rects: c_int = undefined; 277 const rects = pixman_region_rectangles(region, &n_rects); 278 return rects[0..@intCast(n_rects)]; 279 } 280 281 extern fn pixman_region_equal(region1: *Region16, region2: *Region16) Bool; 282 pub fn equal(region1: *Region16, region2: *Region16) bool { 283 return pixman_region_equal(region1, region2) != 0; 284 } 285 286 extern fn pixman_region_selfcheck(region: *Region16) Bool; 287 pub fn selfcheck(region: *Region16) bool { 288 return pixman_region_selfcheck(region) != 0; 289 } 290 291 extern fn pixman_region_reset(region: *Region16, box: *Box16) void; 292 pub const reset = pixman_region_reset; 293 294 extern fn pixman_region_clear(region: *Region16) void; 295 pub const clear = pixman_region_clear; 296 }; 297 298 pub const Region32Data = extern struct { 299 size: c_long, 300 num_rects: c_long, 301 // In memory but not explicity declared 302 //rects: [size]Box32, 303 }; 304 305 pub const Rectangle32 = extern struct { 306 x: i32, 307 y: i32, 308 width: u32, 309 height: u32, 310 }; 311 312 pub const Box32 = extern struct { 313 x1: i32, 314 y1: i32, 315 x2: i32, 316 y2: i32, 317 }; 318 319 pub const Region32 = extern struct { 320 extents: Box32, 321 data: ?*Region32Data, 322 323 extern fn pixman_region32_init(region: *Region32) void; 324 pub const init = pixman_region32_init; 325 326 extern fn pixman_region32_init_rect(region: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) void; 327 pub const initRect = pixman_region32_init_rect; 328 329 extern fn pixman_region32_init_rects(region: *Region32, boxes: *const Box32, count: c_int) Bool; 330 pub fn initRects(region: *Region32, boxes: *const Box32, count: c_int) bool { 331 return pixman_region32_init_rects(region, boxes, count) != 0; 332 } 333 334 extern fn pixman_region32_init_with_extents(region: *Region32, extents: *Box32) void; 335 pub const initWithExtents = pixman_region32_init_with_extents; 336 337 extern fn pixman_region32_init_from_image(region: *Region32, image: ?*Image) void; 338 pub const initFromImage = pixman_region32_init_from_image; 339 340 extern fn pixman_region32_fini(region: *Region32) void; 341 pub const deinit = pixman_region32_fini; 342 343 extern fn pixman_region32_translate(region: *Region32, x: c_int, y: c_int) void; 344 pub const translate = pixman_region32_translate; 345 346 extern fn pixman_region32_copy(dest: *Region32, source: *Region32) Bool; 347 pub fn copy(dest: *Region32, source: *Region32) bool { 348 return pixman_region32_copy(dest, source) != 0; 349 } 350 351 extern fn pixman_region32_intersect(new_reg: *Region32, reg1: *Region32, reg2: *Region32) Bool; 352 pub fn intersect(new_reg: *Region32, reg1: *Region32, reg2: *Region32) bool { 353 return pixman_region32_intersect(new_reg, reg1, reg2) != 0; 354 } 355 356 extern fn pixman_region32_union(new_reg: *Region32, reg1: *Region32, reg2: *Region32) Bool; 357 pub fn @"union"(new_reg: *Region32, reg1: *Region32, reg2: *Region32) bool { 358 return pixman_region32_union(new_reg, reg1, reg2) != 0; 359 } 360 361 extern fn pixman_region32_intersect_rect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool; 362 pub fn intersectRect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) bool { 363 return pixman_region32_intersect_rect(dest, source, x, y, width, height) != 0; 364 } 365 366 extern fn pixman_region32_union_rect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) Bool; 367 pub fn unionRect(dest: *Region32, source: *Region32, x: c_int, y: c_int, width: c_uint, height: c_uint) bool { 368 return pixman_region32_union_rect(dest, source, x, y, width, height) != 0; 369 } 370 371 extern fn pixman_region32_subtract(reg_d: *Region32, reg_m: *Region32, reg_s: *Region32) Bool; 372 pub fn subtract(reg_d: *Region32, reg_m: *Region32, reg_s: *Region32) bool { 373 return pixman_region32_subtract(reg_d, reg_m, reg_s) != 0; 374 } 375 376 extern fn pixman_region32_inverse(new_reg: *Region32, reg1: *Region32, inv_rect: *Box32) Bool; 377 pub fn inverse(new_reg: *Region32, reg1: *Region32, inv_rect: *Box32) bool { 378 return pixman_region32_inverse(new_reg, reg1, inv_rect) != 0; 379 } 380 381 extern fn pixman_region32_contains_point(region: *Region32, x: c_int, y: c_int, box: ?*Box32) Bool; 382 pub fn containsPoint(region: *Region32, x: c_int, y: c_int, box: ?*Box32) bool { 383 return pixman_region32_contains_point(region, x, y, box) != 0; 384 } 385 386 extern fn pixman_region32_contains_rectangle(region: *Region32, prect: *Box32) RegionOverlap; 387 pub const containsRectangle = pixman_region32_contains_rectangle; 388 389 extern fn pixman_region32_not_empty(region: *Region32) Bool; 390 pub fn notEmpty(region: *Region32) bool { 391 return pixman_region32_not_empty(region) != 0; 392 } 393 394 extern fn pixman_region32_extents(region: *Region32) *Box32; 395 // Conflicts with the extents struct field, just access the field directly. 396 //pub const extents = pixman_region32_extents; 397 398 extern fn pixman_region32_n_rects(region: *Region32) c_int; 399 pub const nRects = pixman_region32_n_rects; 400 401 extern fn pixman_region32_rectangles(region: *Region32, n_rects: *c_int) [*]Box32; 402 pub fn rectangles(region: *Region32) []Box32 { 403 var n_rects: c_int = undefined; 404 const rects = pixman_region32_rectangles(region, &n_rects); 405 return rects[0..@intCast(n_rects)]; 406 } 407 408 extern fn pixman_region32_equal(region1: *Region32, region2: *Region32) Bool; 409 pub fn equal(region1: *Region32, region2: *Region32) bool { 410 return pixman_region32_equal(region1, region2) != 0; 411 } 412 413 extern fn pixman_region32_selfcheck(region: *Region32) Bool; 414 pub fn selfcheck(region: *Region32) bool { 415 return pixman_region32_selfcheck(region) != 0; 416 } 417 418 extern fn pixman_region32_reset(region: *Region32, box: *Box32) void; 419 pub const reset = pixman_region32_reset; 420 421 extern fn pixman_region32_clear(region: *Region32) void; 422 pub const clear = pixman_region32_clear; 423 }; 424 425 extern fn pixman_blt( 426 src_bits: [*]u32, 427 dst_bits: [*]u32, 428 src_stride: c_int, 429 dst_stride: c_int, 430 src_bpp: c_int, 431 dst_bpp: c_int, 432 src_x: c_int, 433 src_y: c_int, 434 dest_x: c_int, 435 dest_y: c_int, 436 width: c_int, 437 height: c_int, 438 ) Bool; 439 pub fn blt( 440 src_bits: [*]u32, 441 dst_bits: [*]u32, 442 src_stride: c_int, 443 dst_stride: c_int, 444 src_bpp: c_int, 445 dst_bpp: c_int, 446 src_x: c_int, 447 src_y: c_int, 448 dest_x: c_int, 449 dest_y: c_int, 450 width: c_int, 451 height: c_int, 452 ) bool { 453 return pixman_blt( 454 src_bits, 455 dst_bits, 456 src_stride, 457 dst_stride, 458 src_bpp, 459 dst_bpp, 460 src_x, 461 src_y, 462 dest_x, 463 dest_y, 464 width, 465 height, 466 ) != 0; 467 } 468 469 extern fn pixman_fill( 470 bits: [*]u32, 471 stride: c_int, 472 bpp: c_int, 473 x: c_int, 474 y: c_int, 475 width: c_int, 476 height: c_int, 477 _xor: u32, 478 ) Bool; 479 pub fn fill( 480 bits: [*]u32, 481 stride: c_int, 482 bpp: c_int, 483 x: c_int, 484 y: c_int, 485 width: c_int, 486 height: c_int, 487 _xor: u32, 488 ) bool { 489 return pixman_fill(bits, stride, bpp, x, y, width, height, _xor) != 0; 490 } 491 492 extern fn pixman_version() c_int; 493 pub const version = pixman_version; 494 495 extern fn pixman_version_string() [*:0]const u8; 496 pub const versionString = pixman_version_string; 497 498 pub const Color = extern struct { 499 red: u16, 500 green: u16, 501 blue: u16, 502 alpha: u16, 503 }; 504 505 pub const GradientStop = extern struct { 506 x: Fixed, 507 color: Color, 508 }; 509 510 pub const Indexed = extern struct { 511 color: Bool, 512 rgba: [256]u32, 513 ent: [32768]u8, 514 }; 515 516 fn format( 517 comptime bpp: u32, 518 comptime _type: Type, 519 comptime a: u32, 520 comptime r: u32, 521 comptime g: u32, 522 comptime b: u32, 523 ) comptime_int { 524 return (bpp << 24) | (@intFromEnum(_type) << 16) | 525 (a << 12) | (r << 8) | (g << 4) | b; 526 } 527 528 fn formatByte( 529 comptime bpp: u32, 530 comptime _type: Type, 531 comptime a: u32, 532 comptime r: u32, 533 comptime g: u32, 534 comptime b: u32, 535 ) comptime_int { 536 return ((bpp >> 3) << 24) | 537 (3 << 22) | (@intFromEnum(_type) << 16) | 538 ((a >> 3) << 12) | 539 ((r >> 3) << 8) | 540 ((g >> 3) << 4) | 541 (b >> 3); 542 } 543 544 /// These are the PIXMAN_TYPE_FOO defines 545 pub const Type = enum(u32) { 546 other = 0, 547 a = 1, 548 argb = 2, 549 abgr = 3, 550 color = 4, 551 gray = 5, 552 yuy2 = 6, 553 yv12 = 7, 554 bgra = 8, 555 rgba = 9, 556 argb_srgb = 10, 557 rgba_float = 11, 558 }; 559 560 pub const FormatCode = enum(c_int) { 561 // 128bpp formats 562 rgba_float = formatByte(128, .rgba_float, 32, 32, 32, 32), 563 // 96bpp formats 564 rgb_float = formatByte(96, .rgba_float, 0, 32, 32, 32), 565 566 // 32bpp formats 567 a8r8g8b8 = format(32, .argb, 8, 8, 8, 8), 568 x8r8g8b8 = format(32, .argb, 0, 8, 8, 8), 569 a8b8g8r8 = format(32, .abgr, 8, 8, 8, 8), 570 x8b8g8r8 = format(32, .abgr, 0, 8, 8, 8), 571 b8g8r8a8 = format(32, .bgra, 8, 8, 8, 8), 572 b8g8r8x8 = format(32, .bgra, 0, 8, 8, 8), 573 r8g8b8a8 = format(32, .rgba, 8, 8, 8, 8), 574 r8g8b8x8 = format(32, .rgba, 0, 8, 8, 8), 575 x14r6g6b6 = format(32, .argb, 0, 6, 6, 6), 576 x2r10g10b10 = format(32, .argb, 0, 10, 10, 10), 577 a2r10g10b10 = format(32, .argb, 2, 10, 10, 10), 578 x2b10g10r10 = format(32, .abgr, 0, 10, 10, 10), 579 a2b10g10r10 = format(32, .abgr, 2, 10, 10, 10), 580 581 // sRGB formats 582 a8r8g8b8_sRGB = format(32, .argb_srgb, 8, 8, 8, 8), 583 584 // 24bpp formats 585 r8g8b8 = format(24, .argb, 0, 8, 8, 8), 586 b8g8r8 = format(24, .abgr, 0, 8, 8, 8), 587 588 // 16bpp formats 589 r5g6b5 = format(16, .argb, 0, 5, 6, 5), 590 b5g6r5 = format(16, .abgr, 0, 5, 6, 5), 591 592 a1r5g5b5 = format(16, .argb, 1, 5, 5, 5), 593 x1r5g5b5 = format(16, .argb, 0, 5, 5, 5), 594 a1b5g5r5 = format(16, .abgr, 1, 5, 5, 5), 595 x1b5g5r5 = format(16, .abgr, 0, 5, 5, 5), 596 a4r4g4b4 = format(16, .argb, 4, 4, 4, 4), 597 x4r4g4b4 = format(16, .argb, 0, 4, 4, 4), 598 a4b4g4r4 = format(16, .abgr, 4, 4, 4, 4), 599 x4b4g4r4 = format(16, .abgr, 0, 4, 4, 4), 600 601 // 8bpp formats 602 a8 = format(8, .a, 8, 0, 0, 0), 603 r3g3b2 = format(8, .argb, 0, 3, 3, 2), 604 b2g3r3 = format(8, .abgr, 0, 3, 3, 2), 605 a2r2g2b2 = format(8, .argb, 2, 2, 2, 2), 606 a2b2g2r2 = format(8, .abgr, 2, 2, 2, 2), 607 608 c8 = format(8, .color, 0, 0, 0, 0), // also x4c4 609 g8 = format(8, .gray, 0, 0, 0, 0), // also x4g4 610 611 x4a4 = format(8, .a, 4, 0, 0, 0), 612 613 //x4c4 = format(8, .color, 0, 0, 0, 0), // see c8 614 //x4g4 = format(8, .gray, 0, 0, 0, 0), // see g8 615 616 // 4bpp formats 617 a4 = format(4, .a, 4, 0, 0, 0), 618 r1g2b1 = format(4, .argb, 0, 1, 2, 1), 619 b1g2r1 = format(4, .abgr, 0, 1, 2, 1), 620 a1r1g1b1 = format(4, .argb, 1, 1, 1, 1), 621 a1b1g1r1 = format(4, .abgr, 1, 1, 1, 1), 622 623 c4 = format(4, .color, 0, 0, 0, 0), 624 g4 = format(4, .gray, 0, 0, 0, 0), 625 626 // 1bpp formats 627 a1 = format(1, .a, 1, 0, 0, 0), 628 629 g1 = format(1, .gray, 0, 0, 0, 0), 630 631 // YUV formats 632 yuy2 = format(16, .yuy2, 0, 0, 0, 0), 633 yv12 = format(12, .yv12, 0, 0, 0, 0), 634 635 extern fn pixman_format_supported_destination(_format: FormatCode) Bool; 636 pub fn supportedDestination(_format: FormatCode) bool { 637 return pixman_format_supported_destination(_format) != 0; 638 } 639 640 extern fn pixman_format_supported_source(_format: FormatCode) Bool; 641 pub fn supportedSource(_format: FormatCode) bool { 642 return pixman_format_supported_source(_format) != 0; 643 } 644 }; 645 646 pub const Repeat = enum(c_int) { 647 none, 648 normal, 649 pad, 650 reflect, 651 }; 652 653 pub const Dither = enum(c_int) { 654 none, 655 fast, 656 good, 657 best, 658 ordered_bayer_8, 659 ordered_blue_noise_64, 660 }; 661 662 pub const Filter = enum(c_int) { 663 fast, 664 good, 665 best, 666 nearest, 667 bilinear, 668 convolution, 669 separable_convolution, 670 671 extern fn pixman_filter_create_separable_convolution( 672 n_values: *c_int, 673 scale_x: Fixed, 674 scale_y: Fixed, 675 reconstruct_x: Kernel, 676 reconstruct_y: Kernel, 677 sample_x: Kernel, 678 sample_y: Kernel, 679 subsample_bits_x: c_int, 680 subsample_bits_y: c_int, 681 ) [*]Fixed; 682 pub const createSeparableConvolution = pixman_filter_create_separable_convolution; 683 }; 684 685 pub const Kernel = enum(c_int) { 686 impulse, 687 box, 688 linear, 689 cubic, 690 gaussian, 691 lanczos2, 692 lanczos3, 693 lanczos3_stretched, 694 }; 695 696 pub const Op = enum(c_int) { 697 clear = 0x00, 698 src = 0x01, 699 dst = 0x02, 700 over = 0x03, 701 over_reverse = 0x04, 702 in = 0x05, 703 in_reverse = 0x06, 704 out = 0x07, 705 out_reverse = 0x08, 706 atop = 0x09, 707 atop_reverse = 0x0a, 708 xor = 0x0b, 709 add = 0x0c, 710 saturate = 0x0d, 711 712 disjoint_clear = 0x10, 713 disjoint_src = 0x11, 714 disjoint_dst = 0x12, 715 disjoint_over = 0x13, 716 disjoint_over_reverse = 0x14, 717 disjoint_in = 0x15, 718 disjoint_in_reverse = 0x16, 719 disjoint_out = 0x17, 720 disjoint_out_reverse = 0x18, 721 disjoint_atop = 0x19, 722 disjoint_atop_reverse = 0x1a, 723 disjoint_xor = 0x1b, 724 725 conjoint_clear = 0x20, 726 conjoint_src = 0x21, 727 conjoint_dst = 0x22, 728 conjoint_over = 0x23, 729 conjoint_over_reverse = 0x24, 730 conjoint_in = 0x25, 731 conjoint_in_reverse = 0x26, 732 conjoint_out = 0x27, 733 conjoint_out_reverse = 0x28, 734 conjoint_atop = 0x29, 735 conjoint_atop_reverse = 0x2a, 736 conjoint_xor = 0x2b, 737 738 multiply = 0x30, 739 screen = 0x31, 740 overlay = 0x32, 741 darken = 0x33, 742 lighten = 0x34, 743 color_dodge = 0x35, 744 color_burn = 0x36, 745 hard_light = 0x37, 746 soft_light = 0x38, 747 difference = 0x39, 748 exclusion = 0x3a, 749 hsl_hue = 0x3b, 750 hsl_saturation = 0x3c, 751 hsl_color = 0x3d, 752 hsl_luminosity = 0x3e, 753 }; 754 755 pub const Image = opaque { 756 extern fn pixman_image_create_solid_fill(color: *const Color) ?*Image; 757 pub const createSolidFill = pixman_image_create_solid_fill; 758 759 extern fn pixman_image_create_linear_gradient(p1: *const PointFixed, p2: *const PointFixed, stops: [*]const GradientStop, n_stops: c_int) ?*Image; 760 pub const createLinearGradient = pixman_image_create_linear_gradient; 761 762 extern fn pixman_image_create_radial_gradient(inner: *const PointFixed, outer: *const PointFixed, inner_radius: Fixed, outer_radius: Fixed, stops: [*]const GradientStop, n_stops: c_int) ?*Image; 763 pub const createRadialGradient = pixman_image_create_radial_gradient; 764 765 extern fn pixman_image_create_conical_gradient(center: *const PointFixed, angle: Fixed, stops: [*]const GradientStop, n_stops: c_int) ?*Image; 766 pub const createConicalGradient = pixman_image_create_conical_gradient; 767 768 extern fn pixman_image_create_bits(format: FormatCode, width: c_int, height: c_int, bits: ?[*]u32, rowstride_bytes: c_int) ?*Image; 769 pub const createBits = pixman_image_create_bits; 770 771 extern fn pixman_image_create_bits_no_clear(format: FormatCode, width: c_int, height: c_int, bits: [*c]u32, rowstride_bytes: c_int) ?*Image; 772 pub const createBitsNoClear = pixman_image_create_bits_no_clear; 773 774 extern fn pixman_image_ref(image: *Image) *Image; 775 pub const ref = pixman_image_ref; 776 777 extern fn pixman_image_unref(image: *Image) Bool; 778 pub fn unref(image: *Image) bool { 779 return pixman_image_unref(image) != 0; 780 } 781 782 extern fn pixman_image_set_destroy_function(image: *Image, function: *const fn (*Image, ?*anyopaque) callconv(.c) void, data: ?*anyopaque) void; 783 pub const setDestroyFunction = pixman_image_set_destroy_function; 784 785 extern fn pixman_image_get_destroy_data(image: *Image) ?*anyopaque; 786 pub const getDestroyData = pixman_image_get_destroy_data; 787 788 extern fn pixman_image_set_clip_region(image: *Image, region: *Region16) Bool; 789 pub fn setClipRegion(image: *Image, region: *Region16) bool { 790 return pixman_image_set_clip_region(image, region) != 0; 791 } 792 793 extern fn pixman_image_set_clip_region32(image: *Image, region: *Region32) Bool; 794 pub fn setClipRegion32(image: *Image, region: *Region32) bool { 795 return pixman_image_set_clip_region32(image, region) != 0; 796 } 797 798 extern fn pixman_image_set_has_client_clip(image: *Image, client_clip: Bool) void; 799 pub fn setHasClientClip(image: *Image, client_clip: bool) void { 800 pixman_image_set_has_client_clip(image, @intFromBool(client_clip)); 801 } 802 803 extern fn pixman_image_set_transform(image: *Image, transform: *const Transform) Bool; 804 pub fn setTransform(image: *Image, transform: *const Transform) bool { 805 return pixman_image_set_transform(image, transform) != 0; 806 } 807 808 extern fn pixman_image_set_repeat(image: *Image, repeat: Repeat) void; 809 pub const setRepeat = pixman_image_set_repeat; 810 811 extern fn pixman_image_set_dither(image: *Image, dither: Dither) void; 812 pub const setDither = pixman_image_set_dither; 813 814 extern fn pixman_image_set_dither_offset(image: *Image, offset_x: c_int, offset_y: c_int) void; 815 pub const setDitherOffset = pixman_image_set_dither_offset; 816 817 extern fn pixman_image_set_filter(image: *Image, filter: Filter, filter_params: [*]const Fixed, n_filter_params: c_int) Bool; 818 pub fn setFilter(image: *Image, filter: Filter, filter_params: [*]const Fixed, n_filter_params: c_int) bool { 819 return pixman_image_set_filter(image, filter, filter_params, n_filter_params) != 0; 820 } 821 822 extern fn pixman_image_set_source_clipping(image: *Image, source_clipping: Bool) void; 823 pub fn setSourceClipping(image: *Image, source_clipping: bool) void { 824 pixman_image_set_source_clipping(image, @intFromBool(source_clipping)); 825 } 826 827 extern fn pixman_image_set_alpha_map(image: *Image, alpha_map: ?*Image, x: i16, y: i16) void; 828 pub const setAlphaMap = pixman_image_set_alpha_map; 829 830 extern fn pixman_image_set_component_alpha(image: *Image, component_alpha: Bool) void; 831 pub fn setComponentAlpha(image: *Image, component_alpha: bool) void { 832 pixman_image_set_component_alpha(image, @intFromBool(component_alpha)); 833 } 834 835 extern fn pixman_image_get_component_alpha(image: *Image) Bool; 836 pub fn getComponentAlpha(image: *Image) bool { 837 return pixman_image_get_component_alpha(image) != 0; 838 } 839 840 extern fn pixman_image_set_accessors( 841 image: *Image, 842 read_func: *const fn (src: *const anyopaque, size: c_int) callconv(.c) u32, 843 write_func: *const fn (dst: *anyopaque, value: u32, size: c_int) callconv(.c) void, 844 ) void; 845 pub const setAccessors = pixman_image_set_accessors; 846 847 extern fn pixman_image_set_indexed(image: *Image, indexed: *const Indexed) void; 848 pub const setIndexed = pixman_image_set_indexed; 849 850 extern fn pixman_image_get_data(image: *Image) ?[*]u32; 851 pub const getData = pixman_image_get_data; 852 853 extern fn pixman_image_get_width(image: *Image) c_int; 854 pub const getWidth = pixman_image_get_width; 855 856 extern fn pixman_image_get_height(image: *Image) c_int; 857 pub const getHeight = pixman_image_get_height; 858 859 extern fn pixman_image_get_stride(image: *Image) c_int; 860 pub const getStride = pixman_image_get_stride; 861 862 extern fn pixman_image_get_depth(image: *Image) c_int; 863 pub const getDepth = pixman_image_get_depth; 864 865 extern fn pixman_image_get_format(image: *Image) FormatCode; 866 pub const getFormat = pixman_image_get_format; 867 868 extern fn pixman_image_fill_rectangles(op: Op, image: *Image, color: *const Color, n_rects: c_int, rects: [*]const Rectangle16) Bool; 869 pub fn fillRectangles(op: Op, image: *Image, color: *const Color, n_rects: c_int, rects: [*]const Rectangle16) bool { 870 return pixman_image_fill_rectangles(op, image, color, n_rects, rects) != 0; 871 } 872 873 extern fn pixman_image_fill_boxes(op: Op, dest: *Image, color: *const Color, n_boxes: c_int, boxes: [*]const Box32) Bool; 874 pub fn fillBoxes(op: Op, dest: *Image, color: *const Color, n_boxes: c_int, boxes: [*]const Box32) bool { 875 return pixman_image_fill_boxes(op, dest, color, n_boxes, boxes) != 0; 876 } 877 878 extern fn pixman_image_composite(op: Op, src: *Image, mask: ?*Image, dest: *Image, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dest_x: i16, dest_y: i16, width: u16, height: u16) void; 879 pub const composite = pixman_image_composite; 880 881 extern fn pixman_image_composite32(op: Op, src: *Image, mask: ?*Image, dest: *Image, src_x: i32, src_y: i32, mask_x: i32, mask_y: i32, dest_x: i32, dest_y: i32, width: i32, height: i32) void; 882 pub const composite32 = pixman_image_composite32; 883 884 extern fn pixman_rasterize_edges(image: *Image, l: *Edge, r: *Edge, t: Fixed, b: Fixed) void; 885 pub const rasterizeEdges = pixman_rasterize_edges; 886 887 extern fn pixman_add_traps(image: *Image, x_off: i16, y_off: i16, ntrap: c_int, traps: [*]const Trap) void; 888 pub const addTraps = pixman_add_traps; 889 890 extern fn pixman_add_trapezoids(image: *Image, x_off: i16, y_off: c_int, ntraps: c_int, traps: [*]const Trapezoid) void; 891 pub const addTrapezoids = pixman_add_trapezoids; 892 893 extern fn pixman_rasterize_trapezoid(image: *Image, trap: [*]const Trapezoid, x_off: c_int, y_off: c_int) void; 894 pub const rasterizeTrapezoid = pixman_rasterize_trapezoid; 895 896 extern fn pixman_add_triangles(image: *Image, x_off: i32, y_off: i32, n_tris: c_int, tris: [*]const Triangle) void; 897 pub const addTriangles = pixman_add_triangles; 898 }; 899 900 pub const Glyph = extern struct { 901 x: c_int, 902 y: c_int, 903 glyph: ?*const anyopaque, 904 905 extern fn pixman_glyph_get_extents(cache: ?*GlyphCache, n_glyphs: c_int, glyphs: [*]Glyph, extents: [*]Box32) void; 906 pub const getExtents = pixman_glyph_get_extents; 907 908 extern fn pixman_glyph_get_mask_format(cache: ?*GlyphCache, n_glyphs: c_int, glyphs: [*]const Glyph) FormatCode; 909 pub const getMaskFormat = pixman_glyph_get_mask_format; 910 }; 911 912 pub const GlyphCache = opaque { 913 extern fn pixman_glyph_cache_create() ?*GlyphCache; 914 pub const create = pixman_glyph_cache_create; 915 916 extern fn pixman_glyph_cache_destroy(cache: *GlyphCache) void; 917 pub const destroy = pixman_glyph_cache_destroy; 918 919 extern fn pixman_glyph_cache_freeze(cache: *GlyphCache) void; 920 pub const freeze = pixman_glyph_cache_freeze; 921 922 extern fn pixman_glyph_cache_thaw(cache: *GlyphCache) void; 923 pub const thaw = pixman_glyph_cache_thaw; 924 925 extern fn pixman_glyph_cache_lookup(cache: *GlyphCache, font_key: ?*anyopaque, glyph_key: ?*anyopaque) ?*const anyopaque; 926 pub const lookup = pixman_glyph_cache_lookup; 927 928 extern fn pixman_glyph_cache_insert(cache: *GlyphCache, font_key: ?*anyopaque, glyph_key: ?*anyopaque, origin_x: c_int, origin_y: c_int, glyph_image: *Image) ?*const anyopaque; 929 pub const insert = pixman_glyph_cache_insert; 930 931 extern fn pixman_glyph_cache_remove(cache: *GlyphCache, font_key: ?*anyopaque, glyph_key: ?*anyopaque) void; 932 pub const remove = pixman_glyph_cache_remove; 933 }; 934 935 extern fn pixman_composite_glyphs( 936 op: Op, 937 src: *Image, 938 dest: *Image, 939 mask_format: FormatCode, 940 src_x: i32, 941 src_y: i32, 942 mask_x: i32, 943 mask_y: i32, 944 dest_x: i32, 945 dest_y: i32, 946 width: i32, 947 height: i32, 948 cache: *GlyphCache, 949 n_glyphs: c_int, 950 glyphs: [*]const Glyph, 951 ) void; 952 pub const compositeGlyphs = pixman_composite_glyphs; 953 954 extern fn pixman_composite_glyphs_no_mask( 955 op: Op, 956 src: *Image, 957 dest: *Image, 958 src_x: i32, 959 src_y: i32, 960 dest_x: i32, 961 dest_y: i32, 962 cache: *GlyphCache, 963 n_glyphs: c_int, 964 glyphs: [*]const Glyph, 965 ) void; 966 pub const compositeGlyphsNoMask = pixman_composite_glyphs_no_mask; 967 968 pub const Edge = extern struct { 969 x: Fixed, 970 e: Fixed, 971 stepx: Fixed, 972 signdx: Fixed, 973 dy: Fixed, 974 dx: Fixed, 975 976 stepx_small: Fixed, 977 stepx_big: Fixed, 978 dx_small: Fixed, 979 dx_big: Fixed, 980 981 extern fn pixman_edge_init(e: *Edge, bpp: c_int, y_start: Fixed, x_top: Fixed, y_top: Fixed, x_bot: Fixed, y_bot: Fixed) void; 982 pub const init = pixman_edge_init; 983 984 extern fn pixman_line_fixed_edge_init(e: *Edge, bpp: c_int, y: Fixed, line: *const LineFixed, x_off: c_int, y_off: c_int) void; 985 pub const initFromLineFixed = pixman_line_fixed_edge_init; 986 987 extern fn pixman_edge_step(e: *Edge, n: c_int) void; 988 pub const step = pixman_edge_step; 989 }; 990 991 pub const Trapezoid = extern struct { 992 top: Fixed, 993 bottom: Fixed, 994 left: LineFixed, 995 right: LineFixed, 996 997 pub fn valid(t: Trapezoid) bool { 998 return t.left.p1.y != t.left.p2.y and 999 t.right.p1.y != t.right.p2.y and 1000 @intFromEnum(t.bottom) > @intFromEnum(t.top); 1001 } 1002 }; 1003 1004 pub const Trap = extern struct { 1005 top: SpanFix, 1006 bot: SpanFix, 1007 }; 1008 1009 pub const SpanFix = extern struct { 1010 l: Fixed, 1011 r: Fixed, 1012 y: Fixed, 1013 }; 1014 1015 pub const Triangle = extern struct { 1016 p1: PointFixed, 1017 p2: PointFixed, 1018 p3: PointFixed, 1019 }; 1020 1021 extern fn pixman_sample_ceil_y(y: Fixed, bpp: c_int) Fixed; 1022 pub const sampleCeilY = pixman_sample_ceil_y; 1023 1024 extern fn pixman_sample_floor_y(y: Fixed, bpp: c_int) Fixed; 1025 pub const sampleFloorY = pixman_sample_floor_y; 1026 1027 extern fn pixman_composite_trapezoids( 1028 op: Op, 1029 src: *Image, 1030 dst: *Image, 1031 mask_format: FormatCode, 1032 x_src: c_int, 1033 y_src: c_int, 1034 x_dst: c_int, 1035 y_dst: c_int, 1036 n_traps: c_int, 1037 traps: [*c]const Trapezoid, 1038 ) void; 1039 pub const compositeTrapezoids = pixman_composite_trapezoids; 1040 1041 extern fn pixman_composite_triangles( 1042 op: Op, 1043 src: *Image, 1044 dst: *Image, 1045 mask_format: FormatCode, 1046 x_src: c_int, 1047 y_src: c_int, 1048 x_dst: c_int, 1049 y_dst: c_int, 1050 n_tris: c_int, 1051 tris: [*c]const Triangle, 1052 ) void; 1053 pub const compositeTriangles = pixman_composite_triangles; 1054 1055 test { 1056 @import("std").testing.refAllDeclsRecursive(@This()); 1057 }