1 /*********************************************************** 2 3 Copyright 1987, 1998 The Open Group 4 5 Permission to use, copy, modify, distribute, and sell this software and its 6 documentation for any purpose is hereby granted without fee, provided that 7 the above copyright notice appear in all copies and that both that 8 copyright notice and this permission notice appear in supporting 9 documentation. 10 11 The above copyright notice and this permission notice shall be included in 12 all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21 Except as contained in this notice, the name of The Open Group shall not be 22 used in advertising or otherwise to promote the sale, use or other dealings 23 in this Software without prior written authorization from The Open Group. 24 25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 26 27 All Rights Reserved 28 29 Permission to use, copy, modify, and distribute this software and its 30 documentation for any purpose and without fee is hereby granted, 31 provided that the above copyright notice appear in all copies and that 32 both that copyright notice and this permission notice appear in 33 supporting documentation, and that the name of Digital not be 34 used in advertising or publicity pertaining to distribution of the 35 software without specific, written prior permission. 36 37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43 SOFTWARE. 44 45 ******************************************************************/ 46 /* 47 * Copyright 1998, 2004 Keith Packard 48 * Copyright 2007 Red Hat, Inc. 49 * 50 * Permission to use, copy, modify, distribute, and sell this software and its 51 * documentation for any purpose is hereby granted without fee, provided that 52 * the above copyright notice appear in all copies and that both that 53 * copyright notice and this permission notice appear in supporting 54 * documentation, and that the name of Keith Packard not be used in 55 * advertising or publicity pertaining to distribution of the software without 56 * specific, written prior permission. Keith Packard makes no 57 * representations about the suitability of this software for any purpose. It 58 * is provided "as is" without express or implied warranty. 59 * 60 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 61 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 62 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 63 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 64 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 65 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 66 * PERFORMANCE OF THIS SOFTWARE. 67 */ 68 69 #ifndef PIXMAN_H__ 70 #define PIXMAN_H__ 71 72 #include <pixman-version.h> 73 74 #ifdef __cplusplus 75 #define PIXMAN_BEGIN_DECLS extern "C" { 76 #define PIXMAN_END_DECLS } 77 #else 78 #define PIXMAN_BEGIN_DECLS 79 #define PIXMAN_END_DECLS 80 #endif 81 82 PIXMAN_BEGIN_DECLS 83 84 /* 85 * Standard integers 86 */ 87 88 #if !defined (PIXMAN_DONT_DEFINE_STDINT) 89 90 #if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__) || defined (__HP_cc) 91 # include <inttypes.h> 92 /* VS 2010 (_MSC_VER 1600) has stdint.h */ 93 #elif defined (_MSC_VER) && _MSC_VER < 1600 94 typedef __int8 int8_t; 95 typedef unsigned __int8 uint8_t; 96 typedef __int16 int16_t; 97 typedef unsigned __int16 uint16_t; 98 typedef __int32 int32_t; 99 typedef unsigned __int32 uint32_t; 100 typedef __int64 int64_t; 101 typedef unsigned __int64 uint64_t; 102 #elif defined (_AIX) 103 # include <sys/inttypes.h> 104 #else 105 # include <stdint.h> 106 #endif 107 108 #endif 109 110 /* 111 * Boolean 112 */ 113 typedef int pixman_bool_t; 114 115 /* 116 * Fixpoint numbers 117 */ 118 typedef int64_t pixman_fixed_32_32_t; 119 typedef pixman_fixed_32_32_t pixman_fixed_48_16_t; 120 typedef uint32_t pixman_fixed_1_31_t; 121 typedef uint32_t pixman_fixed_1_16_t; 122 typedef int32_t pixman_fixed_16_16_t; 123 typedef pixman_fixed_16_16_t pixman_fixed_t; 124 125 #define pixman_fixed_e ((pixman_fixed_t) 1) 126 #define pixman_fixed_1 (pixman_int_to_fixed(1)) 127 #define pixman_fixed_1_minus_e (pixman_fixed_1 - pixman_fixed_e) 128 #define pixman_fixed_minus_1 (pixman_int_to_fixed(-1)) 129 #define pixman_fixed_to_int(f) ((int) ((f) >> 16)) 130 #define pixman_int_to_fixed(i) ((pixman_fixed_t) ((uint32_t) (i) << 16)) 131 #define pixman_fixed_to_double(f) (double) ((f) / (double) pixman_fixed_1) 132 #define pixman_double_to_fixed(d) ((pixman_fixed_t) ((d) * 65536.0)) 133 #define pixman_fixed_frac(f) ((f) & pixman_fixed_1_minus_e) 134 #define pixman_fixed_floor(f) ((f) & ~pixman_fixed_1_minus_e) 135 #define pixman_fixed_ceil(f) pixman_fixed_floor ((f) + pixman_fixed_1_minus_e) 136 #define pixman_fixed_fraction(f) ((f) & pixman_fixed_1_minus_e) 137 #define pixman_fixed_mod_2(f) ((f) & (pixman_fixed1 | pixman_fixed_1_minus_e)) 138 #define pixman_max_fixed_48_16 ((pixman_fixed_48_16_t) 0x7fffffff) 139 #define pixman_min_fixed_48_16 (-((pixman_fixed_48_16_t) 1 << 31)) 140 141 /* 142 * Misc structs 143 */ 144 typedef struct pixman_color pixman_color_t; 145 typedef struct pixman_point_fixed pixman_point_fixed_t; 146 typedef struct pixman_line_fixed pixman_line_fixed_t; 147 typedef struct pixman_vector pixman_vector_t; 148 typedef struct pixman_transform pixman_transform_t; 149 150 struct pixman_color 151 { 152 uint16_t red; 153 uint16_t green; 154 uint16_t blue; 155 uint16_t alpha; 156 }; 157 158 struct pixman_point_fixed 159 { 160 pixman_fixed_t x; 161 pixman_fixed_t y; 162 }; 163 164 struct pixman_line_fixed 165 { 166 pixman_point_fixed_t p1, p2; 167 }; 168 169 /* 170 * Fixed point matrices 171 */ 172 173 struct pixman_vector 174 { 175 pixman_fixed_t vector[3]; 176 }; 177 178 struct pixman_transform 179 { 180 pixman_fixed_t matrix[3][3]; 181 }; 182 183 /* forward declaration (sorry) */ 184 struct pixman_box16; 185 typedef union pixman_image pixman_image_t; 186 187 PIXMAN_API 188 void pixman_transform_init_identity (struct pixman_transform *matrix); 189 190 PIXMAN_API 191 pixman_bool_t pixman_transform_point_3d (const struct pixman_transform *transform, 192 struct pixman_vector *vector); 193 194 PIXMAN_API 195 pixman_bool_t pixman_transform_point (const struct pixman_transform *transform, 196 struct pixman_vector *vector); 197 198 PIXMAN_API 199 pixman_bool_t pixman_transform_multiply (struct pixman_transform *dst, 200 const struct pixman_transform *l, 201 const struct pixman_transform *r); 202 203 PIXMAN_API 204 void pixman_transform_init_scale (struct pixman_transform *t, 205 pixman_fixed_t sx, 206 pixman_fixed_t sy); 207 208 PIXMAN_API 209 pixman_bool_t pixman_transform_scale (struct pixman_transform *forward, 210 struct pixman_transform *reverse, 211 pixman_fixed_t sx, 212 pixman_fixed_t sy); 213 214 PIXMAN_API 215 void pixman_transform_init_rotate (struct pixman_transform *t, 216 pixman_fixed_t cos, 217 pixman_fixed_t sin); 218 219 PIXMAN_API 220 pixman_bool_t pixman_transform_rotate (struct pixman_transform *forward, 221 struct pixman_transform *reverse, 222 pixman_fixed_t c, 223 pixman_fixed_t s); 224 225 PIXMAN_API 226 void pixman_transform_init_translate (struct pixman_transform *t, 227 pixman_fixed_t tx, 228 pixman_fixed_t ty); 229 230 PIXMAN_API 231 pixman_bool_t pixman_transform_translate (struct pixman_transform *forward, 232 struct pixman_transform *reverse, 233 pixman_fixed_t tx, 234 pixman_fixed_t ty); 235 236 PIXMAN_API 237 pixman_bool_t pixman_transform_bounds (const struct pixman_transform *matrix, 238 struct pixman_box16 *b); 239 240 PIXMAN_API 241 pixman_bool_t pixman_transform_invert (struct pixman_transform *dst, 242 const struct pixman_transform *src); 243 244 PIXMAN_API 245 pixman_bool_t pixman_transform_is_identity (const struct pixman_transform *t); 246 247 PIXMAN_API 248 pixman_bool_t pixman_transform_is_scale (const struct pixman_transform *t); 249 250 PIXMAN_API 251 pixman_bool_t pixman_transform_is_int_translate (const struct pixman_transform *t); 252 253 PIXMAN_API 254 pixman_bool_t pixman_transform_is_inverse (const struct pixman_transform *a, 255 const struct pixman_transform *b); 256 257 /* 258 * Floating point matrices 259 */ 260 typedef struct pixman_f_transform pixman_f_transform_t; 261 typedef struct pixman_f_vector pixman_f_vector_t; 262 263 struct pixman_f_vector 264 { 265 double v[3]; 266 }; 267 268 struct pixman_f_transform 269 { 270 double m[3][3]; 271 }; 272 273 274 PIXMAN_API 275 pixman_bool_t pixman_transform_from_pixman_f_transform (struct pixman_transform *t, 276 const struct pixman_f_transform *ft); 277 278 PIXMAN_API 279 void pixman_f_transform_from_pixman_transform (struct pixman_f_transform *ft, 280 const struct pixman_transform *t); 281 282 PIXMAN_API 283 pixman_bool_t pixman_f_transform_invert (struct pixman_f_transform *dst, 284 const struct pixman_f_transform *src); 285 286 PIXMAN_API 287 pixman_bool_t pixman_f_transform_point (const struct pixman_f_transform *t, 288 struct pixman_f_vector *v); 289 290 PIXMAN_API 291 void pixman_f_transform_point_3d (const struct pixman_f_transform *t, 292 struct pixman_f_vector *v); 293 294 PIXMAN_API 295 void pixman_f_transform_multiply (struct pixman_f_transform *dst, 296 const struct pixman_f_transform *l, 297 const struct pixman_f_transform *r); 298 299 PIXMAN_API 300 void pixman_f_transform_init_scale (struct pixman_f_transform *t, 301 double sx, 302 double sy); 303 304 PIXMAN_API 305 pixman_bool_t pixman_f_transform_scale (struct pixman_f_transform *forward, 306 struct pixman_f_transform *reverse, 307 double sx, 308 double sy); 309 310 PIXMAN_API 311 void pixman_f_transform_init_rotate (struct pixman_f_transform *t, 312 double cos, 313 double sin); 314 315 PIXMAN_API 316 pixman_bool_t pixman_f_transform_rotate (struct pixman_f_transform *forward, 317 struct pixman_f_transform *reverse, 318 double c, 319 double s); 320 321 PIXMAN_API 322 void pixman_f_transform_init_translate (struct pixman_f_transform *t, 323 double tx, 324 double ty); 325 326 PIXMAN_API 327 pixman_bool_t pixman_f_transform_translate (struct pixman_f_transform *forward, 328 struct pixman_f_transform *reverse, 329 double tx, 330 double ty); 331 332 PIXMAN_API 333 pixman_bool_t pixman_f_transform_bounds (const struct pixman_f_transform *t, 334 struct pixman_box16 *b); 335 336 PIXMAN_API 337 void pixman_f_transform_init_identity (struct pixman_f_transform *t); 338 339 typedef enum 340 { 341 PIXMAN_REPEAT_NONE, 342 PIXMAN_REPEAT_NORMAL, 343 PIXMAN_REPEAT_PAD, 344 PIXMAN_REPEAT_REFLECT 345 } pixman_repeat_t; 346 347 typedef enum 348 { 349 PIXMAN_DITHER_NONE, 350 PIXMAN_DITHER_FAST, 351 PIXMAN_DITHER_GOOD, 352 PIXMAN_DITHER_BEST, 353 PIXMAN_DITHER_ORDERED_BAYER_8, 354 PIXMAN_DITHER_ORDERED_BLUE_NOISE_64, 355 } pixman_dither_t; 356 357 typedef enum 358 { 359 PIXMAN_FILTER_FAST, 360 PIXMAN_FILTER_GOOD, 361 PIXMAN_FILTER_BEST, 362 PIXMAN_FILTER_NEAREST, 363 PIXMAN_FILTER_BILINEAR, 364 PIXMAN_FILTER_CONVOLUTION, 365 366 /* The SEPARABLE_CONVOLUTION filter takes the following parameters: 367 * 368 * width: integer given as 16.16 fixpoint number 369 * height: integer given as 16.16 fixpoint number 370 * x_phase_bits: integer given as 16.16 fixpoint 371 * y_phase_bits: integer given as 16.16 fixpoint 372 * xtables: (1 << x_phase_bits) tables of size width 373 * ytables: (1 << y_phase_bits) tables of size height 374 * 375 * When sampling at (x, y), the location is first rounded to one of 376 * n_x_phases * n_y_phases subpixel positions. These subpixel positions 377 * determine an xtable and a ytable to use. 378 * 379 * Conceptually a width x height matrix is then formed in which each entry 380 * is the product of the corresponding entries in the x and y tables. 381 * This matrix is then aligned with the image pixels such that its center 382 * is as close as possible to the subpixel location chosen earlier. Then 383 * the image is convolved with the matrix and the resulting pixel returned. 384 */ 385 PIXMAN_FILTER_SEPARABLE_CONVOLUTION 386 } pixman_filter_t; 387 388 typedef enum 389 { 390 PIXMAN_OP_CLEAR = 0x00, 391 PIXMAN_OP_SRC = 0x01, 392 PIXMAN_OP_DST = 0x02, 393 PIXMAN_OP_OVER = 0x03, 394 PIXMAN_OP_OVER_REVERSE = 0x04, 395 PIXMAN_OP_IN = 0x05, 396 PIXMAN_OP_IN_REVERSE = 0x06, 397 PIXMAN_OP_OUT = 0x07, 398 PIXMAN_OP_OUT_REVERSE = 0x08, 399 PIXMAN_OP_ATOP = 0x09, 400 PIXMAN_OP_ATOP_REVERSE = 0x0a, 401 PIXMAN_OP_XOR = 0x0b, 402 PIXMAN_OP_ADD = 0x0c, 403 PIXMAN_OP_SATURATE = 0x0d, 404 405 PIXMAN_OP_DISJOINT_CLEAR = 0x10, 406 PIXMAN_OP_DISJOINT_SRC = 0x11, 407 PIXMAN_OP_DISJOINT_DST = 0x12, 408 PIXMAN_OP_DISJOINT_OVER = 0x13, 409 PIXMAN_OP_DISJOINT_OVER_REVERSE = 0x14, 410 PIXMAN_OP_DISJOINT_IN = 0x15, 411 PIXMAN_OP_DISJOINT_IN_REVERSE = 0x16, 412 PIXMAN_OP_DISJOINT_OUT = 0x17, 413 PIXMAN_OP_DISJOINT_OUT_REVERSE = 0x18, 414 PIXMAN_OP_DISJOINT_ATOP = 0x19, 415 PIXMAN_OP_DISJOINT_ATOP_REVERSE = 0x1a, 416 PIXMAN_OP_DISJOINT_XOR = 0x1b, 417 418 PIXMAN_OP_CONJOINT_CLEAR = 0x20, 419 PIXMAN_OP_CONJOINT_SRC = 0x21, 420 PIXMAN_OP_CONJOINT_DST = 0x22, 421 PIXMAN_OP_CONJOINT_OVER = 0x23, 422 PIXMAN_OP_CONJOINT_OVER_REVERSE = 0x24, 423 PIXMAN_OP_CONJOINT_IN = 0x25, 424 PIXMAN_OP_CONJOINT_IN_REVERSE = 0x26, 425 PIXMAN_OP_CONJOINT_OUT = 0x27, 426 PIXMAN_OP_CONJOINT_OUT_REVERSE = 0x28, 427 PIXMAN_OP_CONJOINT_ATOP = 0x29, 428 PIXMAN_OP_CONJOINT_ATOP_REVERSE = 0x2a, 429 PIXMAN_OP_CONJOINT_XOR = 0x2b, 430 431 PIXMAN_OP_MULTIPLY = 0x30, 432 PIXMAN_OP_SCREEN = 0x31, 433 PIXMAN_OP_OVERLAY = 0x32, 434 PIXMAN_OP_DARKEN = 0x33, 435 PIXMAN_OP_LIGHTEN = 0x34, 436 PIXMAN_OP_COLOR_DODGE = 0x35, 437 PIXMAN_OP_COLOR_BURN = 0x36, 438 PIXMAN_OP_HARD_LIGHT = 0x37, 439 PIXMAN_OP_SOFT_LIGHT = 0x38, 440 PIXMAN_OP_DIFFERENCE = 0x39, 441 PIXMAN_OP_EXCLUSION = 0x3a, 442 PIXMAN_OP_HSL_HUE = 0x3b, 443 PIXMAN_OP_HSL_SATURATION = 0x3c, 444 PIXMAN_OP_HSL_COLOR = 0x3d, 445 PIXMAN_OP_HSL_LUMINOSITY = 0x3e 446 447 #ifdef PIXMAN_USE_INTERNAL_API 448 , 449 PIXMAN_N_OPERATORS, 450 PIXMAN_OP_NONE = PIXMAN_N_OPERATORS, 451 PIXMAN_OP_any = PIXMAN_N_OPERATORS + 1 452 #endif 453 } pixman_op_t; 454 455 /* 456 * Regions 457 */ 458 typedef struct pixman_region16_data pixman_region16_data_t; 459 typedef struct pixman_box16 pixman_box16_t; 460 typedef struct pixman_rectangle16 pixman_rectangle16_t; 461 typedef struct pixman_region16 pixman_region16_t; 462 463 struct pixman_region16_data { 464 long size; 465 long numRects; 466 /* pixman_box16_t rects[size]; in memory but not explicitly declared */ 467 }; 468 469 struct pixman_rectangle16 470 { 471 int16_t x, y; 472 uint16_t width, height; 473 }; 474 475 struct pixman_box16 476 { 477 int16_t x1, y1, x2, y2; 478 }; 479 480 struct pixman_region16 481 { 482 pixman_box16_t extents; 483 pixman_region16_data_t *data; 484 }; 485 486 typedef enum 487 { 488 PIXMAN_REGION_OUT, 489 PIXMAN_REGION_IN, 490 PIXMAN_REGION_PART 491 } pixman_region_overlap_t; 492 493 /* This function exists only to make it possible to preserve 494 * the X ABI - it should go away at first opportunity. 495 */ 496 PIXMAN_API 497 void pixman_region_set_static_pointers (pixman_box16_t *empty_box, 498 pixman_region16_data_t *empty_data, 499 pixman_region16_data_t *broken_data); 500 501 /* creation/destruction */ 502 PIXMAN_API 503 void pixman_region_init (pixman_region16_t *region); 504 505 PIXMAN_API 506 void pixman_region_init_rect (pixman_region16_t *region, 507 int x, 508 int y, 509 unsigned int width, 510 unsigned int height); 511 512 PIXMAN_API 513 pixman_bool_t pixman_region_init_rects (pixman_region16_t *region, 514 const pixman_box16_t *boxes, 515 int count); 516 517 PIXMAN_API 518 void pixman_region_init_with_extents (pixman_region16_t *region, 519 const pixman_box16_t *extents); 520 521 PIXMAN_API 522 void pixman_region_init_from_image (pixman_region16_t *region, 523 pixman_image_t *image); 524 525 PIXMAN_API 526 void pixman_region_fini (pixman_region16_t *region); 527 528 529 /* manipulation */ 530 PIXMAN_API 531 void pixman_region_translate (pixman_region16_t *region, 532 int x, 533 int y); 534 535 PIXMAN_API 536 pixman_bool_t pixman_region_copy (pixman_region16_t *dest, 537 const pixman_region16_t *source); 538 539 PIXMAN_API 540 pixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg, 541 const pixman_region16_t *reg1, 542 const pixman_region16_t *reg2); 543 544 PIXMAN_API 545 pixman_bool_t pixman_region_union (pixman_region16_t *new_reg, 546 const pixman_region16_t *reg1, 547 const pixman_region16_t *reg2); 548 549 PIXMAN_API 550 pixman_bool_t pixman_region_union_rect (pixman_region16_t *dest, 551 const pixman_region16_t *source, 552 int x, 553 int y, 554 unsigned int width, 555 unsigned int height); 556 557 PIXMAN_API 558 pixman_bool_t pixman_region_intersect_rect (pixman_region16_t *dest, 559 const pixman_region16_t *source, 560 int x, 561 int y, 562 unsigned int width, 563 unsigned int height); 564 565 PIXMAN_API 566 pixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d, 567 const pixman_region16_t *reg_m, 568 const pixman_region16_t *reg_s); 569 570 PIXMAN_API 571 pixman_bool_t pixman_region_inverse (pixman_region16_t *new_reg, 572 const pixman_region16_t *reg1, 573 const pixman_box16_t *inv_rect); 574 575 PIXMAN_API 576 pixman_bool_t pixman_region_contains_point (const pixman_region16_t *region, 577 int x, 578 int y, 579 pixman_box16_t *box); 580 581 PIXMAN_API 582 pixman_region_overlap_t pixman_region_contains_rectangle (const pixman_region16_t *region, 583 const pixman_box16_t *prect); 584 585 PIXMAN_API 586 pixman_bool_t pixman_region_empty (const pixman_region16_t *region); 587 588 PIXMAN_API 589 pixman_bool_t pixman_region_not_empty (const pixman_region16_t *region); 590 591 PIXMAN_API 592 pixman_box16_t * pixman_region_extents (const pixman_region16_t *region); 593 594 PIXMAN_API 595 int pixman_region_n_rects (const pixman_region16_t *region); 596 597 PIXMAN_API 598 pixman_box16_t * pixman_region_rectangles (const pixman_region16_t *region, 599 int *n_rects); 600 601 PIXMAN_API 602 pixman_bool_t pixman_region_equal (const pixman_region16_t *region1, 603 const pixman_region16_t *region2); 604 605 PIXMAN_API 606 pixman_bool_t pixman_region_selfcheck (const pixman_region16_t *region); 607 608 PIXMAN_API 609 void pixman_region_reset (pixman_region16_t *region, 610 const pixman_box16_t *box); 611 612 PIXMAN_API 613 void pixman_region_clear (pixman_region16_t *region); 614 /* 615 * 32 bit regions 616 */ 617 typedef struct pixman_region32_data pixman_region32_data_t; 618 typedef struct pixman_box32 pixman_box32_t; 619 typedef struct pixman_rectangle32 pixman_rectangle32_t; 620 typedef struct pixman_region32 pixman_region32_t; 621 622 struct pixman_region32_data { 623 long size; 624 long numRects; 625 /* pixman_box32_t rects[size]; in memory but not explicitly declared */ 626 }; 627 628 struct pixman_rectangle32 629 { 630 int32_t x, y; 631 uint32_t width, height; 632 }; 633 634 struct pixman_box32 635 { 636 int32_t x1, y1, x2, y2; 637 }; 638 639 struct pixman_region32 640 { 641 pixman_box32_t extents; 642 pixman_region32_data_t *data; 643 }; 644 645 /* creation/destruction */ 646 PIXMAN_API 647 void pixman_region32_init (pixman_region32_t *region); 648 649 PIXMAN_API 650 void pixman_region32_init_rect (pixman_region32_t *region, 651 int x, 652 int y, 653 unsigned int width, 654 unsigned int height); 655 656 PIXMAN_API 657 pixman_bool_t pixman_region32_init_rects (pixman_region32_t *region, 658 const pixman_box32_t *boxes, 659 int count); 660 661 PIXMAN_API 662 void pixman_region32_init_with_extents (pixman_region32_t *region, 663 const pixman_box32_t *extents); 664 665 PIXMAN_API 666 void pixman_region32_init_from_image (pixman_region32_t *region, 667 pixman_image_t *image); 668 669 PIXMAN_API 670 void pixman_region32_fini (pixman_region32_t *region); 671 672 673 /* manipulation */ 674 PIXMAN_API 675 void pixman_region32_translate (pixman_region32_t *region, 676 int x, 677 int y); 678 679 PIXMAN_API 680 pixman_bool_t pixman_region32_copy (pixman_region32_t *dest, 681 const pixman_region32_t *source); 682 683 PIXMAN_API 684 pixman_bool_t pixman_region32_intersect (pixman_region32_t *new_reg, 685 const pixman_region32_t *reg1, 686 const pixman_region32_t *reg2); 687 688 PIXMAN_API 689 pixman_bool_t pixman_region32_union (pixman_region32_t *new_reg, 690 const pixman_region32_t *reg1, 691 const pixman_region32_t *reg2); 692 693 PIXMAN_API 694 pixman_bool_t pixman_region32_intersect_rect (pixman_region32_t *dest, 695 const pixman_region32_t *source, 696 int x, 697 int y, 698 unsigned int width, 699 unsigned int height); 700 701 PIXMAN_API 702 pixman_bool_t pixman_region32_union_rect (pixman_region32_t *dest, 703 const pixman_region32_t *source, 704 int x, 705 int y, 706 unsigned int width, 707 unsigned int height); 708 709 PIXMAN_API 710 pixman_bool_t pixman_region32_subtract (pixman_region32_t *reg_d, 711 const pixman_region32_t *reg_m, 712 const pixman_region32_t *reg_s); 713 714 PIXMAN_API 715 pixman_bool_t pixman_region32_inverse (pixman_region32_t *new_reg, 716 const pixman_region32_t *reg1, 717 const pixman_box32_t *inv_rect); 718 719 PIXMAN_API 720 pixman_bool_t pixman_region32_contains_point (const pixman_region32_t *region, 721 int x, 722 int y, 723 pixman_box32_t *box); 724 725 PIXMAN_API 726 pixman_region_overlap_t pixman_region32_contains_rectangle (const pixman_region32_t *region, 727 const pixman_box32_t *prect); 728 729 PIXMAN_API 730 pixman_bool_t pixman_region32_empty (const pixman_region32_t *region); 731 732 PIXMAN_API 733 pixman_bool_t pixman_region32_not_empty (const pixman_region32_t *region); 734 735 PIXMAN_API 736 pixman_box32_t * pixman_region32_extents (const pixman_region32_t *region); 737 738 PIXMAN_API 739 int pixman_region32_n_rects (const pixman_region32_t *region); 740 741 PIXMAN_API 742 pixman_box32_t * pixman_region32_rectangles (const pixman_region32_t *region, 743 int *n_rects); 744 745 PIXMAN_API 746 pixman_bool_t pixman_region32_equal (const pixman_region32_t *region1, 747 const pixman_region32_t *region2); 748 749 PIXMAN_API 750 pixman_bool_t pixman_region32_selfcheck (const pixman_region32_t *region); 751 752 PIXMAN_API 753 void pixman_region32_reset (pixman_region32_t *region, 754 const pixman_box32_t *box); 755 756 PIXMAN_API 757 void pixman_region32_clear (pixman_region32_t *region); 758 /* 759 * 64 bit fractional regions 760 */ 761 typedef struct pixman_region64f_data pixman_region64f_data_t; 762 typedef struct pixman_box64f pixman_box64f_t; 763 typedef struct pixman_rectangle64f pixman_rectangle64f_t; 764 typedef struct pixman_region64f pixman_region64f_t; 765 766 struct pixman_region64f_data { 767 long size; 768 long numRects; 769 /* pixman_box64f_t rects[size]; in memory but not explicitly declared */ 770 }; 771 772 struct pixman_rectangle64f 773 { 774 double x, y; 775 double width, height; 776 }; 777 778 struct pixman_box64f 779 { 780 double x1, y1, x2, y2; 781 }; 782 783 struct pixman_region64f 784 { 785 pixman_box64f_t extents; 786 pixman_region64f_data_t *data; 787 }; 788 789 /* creation/destruction */ 790 PIXMAN_API 791 void pixman_region64f_init (pixman_region64f_t *region); 792 793 PIXMAN_API 794 void pixman_region64f_init_rect (pixman_region64f_t *region, 795 int x, 796 int y, 797 unsigned int width, 798 unsigned int height); 799 800 PIXMAN_API 801 void pixman_region64f_init_rectf (pixman_region64f_t *region, 802 double x, 803 double y, 804 double width, 805 double height); 806 807 PIXMAN_API 808 pixman_bool_t pixman_region64f_init_rects (pixman_region64f_t *region, 809 const pixman_box64f_t *boxes, 810 int count); 811 812 PIXMAN_API 813 void pixman_region64f_init_with_extents (pixman_region64f_t *region, 814 const pixman_box64f_t *extents); 815 816 PIXMAN_API 817 void pixman_region64f_init_from_image (pixman_region64f_t *region, 818 pixman_image_t *image); 819 820 PIXMAN_API 821 void pixman_region64f_fini (pixman_region64f_t *region); 822 823 824 /* manipulation */ 825 PIXMAN_API 826 void pixman_region64f_translate (pixman_region64f_t *region, 827 int x, 828 int y); 829 830 PIXMAN_API 831 void pixman_region64f_translatef (pixman_region64f_t *region, 832 double x, 833 double y); 834 835 PIXMAN_API 836 pixman_bool_t pixman_region64f_copy (pixman_region64f_t *dest, 837 const pixman_region64f_t *source); 838 839 PIXMAN_API 840 pixman_bool_t pixman_region64f_intersect (pixman_region64f_t *new_reg, 841 const pixman_region64f_t *reg1, 842 const pixman_region64f_t *reg2); 843 844 PIXMAN_API 845 pixman_bool_t pixman_region64f_union (pixman_region64f_t *new_reg, 846 const pixman_region64f_t *reg1, 847 const pixman_region64f_t *reg2); 848 849 PIXMAN_API 850 pixman_bool_t pixman_region64f_intersect_rect (pixman_region64f_t *dest, 851 const pixman_region64f_t *source, 852 int x, 853 int y, 854 unsigned int width, 855 unsigned int height); 856 857 PIXMAN_API 858 pixman_bool_t pixman_region64f_intersect_rectf (pixman_region64f_t *dest, 859 const pixman_region64f_t *source, 860 double x, 861 double y, 862 double width, 863 double height); 864 865 PIXMAN_API 866 pixman_bool_t pixman_region64f_union_rect (pixman_region64f_t *dest, 867 const pixman_region64f_t *source, 868 int x, 869 int y, 870 unsigned int width, 871 unsigned int height); 872 873 PIXMAN_API 874 pixman_bool_t pixman_region64f_union_rectf (pixman_region64f_t *dest, 875 const pixman_region64f_t *source, 876 double x, 877 double y, 878 double width, 879 double height); 880 881 PIXMAN_API 882 pixman_bool_t pixman_region64f_subtract (pixman_region64f_t *reg_d, 883 const pixman_region64f_t *reg_m, 884 const pixman_region64f_t *reg_s); 885 886 PIXMAN_API 887 pixman_bool_t pixman_region64f_inverse (pixman_region64f_t *new_reg, 888 const pixman_region64f_t *reg1, 889 const pixman_box64f_t *inv_rect); 890 891 PIXMAN_API 892 pixman_bool_t pixman_region64f_contains_point (const pixman_region64f_t *region, 893 int x, 894 int y, 895 pixman_box64f_t *box); 896 897 PIXMAN_API 898 pixman_bool_t pixman_region64f_contains_pointf (const pixman_region64f_t *region, 899 double x, 900 double y, 901 pixman_box64f_t *box); 902 903 PIXMAN_API 904 pixman_region_overlap_t pixman_region64f_contains_rectangle(const pixman_region64f_t *region, 905 const pixman_box64f_t *prect); 906 907 PIXMAN_API 908 pixman_bool_t pixman_region64f_empty (const pixman_region64f_t *region); 909 910 PIXMAN_API 911 pixman_bool_t pixman_region64f_not_empty (const pixman_region64f_t *region); 912 913 PIXMAN_API 914 pixman_box64f_t * pixman_region64f_extents (const pixman_region64f_t *region); 915 916 PIXMAN_API 917 int pixman_region64f_n_rects (const pixman_region64f_t *region); 918 919 PIXMAN_API 920 pixman_box64f_t * pixman_region64f_rectangles (const pixman_region64f_t *region, 921 int *n_rects); 922 923 PIXMAN_API 924 pixman_bool_t pixman_region64f_equal (const pixman_region64f_t *region1, 925 const pixman_region64f_t *region2); 926 927 PIXMAN_API 928 pixman_bool_t pixman_region64f_selfcheck (const pixman_region64f_t *region); 929 930 PIXMAN_API 931 void pixman_region64f_reset (pixman_region64f_t *region, 932 const pixman_box64f_t *box); 933 934 PIXMAN_API 935 void pixman_region64f_clear (pixman_region64f_t *region); 936 937 938 /* Copy / Fill / Misc */ 939 PIXMAN_API 940 pixman_bool_t pixman_blt (uint32_t *src_bits, 941 uint32_t *dst_bits, 942 int src_stride, 943 int dst_stride, 944 int src_bpp, 945 int dst_bpp, 946 int src_x, 947 int src_y, 948 int dest_x, 949 int dest_y, 950 int width, 951 int height); 952 953 PIXMAN_API 954 pixman_bool_t pixman_fill (uint32_t *bits, 955 int stride, 956 int bpp, 957 int x, 958 int y, 959 int width, 960 int height, 961 uint32_t _xor); 962 963 964 PIXMAN_API 965 int pixman_version (void); 966 967 PIXMAN_API 968 const char* pixman_version_string (void); 969 970 /* 971 * Images 972 */ 973 typedef struct pixman_indexed pixman_indexed_t; 974 typedef struct pixman_gradient_stop pixman_gradient_stop_t; 975 976 typedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size); 977 typedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size); 978 979 typedef void (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data); 980 981 struct pixman_gradient_stop { 982 pixman_fixed_t x; 983 pixman_color_t color; 984 }; 985 986 #define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */ 987 988 #if PIXMAN_MAX_INDEXED <= 256 989 typedef uint8_t pixman_index_type; 990 #endif 991 992 struct pixman_indexed 993 { 994 pixman_bool_t color; 995 uint32_t rgba[PIXMAN_MAX_INDEXED]; 996 pixman_index_type ent[32768]; 997 }; 998 999 /* 1000 * While the protocol is generous in format support, the 1001 * sample implementation allows only packed RGB and GBR 1002 * representations for data to simplify software rendering, 1003 */ 1004 #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \ 1005 ((type) << 16) | \ 1006 ((a) << 12) | \ 1007 ((r) << 8) | \ 1008 ((g) << 4) | \ 1009 ((b))) 1010 1011 #define PIXMAN_FORMAT_BYTE(bpp,type,a,r,g,b) \ 1012 (((bpp >> 3) << 24) | \ 1013 (3 << 22) | ((type) << 16) | \ 1014 ((a >> 3) << 12) | \ 1015 ((r >> 3) << 8) | \ 1016 ((g >> 3) << 4) | \ 1017 ((b >> 3))) 1018 1019 #define PIXMAN_FORMAT_RESHIFT(val, ofs, num) \ 1020 (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3)) 1021 1022 #define PIXMAN_FORMAT_BPP(f) PIXMAN_FORMAT_RESHIFT(f, 24, 8) 1023 #define PIXMAN_FORMAT_SHIFT(f) ((uint32_t)((f >> 22) & 3)) 1024 #define PIXMAN_FORMAT_TYPE(f) (((f) >> 16) & 0x3f) 1025 #define PIXMAN_FORMAT_A(f) PIXMAN_FORMAT_RESHIFT(f, 12, 4) 1026 #define PIXMAN_FORMAT_R(f) PIXMAN_FORMAT_RESHIFT(f, 8, 4) 1027 #define PIXMAN_FORMAT_G(f) PIXMAN_FORMAT_RESHIFT(f, 4, 4) 1028 #define PIXMAN_FORMAT_B(f) PIXMAN_FORMAT_RESHIFT(f, 0, 4) 1029 #define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff) 1030 #define PIXMAN_FORMAT_VIS(f) (((f) ) & 0xffff) 1031 #define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) + \ 1032 PIXMAN_FORMAT_R(f) + \ 1033 PIXMAN_FORMAT_G(f) + \ 1034 PIXMAN_FORMAT_B(f)) 1035 1036 #define PIXMAN_TYPE_OTHER 0 1037 #define PIXMAN_TYPE_A 1 1038 #define PIXMAN_TYPE_ARGB 2 1039 #define PIXMAN_TYPE_ABGR 3 1040 #define PIXMAN_TYPE_COLOR 4 1041 #define PIXMAN_TYPE_GRAY 5 1042 #define PIXMAN_TYPE_YUY2 6 1043 #define PIXMAN_TYPE_YV12 7 1044 #define PIXMAN_TYPE_BGRA 8 1045 #define PIXMAN_TYPE_RGBA 9 1046 #define PIXMAN_TYPE_ARGB_SRGB 10 1047 #define PIXMAN_TYPE_RGBA_FLOAT 11 1048 1049 #define PIXMAN_FORMAT_COLOR(f) \ 1050 (PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \ 1051 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR || \ 1052 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA || \ 1053 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA || \ 1054 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA_FLOAT) 1055 1056 typedef enum { 1057 /* 128bpp formats */ 1058 PIXMAN_rgba_float = PIXMAN_FORMAT_BYTE(128,PIXMAN_TYPE_RGBA_FLOAT,32,32,32,32), 1059 /* 96bpp formats */ 1060 PIXMAN_rgb_float = PIXMAN_FORMAT_BYTE(96,PIXMAN_TYPE_RGBA_FLOAT,0,32,32,32), 1061 1062 /* 64bpp formats */ 1063 /* [63:0] A:B:G:R 16:16:16:16 native endian */ 1064 PIXMAN_a16b16g16r16 = PIXMAN_FORMAT_BYTE(64,PIXMAN_TYPE_ABGR,16,16,16,16), 1065 1066 /* 32bpp formats */ 1067 PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8), 1068 PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8), 1069 PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8), 1070 PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8), 1071 PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8), 1072 PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8), 1073 PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8), 1074 PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8), 1075 PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6), 1076 PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10), 1077 PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10), 1078 PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10), 1079 PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10), 1080 1081 /* sRGB formats */ 1082 PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8), 1083 PIXMAN_r8g8b8_sRGB = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB_SRGB,0,8,8,8), 1084 1085 /* 24bpp formats */ 1086 PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8), 1087 PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8), 1088 1089 /* 16bpp formats */ 1090 PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5), 1091 PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5), 1092 1093 PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5), 1094 PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5), 1095 PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5), 1096 PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5), 1097 PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4), 1098 PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4), 1099 PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4), 1100 PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4), 1101 1102 /* 8bpp formats */ 1103 PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0), 1104 PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2), 1105 PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2), 1106 PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2), 1107 PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2), 1108 1109 PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 1110 PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 1111 1112 PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0), 1113 1114 PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0), 1115 PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0), 1116 1117 /* 4bpp formats */ 1118 PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0), 1119 PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1), 1120 PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1), 1121 PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1), 1122 PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1), 1123 1124 PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0), 1125 PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0), 1126 1127 /* 1bpp formats */ 1128 PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), 1129 1130 PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), 1131 1132 /* YUV formats */ 1133 PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0), 1134 PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0) 1135 } pixman_format_code_t; 1136 1137 /* Querying supported format values. */ 1138 PIXMAN_API 1139 pixman_bool_t pixman_format_supported_destination (pixman_format_code_t format); 1140 1141 PIXMAN_API 1142 pixman_bool_t pixman_format_supported_source (pixman_format_code_t format); 1143 1144 /* Constructors */ 1145 PIXMAN_API 1146 pixman_image_t *pixman_image_create_solid_fill (const pixman_color_t *color); 1147 1148 PIXMAN_API 1149 pixman_image_t *pixman_image_create_linear_gradient (const pixman_point_fixed_t *p1, 1150 const pixman_point_fixed_t *p2, 1151 const pixman_gradient_stop_t *stops, 1152 int n_stops); 1153 1154 PIXMAN_API 1155 pixman_image_t *pixman_image_create_radial_gradient (const pixman_point_fixed_t *inner, 1156 const pixman_point_fixed_t *outer, 1157 pixman_fixed_t inner_radius, 1158 pixman_fixed_t outer_radius, 1159 const pixman_gradient_stop_t *stops, 1160 int n_stops); 1161 1162 PIXMAN_API 1163 pixman_image_t *pixman_image_create_conical_gradient (const pixman_point_fixed_t *center, 1164 pixman_fixed_t angle, 1165 const pixman_gradient_stop_t *stops, 1166 int n_stops); 1167 1168 PIXMAN_API 1169 pixman_image_t *pixman_image_create_bits (pixman_format_code_t format, 1170 int width, 1171 int height, 1172 uint32_t *bits, 1173 int rowstride_bytes); 1174 1175 PIXMAN_API 1176 pixman_image_t *pixman_image_create_bits_no_clear (pixman_format_code_t format, 1177 int width, 1178 int height, 1179 uint32_t * bits, 1180 int rowstride_bytes); 1181 1182 /* Destructor */ 1183 PIXMAN_API 1184 pixman_image_t *pixman_image_ref (pixman_image_t *image); 1185 1186 PIXMAN_API 1187 pixman_bool_t pixman_image_unref (pixman_image_t *image); 1188 1189 1190 PIXMAN_API 1191 void pixman_image_set_destroy_function (pixman_image_t *image, 1192 pixman_image_destroy_func_t function, 1193 void *data); 1194 1195 PIXMAN_API 1196 void * pixman_image_get_destroy_data (pixman_image_t *image); 1197 1198 /* Set properties */ 1199 PIXMAN_API 1200 pixman_bool_t pixman_image_set_clip_region (pixman_image_t *image, 1201 const pixman_region16_t *region); 1202 1203 PIXMAN_API 1204 pixman_bool_t pixman_image_set_clip_region32 (pixman_image_t *image, 1205 const pixman_region32_t *region); 1206 1207 PIXMAN_API 1208 pixman_bool_t pixman_image_set_clip_region64f (pixman_image_t *image, 1209 const pixman_region64f_t *region); 1210 1211 PIXMAN_API 1212 void pixman_image_set_has_client_clip (pixman_image_t *image, 1213 pixman_bool_t clien_clip); 1214 1215 PIXMAN_API 1216 pixman_bool_t pixman_image_set_transform (pixman_image_t *image, 1217 const pixman_transform_t *transform); 1218 1219 PIXMAN_API 1220 void pixman_image_set_repeat (pixman_image_t *image, 1221 pixman_repeat_t repeat); 1222 1223 PIXMAN_API 1224 void pixman_image_set_dither (pixman_image_t *image, 1225 pixman_dither_t dither); 1226 1227 PIXMAN_API 1228 void pixman_image_set_dither_offset (pixman_image_t *image, 1229 int offset_x, 1230 int offset_y); 1231 1232 PIXMAN_API 1233 pixman_bool_t pixman_image_set_filter (pixman_image_t *image, 1234 pixman_filter_t filter, 1235 const pixman_fixed_t *filter_params, 1236 int n_filter_params); 1237 1238 PIXMAN_API 1239 void pixman_image_set_source_clipping (pixman_image_t *image, 1240 pixman_bool_t source_clipping); 1241 1242 PIXMAN_API 1243 void pixman_image_set_alpha_map (pixman_image_t *image, 1244 pixman_image_t *alpha_map, 1245 int16_t x, 1246 int16_t y); 1247 1248 PIXMAN_API 1249 void pixman_image_set_component_alpha (pixman_image_t *image, 1250 pixman_bool_t component_alpha); 1251 1252 PIXMAN_API 1253 pixman_bool_t pixman_image_get_component_alpha (pixman_image_t *image); 1254 1255 PIXMAN_API 1256 void pixman_image_set_accessors (pixman_image_t *image, 1257 pixman_read_memory_func_t read_func, 1258 pixman_write_memory_func_t write_func); 1259 1260 PIXMAN_API 1261 void pixman_image_set_indexed (pixman_image_t *image, 1262 const pixman_indexed_t *indexed); 1263 1264 PIXMAN_API 1265 uint32_t *pixman_image_get_data (pixman_image_t *image); 1266 1267 PIXMAN_API 1268 int pixman_image_get_width (pixman_image_t *image); 1269 1270 PIXMAN_API 1271 int pixman_image_get_height (pixman_image_t *image); 1272 1273 PIXMAN_API 1274 int pixman_image_get_stride (pixman_image_t *image); /* in bytes */ 1275 1276 PIXMAN_API 1277 int pixman_image_get_depth (pixman_image_t *image); 1278 1279 PIXMAN_API 1280 pixman_format_code_t pixman_image_get_format (pixman_image_t *image); 1281 1282 typedef enum 1283 { 1284 PIXMAN_KERNEL_IMPULSE, 1285 PIXMAN_KERNEL_BOX, 1286 PIXMAN_KERNEL_LINEAR, 1287 PIXMAN_KERNEL_CUBIC, 1288 PIXMAN_KERNEL_GAUSSIAN, 1289 PIXMAN_KERNEL_LANCZOS2, 1290 PIXMAN_KERNEL_LANCZOS3, 1291 PIXMAN_KERNEL_LANCZOS3_STRETCHED /* Jim Blinn's 'nice' filter */ 1292 } pixman_kernel_t; 1293 1294 /* Create the parameter list for a SEPARABLE_CONVOLUTION filter 1295 * with the given kernels and scale parameters. 1296 */ 1297 PIXMAN_API 1298 pixman_fixed_t * 1299 pixman_filter_create_separable_convolution (int *n_values, 1300 pixman_fixed_t scale_x, 1301 pixman_fixed_t scale_y, 1302 pixman_kernel_t reconstruct_x, 1303 pixman_kernel_t reconstruct_y, 1304 pixman_kernel_t sample_x, 1305 pixman_kernel_t sample_y, 1306 int subsample_bits_x, 1307 int subsample_bits_y); 1308 1309 1310 PIXMAN_API 1311 pixman_bool_t pixman_image_fill_rectangles (pixman_op_t op, 1312 pixman_image_t *image, 1313 const pixman_color_t *color, 1314 int n_rects, 1315 const pixman_rectangle16_t *rects); 1316 1317 PIXMAN_API 1318 pixman_bool_t pixman_image_fill_boxes (pixman_op_t op, 1319 pixman_image_t *dest, 1320 const pixman_color_t *color, 1321 int n_boxes, 1322 const pixman_box32_t *boxes); 1323 1324 /* Composite */ 1325 PIXMAN_API 1326 pixman_bool_t pixman_compute_composite_region (pixman_region16_t *region, 1327 pixman_image_t *src_image, 1328 pixman_image_t *mask_image, 1329 pixman_image_t *dest_image, 1330 int16_t src_x, 1331 int16_t src_y, 1332 int16_t mask_x, 1333 int16_t mask_y, 1334 int16_t dest_x, 1335 int16_t dest_y, 1336 uint16_t width, 1337 uint16_t height); 1338 1339 PIXMAN_API 1340 void pixman_image_composite (pixman_op_t op, 1341 pixman_image_t *src, 1342 pixman_image_t *mask, 1343 pixman_image_t *dest, 1344 int16_t src_x, 1345 int16_t src_y, 1346 int16_t mask_x, 1347 int16_t mask_y, 1348 int16_t dest_x, 1349 int16_t dest_y, 1350 uint16_t width, 1351 uint16_t height); 1352 1353 PIXMAN_API 1354 void pixman_image_composite32 (pixman_op_t op, 1355 pixman_image_t *src, 1356 pixman_image_t *mask, 1357 pixman_image_t *dest, 1358 int32_t src_x, 1359 int32_t src_y, 1360 int32_t mask_x, 1361 int32_t mask_y, 1362 int32_t dest_x, 1363 int32_t dest_y, 1364 int32_t width, 1365 int32_t height); 1366 1367 PIXMAN_API 1368 void pixman_image_composite64f (pixman_op_t op, 1369 pixman_image_t *src, 1370 pixman_image_t *mask, 1371 pixman_image_t *dest, 1372 double src_x, 1373 double src_y, 1374 double mask_x, 1375 double mask_y, 1376 double dest_x, 1377 double dest_y, 1378 double width, 1379 double height); 1380 1381 /* Executive Summary: This function is a no-op that only exists 1382 * for historical reasons. 1383 * 1384 * There used to be a bug in the X server where it would rely on 1385 * out-of-bounds accesses when it was asked to composite with a 1386 * window as the source. It would create a pixman image pointing 1387 * to some bogus position in memory, but then set a clip region 1388 * to the position where the actual bits were. 1389 * 1390 * Due to a bug in old versions of pixman, where it would not clip 1391 * against the image bounds when a clip region was set, this would 1392 * actually work. So when the pixman bug was fixed, a workaround was 1393 * added to allow certain out-of-bound accesses. This function disabled 1394 * those workarounds. 1395 * 1396 * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this 1397 * function is a no-op. 1398 */ 1399 PIXMAN_API 1400 void pixman_disable_out_of_bounds_workaround (void); 1401 1402 /* 1403 * Glyphs 1404 */ 1405 typedef struct pixman_glyph_cache_t pixman_glyph_cache_t; 1406 typedef struct 1407 { 1408 int x, y; 1409 const void *glyph; 1410 } pixman_glyph_t; 1411 1412 PIXMAN_API 1413 pixman_glyph_cache_t *pixman_glyph_cache_create (void); 1414 1415 PIXMAN_API 1416 void pixman_glyph_cache_destroy (pixman_glyph_cache_t *cache); 1417 1418 PIXMAN_API 1419 void pixman_glyph_cache_freeze (pixman_glyph_cache_t *cache); 1420 1421 PIXMAN_API 1422 void pixman_glyph_cache_thaw (pixman_glyph_cache_t *cache); 1423 1424 PIXMAN_API 1425 const void * pixman_glyph_cache_lookup (pixman_glyph_cache_t *cache, 1426 void *font_key, 1427 void *glyph_key); 1428 1429 PIXMAN_API 1430 const void * pixman_glyph_cache_insert (pixman_glyph_cache_t *cache, 1431 void *font_key, 1432 void *glyph_key, 1433 int origin_x, 1434 int origin_y, 1435 pixman_image_t *glyph_image); 1436 1437 PIXMAN_API 1438 void pixman_glyph_cache_remove (pixman_glyph_cache_t *cache, 1439 void *font_key, 1440 void *glyph_key); 1441 1442 PIXMAN_API 1443 void pixman_glyph_get_extents (pixman_glyph_cache_t *cache, 1444 int n_glyphs, 1445 pixman_glyph_t *glyphs, 1446 pixman_box32_t *extents); 1447 1448 PIXMAN_API 1449 pixman_format_code_t pixman_glyph_get_mask_format (pixman_glyph_cache_t *cache, 1450 int n_glyphs, 1451 const pixman_glyph_t *glyphs); 1452 1453 PIXMAN_API 1454 void pixman_composite_glyphs (pixman_op_t op, 1455 pixman_image_t *src, 1456 pixman_image_t *dest, 1457 pixman_format_code_t mask_format, 1458 int32_t src_x, 1459 int32_t src_y, 1460 int32_t mask_x, 1461 int32_t mask_y, 1462 int32_t dest_x, 1463 int32_t dest_y, 1464 int32_t width, 1465 int32_t height, 1466 pixman_glyph_cache_t *cache, 1467 int n_glyphs, 1468 const pixman_glyph_t *glyphs); 1469 1470 PIXMAN_API 1471 void pixman_composite_glyphs_no_mask (pixman_op_t op, 1472 pixman_image_t *src, 1473 pixman_image_t *dest, 1474 int32_t src_x, 1475 int32_t src_y, 1476 int32_t dest_x, 1477 int32_t dest_y, 1478 pixman_glyph_cache_t *cache, 1479 int n_glyphs, 1480 const pixman_glyph_t *glyphs); 1481 1482 /* 1483 * Trapezoids 1484 */ 1485 typedef struct pixman_edge pixman_edge_t; 1486 typedef struct pixman_trapezoid pixman_trapezoid_t; 1487 typedef struct pixman_trap pixman_trap_t; 1488 typedef struct pixman_span_fix pixman_span_fix_t; 1489 typedef struct pixman_triangle pixman_triangle_t; 1490 1491 /* 1492 * An edge structure. This represents a single polygon edge 1493 * and can be quickly stepped across small or large gaps in the 1494 * sample grid 1495 */ 1496 struct pixman_edge 1497 { 1498 pixman_fixed_t x; 1499 pixman_fixed_t e; 1500 pixman_fixed_t stepx; 1501 pixman_fixed_t signdx; 1502 pixman_fixed_t dy; 1503 pixman_fixed_t dx; 1504 1505 pixman_fixed_t stepx_small; 1506 pixman_fixed_t stepx_big; 1507 pixman_fixed_t dx_small; 1508 pixman_fixed_t dx_big; 1509 }; 1510 1511 struct pixman_trapezoid 1512 { 1513 pixman_fixed_t top, bottom; 1514 pixman_line_fixed_t left, right; 1515 }; 1516 1517 struct pixman_triangle 1518 { 1519 pixman_point_fixed_t p1, p2, p3; 1520 }; 1521 1522 /* whether 't' is a well defined not obviously empty trapezoid */ 1523 #define pixman_trapezoid_valid(t) \ 1524 ((t)->left.p1.y != (t)->left.p2.y && \ 1525 (t)->right.p1.y != (t)->right.p2.y && \ 1526 ((t)->bottom > (t)->top)) 1527 1528 struct pixman_span_fix 1529 { 1530 pixman_fixed_t l, r, y; 1531 }; 1532 1533 struct pixman_trap 1534 { 1535 pixman_span_fix_t top, bot; 1536 }; 1537 1538 PIXMAN_API 1539 pixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y, 1540 int bpp); 1541 1542 PIXMAN_API 1543 pixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y, 1544 int bpp); 1545 1546 PIXMAN_API 1547 void pixman_edge_step (pixman_edge_t *e, 1548 int n); 1549 1550 PIXMAN_API 1551 void pixman_edge_init (pixman_edge_t *e, 1552 int bpp, 1553 pixman_fixed_t y_start, 1554 pixman_fixed_t x_top, 1555 pixman_fixed_t y_top, 1556 pixman_fixed_t x_bot, 1557 pixman_fixed_t y_bot); 1558 1559 PIXMAN_API 1560 void pixman_line_fixed_edge_init (pixman_edge_t *e, 1561 int bpp, 1562 pixman_fixed_t y, 1563 const pixman_line_fixed_t *line, 1564 int x_off, 1565 int y_off); 1566 1567 PIXMAN_API 1568 void pixman_rasterize_edges (pixman_image_t *image, 1569 pixman_edge_t *l, 1570 pixman_edge_t *r, 1571 pixman_fixed_t t, 1572 pixman_fixed_t b); 1573 1574 PIXMAN_API 1575 void pixman_add_traps (pixman_image_t *image, 1576 int16_t x_off, 1577 int16_t y_off, 1578 int ntrap, 1579 const pixman_trap_t *traps); 1580 1581 PIXMAN_API 1582 void pixman_add_trapezoids (pixman_image_t *image, 1583 int16_t x_off, 1584 int y_off, 1585 int ntraps, 1586 const pixman_trapezoid_t *traps); 1587 1588 PIXMAN_API 1589 void pixman_rasterize_trapezoid (pixman_image_t *image, 1590 const pixman_trapezoid_t *trap, 1591 int x_off, 1592 int y_off); 1593 1594 PIXMAN_API 1595 void pixman_composite_trapezoids (pixman_op_t op, 1596 pixman_image_t * src, 1597 pixman_image_t * dst, 1598 pixman_format_code_t mask_format, 1599 int x_src, 1600 int y_src, 1601 int x_dst, 1602 int y_dst, 1603 int n_traps, 1604 const pixman_trapezoid_t * traps); 1605 1606 PIXMAN_API 1607 void pixman_composite_triangles (pixman_op_t op, 1608 pixman_image_t * src, 1609 pixman_image_t * dst, 1610 pixman_format_code_t mask_format, 1611 int x_src, 1612 int y_src, 1613 int x_dst, 1614 int y_dst, 1615 int n_tris, 1616 const pixman_triangle_t * tris); 1617 1618 PIXMAN_API 1619 void pixman_add_triangles (pixman_image_t *image, 1620 int32_t x_off, 1621 int32_t y_off, 1622 int n_tris, 1623 const pixman_triangle_t *tris); 1624 1625 PIXMAN_END_DECLS 1626 1627 #endif /* PIXMAN_H__ */ 1628