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