pixman (0.42.2)
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 #endif
452 } pixman_op_t;
453
454 /*
455 * Regions
456 */
457 typedef struct pixman_region16_data pixman_region16_data_t;
458 typedef struct pixman_box16 pixman_box16_t;
459 typedef struct pixman_rectangle16 pixman_rectangle16_t;
460 typedef struct pixman_region16 pixman_region16_t;
461
462 struct pixman_region16_data {
463 long size;
464 long numRects;
465 /* pixman_box16_t rects[size]; in memory but not explicitly declared */
466 };
467
468 struct pixman_rectangle16
469 {
470 int16_t x, y;
471 uint16_t width, height;
472 };
473
474 struct pixman_box16
475 {
476 int16_t x1, y1, x2, y2;
477 };
478
479 struct pixman_region16
480 {
481 pixman_box16_t extents;
482 pixman_region16_data_t *data;
483 };
484
485 typedef enum
486 {
487 PIXMAN_REGION_OUT,
488 PIXMAN_REGION_IN,
489 PIXMAN_REGION_PART
490 } pixman_region_overlap_t;
491
492 /* This function exists only to make it possible to preserve
493 * the X ABI - it should go away at first opportunity.
494 */
495 PIXMAN_API
496 void pixman_region_set_static_pointers (pixman_box16_t *empty_box,
497 pixman_region16_data_t *empty_data,
498 pixman_region16_data_t *broken_data);
499
500 /* creation/destruction */
501 PIXMAN_API
502 void pixman_region_init (pixman_region16_t *region);
503
504 PIXMAN_API
505 void pixman_region_init_rect (pixman_region16_t *region,
506 int x,
507 int y,
508 unsigned int width,
509 unsigned int height);
510
511 PIXMAN_API
512 pixman_bool_t pixman_region_init_rects (pixman_region16_t *region,
513 const pixman_box16_t *boxes,
514 int count);
515
516 PIXMAN_API
517 void pixman_region_init_with_extents (pixman_region16_t *region,
518 const pixman_box16_t *extents);
519
520 PIXMAN_API
521 void pixman_region_init_from_image (pixman_region16_t *region,
522 pixman_image_t *image);
523
524 PIXMAN_API
525 void pixman_region_fini (pixman_region16_t *region);
526
527
528 /* manipulation */
529 PIXMAN_API
530 void pixman_region_translate (pixman_region16_t *region,
531 int x,
532 int y);
533
534 PIXMAN_API
535 pixman_bool_t pixman_region_copy (pixman_region16_t *dest,
536 const pixman_region16_t *source);
537
538 PIXMAN_API
539 pixman_bool_t pixman_region_intersect (pixman_region16_t *new_reg,
540 const pixman_region16_t *reg1,
541 const pixman_region16_t *reg2);
542
543 PIXMAN_API
544 pixman_bool_t pixman_region_union (pixman_region16_t *new_reg,
545 const pixman_region16_t *reg1,
546 const pixman_region16_t *reg2);
547
548 PIXMAN_API
549 pixman_bool_t pixman_region_union_rect (pixman_region16_t *dest,
550 const pixman_region16_t *source,
551 int x,
552 int y,
553 unsigned int width,
554 unsigned int height);
555
556 PIXMAN_API
557 pixman_bool_t pixman_region_intersect_rect (pixman_region16_t *dest,
558 const pixman_region16_t *source,
559 int x,
560 int y,
561 unsigned int width,
562 unsigned int height);
563
564 PIXMAN_API
565 pixman_bool_t pixman_region_subtract (pixman_region16_t *reg_d,
566 const pixman_region16_t *reg_m,
567 const pixman_region16_t *reg_s);
568
569 PIXMAN_API
570 pixman_bool_t pixman_region_inverse (pixman_region16_t *new_reg,
571 const pixman_region16_t *reg1,
572 const pixman_box16_t *inv_rect);
573
574 PIXMAN_API
575 pixman_bool_t pixman_region_contains_point (const pixman_region16_t *region,
576 int x,
577 int y,
578 pixman_box16_t *box);
579
580 PIXMAN_API
581 pixman_region_overlap_t pixman_region_contains_rectangle (const pixman_region16_t *region,
582 const pixman_box16_t *prect);
583
584 PIXMAN_API
585 pixman_bool_t pixman_region_not_empty (const pixman_region16_t *region);
586
587 PIXMAN_API
588 pixman_box16_t * pixman_region_extents (const pixman_region16_t *region);
589
590 PIXMAN_API
591 int pixman_region_n_rects (const pixman_region16_t *region);
592
593 PIXMAN_API
594 pixman_box16_t * pixman_region_rectangles (const pixman_region16_t *region,
595 int *n_rects);
596
597 PIXMAN_API
598 pixman_bool_t pixman_region_equal (const pixman_region16_t *region1,
599 const pixman_region16_t *region2);
600
601 PIXMAN_API
602 pixman_bool_t pixman_region_selfcheck (pixman_region16_t *region);
603
604 PIXMAN_API
605 void pixman_region_reset (pixman_region16_t *region,
606 const pixman_box16_t *box);
607
608 PIXMAN_API
609 void pixman_region_clear (pixman_region16_t *region);
610 /*
611 * 32 bit regions
612 */
613 typedef struct pixman_region32_data pixman_region32_data_t;
614 typedef struct pixman_box32 pixman_box32_t;
615 typedef struct pixman_rectangle32 pixman_rectangle32_t;
616 typedef struct pixman_region32 pixman_region32_t;
617
618 struct pixman_region32_data {
619 long size;
620 long numRects;
621 /* pixman_box32_t rects[size]; in memory but not explicitly declared */
622 };
623
624 struct pixman_rectangle32
625 {
626 int32_t x, y;
627 uint32_t width, height;
628 };
629
630 struct pixman_box32
631 {
632 int32_t x1, y1, x2, y2;
633 };
634
635 struct pixman_region32
636 {
637 pixman_box32_t extents;
638 pixman_region32_data_t *data;
639 };
640
641 /* creation/destruction */
642 PIXMAN_API
643 void pixman_region32_init (pixman_region32_t *region);
644
645 PIXMAN_API
646 void pixman_region32_init_rect (pixman_region32_t *region,
647 int x,
648 int y,
649 unsigned int width,
650 unsigned int height);
651
652 PIXMAN_API
653 pixman_bool_t pixman_region32_init_rects (pixman_region32_t *region,
654 const pixman_box32_t *boxes,
655 int count);
656
657 PIXMAN_API
658 void pixman_region32_init_with_extents (pixman_region32_t *region,
659 const pixman_box32_t *extents);
660
661 PIXMAN_API
662 void pixman_region32_init_from_image (pixman_region32_t *region,
663 pixman_image_t *image);
664
665 PIXMAN_API
666 void pixman_region32_fini (pixman_region32_t *region);
667
668
669 /* manipulation */
670 PIXMAN_API
671 void pixman_region32_translate (pixman_region32_t *region,
672 int x,
673 int y);
674
675 PIXMAN_API
676 pixman_bool_t pixman_region32_copy (pixman_region32_t *dest,
677 const pixman_region32_t *source);
678
679 PIXMAN_API
680 pixman_bool_t pixman_region32_intersect (pixman_region32_t *new_reg,
681 const pixman_region32_t *reg1,
682 const pixman_region32_t *reg2);
683
684 PIXMAN_API
685 pixman_bool_t pixman_region32_union (pixman_region32_t *new_reg,
686 const pixman_region32_t *reg1,
687 const pixman_region32_t *reg2);
688
689 PIXMAN_API
690 pixman_bool_t pixman_region32_intersect_rect (pixman_region32_t *dest,
691 const pixman_region32_t *source,
692 int x,
693 int y,
694 unsigned int width,
695 unsigned int height);
696
697 PIXMAN_API
698 pixman_bool_t pixman_region32_union_rect (pixman_region32_t *dest,
699 const pixman_region32_t *source,
700 int x,
701 int y,
702 unsigned int width,
703 unsigned int height);
704
705 PIXMAN_API
706 pixman_bool_t pixman_region32_subtract (pixman_region32_t *reg_d,
707 const pixman_region32_t *reg_m,
708 const pixman_region32_t *reg_s);
709
710 PIXMAN_API
711 pixman_bool_t pixman_region32_inverse (pixman_region32_t *new_reg,
712 const pixman_region32_t *reg1,
713 const pixman_box32_t *inv_rect);
714
715 PIXMAN_API
716 pixman_bool_t pixman_region32_contains_point (const pixman_region32_t *region,
717 int x,
718 int y,
719 pixman_box32_t *box);
720
721 PIXMAN_API
722 pixman_region_overlap_t pixman_region32_contains_rectangle (const pixman_region32_t *region,
723 const pixman_box32_t *prect);
724
725 PIXMAN_API
726 pixman_bool_t pixman_region32_not_empty (const pixman_region32_t *region);
727
728 PIXMAN_API
729 pixman_box32_t * pixman_region32_extents (const pixman_region32_t *region);
730
731 PIXMAN_API
732 int pixman_region32_n_rects (const pixman_region32_t *region);
733
734 PIXMAN_API
735 pixman_box32_t * pixman_region32_rectangles (const pixman_region32_t *region,
736 int *n_rects);
737
738 PIXMAN_API
739 pixman_bool_t pixman_region32_equal (const pixman_region32_t *region1,
740 const pixman_region32_t *region2);
741
742 PIXMAN_API
743 pixman_bool_t pixman_region32_selfcheck (pixman_region32_t *region);
744
745 PIXMAN_API
746 void pixman_region32_reset (pixman_region32_t *region,
747 const pixman_box32_t *box);
748
749 PIXMAN_API
750 void pixman_region32_clear (pixman_region32_t *region);
751
752
753 /* Copy / Fill / Misc */
754 PIXMAN_API
755 pixman_bool_t pixman_blt (uint32_t *src_bits,
756 uint32_t *dst_bits,
757 int src_stride,
758 int dst_stride,
759 int src_bpp,
760 int dst_bpp,
761 int src_x,
762 int src_y,
763 int dest_x,
764 int dest_y,
765 int width,
766 int height);
767
768 PIXMAN_API
769 pixman_bool_t pixman_fill (uint32_t *bits,
770 int stride,
771 int bpp,
772 int x,
773 int y,
774 int width,
775 int height,
776 uint32_t _xor);
777
778
779 PIXMAN_API
780 int pixman_version (void);
781
782 PIXMAN_API
783 const char* pixman_version_string (void);
784
785 /*
786 * Images
787 */
788 typedef struct pixman_indexed pixman_indexed_t;
789 typedef struct pixman_gradient_stop pixman_gradient_stop_t;
790
791 typedef uint32_t (* pixman_read_memory_func_t) (const void *src, int size);
792 typedef void (* pixman_write_memory_func_t) (void *dst, uint32_t value, int size);
793
794 typedef void (* pixman_image_destroy_func_t) (pixman_image_t *image, void *data);
795
796 struct pixman_gradient_stop {
797 pixman_fixed_t x;
798 pixman_color_t color;
799 };
800
801 #define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */
802
803 #if PIXMAN_MAX_INDEXED <= 256
804 typedef uint8_t pixman_index_type;
805 #endif
806
807 struct pixman_indexed
808 {
809 pixman_bool_t color;
810 uint32_t rgba[PIXMAN_MAX_INDEXED];
811 pixman_index_type ent[32768];
812 };
813
814 /*
815 * While the protocol is generous in format support, the
816 * sample implementation allows only packed RGB and GBR
817 * representations for data to simplify software rendering,
818 */
819 #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
820 ((type) << 16) | \
821 ((a) << 12) | \
822 ((r) << 8) | \
823 ((g) << 4) | \
824 ((b)))
825
826 #define PIXMAN_FORMAT_BYTE(bpp,type,a,r,g,b) \
827 (((bpp >> 3) << 24) | \
828 (3 << 22) | ((type) << 16) | \
829 ((a >> 3) << 12) | \
830 ((r >> 3) << 8) | \
831 ((g >> 3) << 4) | \
832 ((b >> 3)))
833
834 #define PIXMAN_FORMAT_RESHIFT(val, ofs, num) \
835 (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3))
836
837 #define PIXMAN_FORMAT_BPP(f) PIXMAN_FORMAT_RESHIFT(f, 24, 8)
838 #define PIXMAN_FORMAT_SHIFT(f) ((uint32_t)((f >> 22) & 3))
839 #define PIXMAN_FORMAT_TYPE(f) (((f) >> 16) & 0x3f)
840 #define PIXMAN_FORMAT_A(f) PIXMAN_FORMAT_RESHIFT(f, 12, 4)
841 #define PIXMAN_FORMAT_R(f) PIXMAN_FORMAT_RESHIFT(f, 8, 4)
842 #define PIXMAN_FORMAT_G(f) PIXMAN_FORMAT_RESHIFT(f, 4, 4)
843 #define PIXMAN_FORMAT_B(f) PIXMAN_FORMAT_RESHIFT(f, 0, 4)
844 #define PIXMAN_FORMAT_RGB(f) (((f) ) & 0xfff)
845 #define PIXMAN_FORMAT_VIS(f) (((f) ) & 0xffff)
846 #define PIXMAN_FORMAT_DEPTH(f) (PIXMAN_FORMAT_A(f) + \
847 PIXMAN_FORMAT_R(f) + \
848 PIXMAN_FORMAT_G(f) + \
849 PIXMAN_FORMAT_B(f))
850
851 #define PIXMAN_TYPE_OTHER 0
852 #define PIXMAN_TYPE_A 1
853 #define PIXMAN_TYPE_ARGB 2
854 #define PIXMAN_TYPE_ABGR 3
855 #define PIXMAN_TYPE_COLOR 4
856 #define PIXMAN_TYPE_GRAY 5
857 #define PIXMAN_TYPE_YUY2 6
858 #define PIXMAN_TYPE_YV12 7
859 #define PIXMAN_TYPE_BGRA 8
860 #define PIXMAN_TYPE_RGBA 9
861 #define PIXMAN_TYPE_ARGB_SRGB 10
862 #define PIXMAN_TYPE_RGBA_FLOAT 11
863
864 #define PIXMAN_FORMAT_COLOR(f) \
865 (PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \
866 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ABGR || \
867 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_BGRA || \
868 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA || \
869 PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_RGBA_FLOAT)
870
871 typedef enum {
872 /* 128bpp formats */
873 PIXMAN_rgba_float = PIXMAN_FORMAT_BYTE(128,PIXMAN_TYPE_RGBA_FLOAT,32,32,32,32),
874 /* 96bpp formats */
875 PIXMAN_rgb_float = PIXMAN_FORMAT_BYTE(96,PIXMAN_TYPE_RGBA_FLOAT,0,32,32,32),
876
877 /* 32bpp formats */
878 PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
879 PIXMAN_x8r8g8b8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
880 PIXMAN_a8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
881 PIXMAN_x8b8g8r8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
882 PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
883 PIXMAN_b8g8r8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
884 PIXMAN_r8g8b8a8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8),
885 PIXMAN_r8g8b8x8 = PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8),
886 PIXMAN_x14r6g6b6 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
887 PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10),
888 PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
889 PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
890 PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
891
892 /* sRGB formats */
893 PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
894
895 /* 24bpp formats */
896 PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),
897 PIXMAN_b8g8r8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ABGR,0,8,8,8),
898
899 /* 16bpp formats */
900 PIXMAN_r5g6b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,6,5),
901 PIXMAN_b5g6r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,6,5),
902
903 PIXMAN_a1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,1,5,5,5),
904 PIXMAN_x1r5g5b5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,5,5,5),
905 PIXMAN_a1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,1,5,5,5),
906 PIXMAN_x1b5g5r5 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,5,5,5),
907 PIXMAN_a4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,4,4,4,4),
908 PIXMAN_x4r4g4b4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ARGB,0,4,4,4),
909 PIXMAN_a4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,4,4,4,4),
910 PIXMAN_x4b4g4r4 = PIXMAN_FORMAT(16,PIXMAN_TYPE_ABGR,0,4,4,4),
911
912 /* 8bpp formats */
913 PIXMAN_a8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0),
914 PIXMAN_r3g3b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,0,3,3,2),
915 PIXMAN_b2g3r3 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,0,3,3,2),
916 PIXMAN_a2r2g2b2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ARGB,2,2,2,2),
917 PIXMAN_a2b2g2r2 = PIXMAN_FORMAT(8,PIXMAN_TYPE_ABGR,2,2,2,2),
918
919 PIXMAN_c8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
920 PIXMAN_g8 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
921
922 PIXMAN_x4a4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_A,4,0,0,0),
923
924 PIXMAN_x4c4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_COLOR,0,0,0,0),
925 PIXMAN_x4g4 = PIXMAN_FORMAT(8,PIXMAN_TYPE_GRAY,0,0,0,0),
926
927 /* 4bpp formats */
928 PIXMAN_a4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_A,4,0,0,0),
929 PIXMAN_r1g2b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,0,1,2,1),
930 PIXMAN_b1g2r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,0,1,2,1),
931 PIXMAN_a1r1g1b1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ARGB,1,1,1,1),
932 PIXMAN_a1b1g1r1 = PIXMAN_FORMAT(4,PIXMAN_TYPE_ABGR,1,1,1,1),
933
934 PIXMAN_c4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_COLOR,0,0,0,0),
935 PIXMAN_g4 = PIXMAN_FORMAT(4,PIXMAN_TYPE_GRAY,0,0,0,0),
936
937 /* 1bpp formats */
938 PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0),
939
940 PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
941
942 /* YUV formats */
943 PIXMAN_yuy2 = PIXMAN_FORMAT(16,PIXMAN_TYPE_YUY2,0,0,0,0),
944 PIXMAN_yv12 = PIXMAN_FORMAT(12,PIXMAN_TYPE_YV12,0,0,0,0)
945 } pixman_format_code_t;
946
947 /* Querying supported format values. */
948 PIXMAN_API
949 pixman_bool_t pixman_format_supported_destination (pixman_format_code_t format);
950
951 PIXMAN_API
952 pixman_bool_t pixman_format_supported_source (pixman_format_code_t format);
953
954 /* Constructors */
955 PIXMAN_API
956 pixman_image_t *pixman_image_create_solid_fill (const pixman_color_t *color);
957
958 PIXMAN_API
959 pixman_image_t *pixman_image_create_linear_gradient (const pixman_point_fixed_t *p1,
960 const pixman_point_fixed_t *p2,
961 const pixman_gradient_stop_t *stops,
962 int n_stops);
963
964 PIXMAN_API
965 pixman_image_t *pixman_image_create_radial_gradient (const pixman_point_fixed_t *inner,
966 const pixman_point_fixed_t *outer,
967 pixman_fixed_t inner_radius,
968 pixman_fixed_t outer_radius,
969 const pixman_gradient_stop_t *stops,
970 int n_stops);
971
972 PIXMAN_API
973 pixman_image_t *pixman_image_create_conical_gradient (const pixman_point_fixed_t *center,
974 pixman_fixed_t angle,
975 const pixman_gradient_stop_t *stops,
976 int n_stops);
977
978 PIXMAN_API
979 pixman_image_t *pixman_image_create_bits (pixman_format_code_t format,
980 int width,
981 int height,
982 uint32_t *bits,
983 int rowstride_bytes);
984
985 PIXMAN_API
986 pixman_image_t *pixman_image_create_bits_no_clear (pixman_format_code_t format,
987 int width,
988 int height,
989 uint32_t * bits,
990 int rowstride_bytes);
991
992 /* Destructor */
993 PIXMAN_API
994 pixman_image_t *pixman_image_ref (pixman_image_t *image);
995
996 PIXMAN_API
997 pixman_bool_t pixman_image_unref (pixman_image_t *image);
998
999
1000 PIXMAN_API
1001 void pixman_image_set_destroy_function (pixman_image_t *image,
1002 pixman_image_destroy_func_t function,
1003 void *data);
1004
1005 PIXMAN_API
1006 void * pixman_image_get_destroy_data (pixman_image_t *image);
1007
1008 /* Set properties */
1009 PIXMAN_API
1010 pixman_bool_t pixman_image_set_clip_region (pixman_image_t *image,
1011 pixman_region16_t *region);
1012
1013 PIXMAN_API
1014 pixman_bool_t pixman_image_set_clip_region32 (pixman_image_t *image,
1015 pixman_region32_t *region);
1016
1017 PIXMAN_API
1018 void pixman_image_set_has_client_clip (pixman_image_t *image,
1019 pixman_bool_t clien_clip);
1020
1021 PIXMAN_API
1022 pixman_bool_t pixman_image_set_transform (pixman_image_t *image,
1023 const pixman_transform_t *transform);
1024
1025 PIXMAN_API
1026 void pixman_image_set_repeat (pixman_image_t *image,
1027 pixman_repeat_t repeat);
1028
1029 PIXMAN_API
1030 void pixman_image_set_dither (pixman_image_t *image,
1031 pixman_dither_t dither);
1032
1033 PIXMAN_API
1034 void pixman_image_set_dither_offset (pixman_image_t *image,
1035 int offset_x,
1036 int offset_y);
1037
1038 PIXMAN_API
1039 pixman_bool_t pixman_image_set_filter (pixman_image_t *image,
1040 pixman_filter_t filter,
1041 const pixman_fixed_t *filter_params,
1042 int n_filter_params);
1043
1044 PIXMAN_API
1045 void pixman_image_set_source_clipping (pixman_image_t *image,
1046 pixman_bool_t source_clipping);
1047
1048 PIXMAN_API
1049 void pixman_image_set_alpha_map (pixman_image_t *image,
1050 pixman_image_t *alpha_map,
1051 int16_t x,
1052 int16_t y);
1053
1054 PIXMAN_API
1055 void pixman_image_set_component_alpha (pixman_image_t *image,
1056 pixman_bool_t component_alpha);
1057
1058 PIXMAN_API
1059 pixman_bool_t pixman_image_get_component_alpha (pixman_image_t *image);
1060
1061 PIXMAN_API
1062 void pixman_image_set_accessors (pixman_image_t *image,
1063 pixman_read_memory_func_t read_func,
1064 pixman_write_memory_func_t write_func);
1065
1066 PIXMAN_API
1067 void pixman_image_set_indexed (pixman_image_t *image,
1068 const pixman_indexed_t *indexed);
1069
1070 PIXMAN_API
1071 uint32_t *pixman_image_get_data (pixman_image_t *image);
1072
1073 PIXMAN_API
1074 int pixman_image_get_width (pixman_image_t *image);
1075
1076 PIXMAN_API
1077 int pixman_image_get_height (pixman_image_t *image);
1078
1079 PIXMAN_API
1080 int pixman_image_get_stride (pixman_image_t *image); /* in bytes */
1081
1082 PIXMAN_API
1083 int pixman_image_get_depth (pixman_image_t *image);
1084
1085 PIXMAN_API
1086 pixman_format_code_t pixman_image_get_format (pixman_image_t *image);
1087
1088 typedef enum
1089 {
1090 PIXMAN_KERNEL_IMPULSE,
1091 PIXMAN_KERNEL_BOX,
1092 PIXMAN_KERNEL_LINEAR,
1093 PIXMAN_KERNEL_CUBIC,
1094 PIXMAN_KERNEL_GAUSSIAN,
1095 PIXMAN_KERNEL_LANCZOS2,
1096 PIXMAN_KERNEL_LANCZOS3,
1097 PIXMAN_KERNEL_LANCZOS3_STRETCHED /* Jim Blinn's 'nice' filter */
1098 } pixman_kernel_t;
1099
1100 /* Create the parameter list for a SEPARABLE_CONVOLUTION filter
1101 * with the given kernels and scale parameters.
1102 */
1103 PIXMAN_API
1104 pixman_fixed_t *
1105 pixman_filter_create_separable_convolution (int *n_values,
1106 pixman_fixed_t scale_x,
1107 pixman_fixed_t scale_y,
1108 pixman_kernel_t reconstruct_x,
1109 pixman_kernel_t reconstruct_y,
1110 pixman_kernel_t sample_x,
1111 pixman_kernel_t sample_y,
1112 int subsample_bits_x,
1113 int subsample_bits_y);
1114
1115
1116 PIXMAN_API
1117 pixman_bool_t pixman_image_fill_rectangles (pixman_op_t op,
1118 pixman_image_t *image,
1119 const pixman_color_t *color,
1120 int n_rects,
1121 const pixman_rectangle16_t *rects);
1122
1123 PIXMAN_API
1124 pixman_bool_t pixman_image_fill_boxes (pixman_op_t op,
1125 pixman_image_t *dest,
1126 const pixman_color_t *color,
1127 int n_boxes,
1128 const pixman_box32_t *boxes);
1129
1130 /* Composite */
1131 PIXMAN_API
1132 pixman_bool_t pixman_compute_composite_region (pixman_region16_t *region,
1133 pixman_image_t *src_image,
1134 pixman_image_t *mask_image,
1135 pixman_image_t *dest_image,
1136 int16_t src_x,
1137 int16_t src_y,
1138 int16_t mask_x,
1139 int16_t mask_y,
1140 int16_t dest_x,
1141 int16_t dest_y,
1142 uint16_t width,
1143 uint16_t height);
1144
1145 PIXMAN_API
1146 void pixman_image_composite (pixman_op_t op,
1147 pixman_image_t *src,
1148 pixman_image_t *mask,
1149 pixman_image_t *dest,
1150 int16_t src_x,
1151 int16_t src_y,
1152 int16_t mask_x,
1153 int16_t mask_y,
1154 int16_t dest_x,
1155 int16_t dest_y,
1156 uint16_t width,
1157 uint16_t height);
1158
1159 PIXMAN_API
1160 void pixman_image_composite32 (pixman_op_t op,
1161 pixman_image_t *src,
1162 pixman_image_t *mask,
1163 pixman_image_t *dest,
1164 int32_t src_x,
1165 int32_t src_y,
1166 int32_t mask_x,
1167 int32_t mask_y,
1168 int32_t dest_x,
1169 int32_t dest_y,
1170 int32_t width,
1171 int32_t height);
1172
1173 /* Executive Summary: This function is a no-op that only exists
1174 * for historical reasons.
1175 *
1176 * There used to be a bug in the X server where it would rely on
1177 * out-of-bounds accesses when it was asked to composite with a
1178 * window as the source. It would create a pixman image pointing
1179 * to some bogus position in memory, but then set a clip region
1180 * to the position where the actual bits were.
1181 *
1182 * Due to a bug in old versions of pixman, where it would not clip
1183 * against the image bounds when a clip region was set, this would
1184 * actually work. So when the pixman bug was fixed, a workaround was
1185 * added to allow certain out-of-bound accesses. This function disabled
1186 * those workarounds.
1187 *
1188 * Since 0.21.2, pixman doesn't do these workarounds anymore, so now this
1189 * function is a no-op.
1190 */
1191 PIXMAN_API
1192 void pixman_disable_out_of_bounds_workaround (void);
1193
1194 /*
1195 * Glyphs
1196 */
1197 typedef struct pixman_glyph_cache_t pixman_glyph_cache_t;
1198 typedef struct
1199 {
1200 int x, y;
1201 const void *glyph;
1202 } pixman_glyph_t;
1203
1204 PIXMAN_API
1205 pixman_glyph_cache_t *pixman_glyph_cache_create (void);
1206
1207 PIXMAN_API
1208 void pixman_glyph_cache_destroy (pixman_glyph_cache_t *cache);
1209
1210 PIXMAN_API
1211 void pixman_glyph_cache_freeze (pixman_glyph_cache_t *cache);
1212
1213 PIXMAN_API
1214 void pixman_glyph_cache_thaw (pixman_glyph_cache_t *cache);
1215
1216 PIXMAN_API
1217 const void * pixman_glyph_cache_lookup (pixman_glyph_cache_t *cache,
1218 void *font_key,
1219 void *glyph_key);
1220
1221 PIXMAN_API
1222 const void * pixman_glyph_cache_insert (pixman_glyph_cache_t *cache,
1223 void *font_key,
1224 void *glyph_key,
1225 int origin_x,
1226 int origin_y,
1227 pixman_image_t *glyph_image);
1228
1229 PIXMAN_API
1230 void pixman_glyph_cache_remove (pixman_glyph_cache_t *cache,
1231 void *font_key,
1232 void *glyph_key);
1233
1234 PIXMAN_API
1235 void pixman_glyph_get_extents (pixman_glyph_cache_t *cache,
1236 int n_glyphs,
1237 pixman_glyph_t *glyphs,
1238 pixman_box32_t *extents);
1239
1240 PIXMAN_API
1241 pixman_format_code_t pixman_glyph_get_mask_format (pixman_glyph_cache_t *cache,
1242 int n_glyphs,
1243 const pixman_glyph_t *glyphs);
1244
1245 PIXMAN_API
1246 void pixman_composite_glyphs (pixman_op_t op,
1247 pixman_image_t *src,
1248 pixman_image_t *dest,
1249 pixman_format_code_t mask_format,
1250 int32_t src_x,
1251 int32_t src_y,
1252 int32_t mask_x,
1253 int32_t mask_y,
1254 int32_t dest_x,
1255 int32_t dest_y,
1256 int32_t width,
1257 int32_t height,
1258 pixman_glyph_cache_t *cache,
1259 int n_glyphs,
1260 const pixman_glyph_t *glyphs);
1261
1262 PIXMAN_API
1263 void pixman_composite_glyphs_no_mask (pixman_op_t op,
1264 pixman_image_t *src,
1265 pixman_image_t *dest,
1266 int32_t src_x,
1267 int32_t src_y,
1268 int32_t dest_x,
1269 int32_t dest_y,
1270 pixman_glyph_cache_t *cache,
1271 int n_glyphs,
1272 const pixman_glyph_t *glyphs);
1273
1274 /*
1275 * Trapezoids
1276 */
1277 typedef struct pixman_edge pixman_edge_t;
1278 typedef struct pixman_trapezoid pixman_trapezoid_t;
1279 typedef struct pixman_trap pixman_trap_t;
1280 typedef struct pixman_span_fix pixman_span_fix_t;
1281 typedef struct pixman_triangle pixman_triangle_t;
1282
1283 /*
1284 * An edge structure. This represents a single polygon edge
1285 * and can be quickly stepped across small or large gaps in the
1286 * sample grid
1287 */
1288 struct pixman_edge
1289 {
1290 pixman_fixed_t x;
1291 pixman_fixed_t e;
1292 pixman_fixed_t stepx;
1293 pixman_fixed_t signdx;
1294 pixman_fixed_t dy;
1295 pixman_fixed_t dx;
1296
1297 pixman_fixed_t stepx_small;
1298 pixman_fixed_t stepx_big;
1299 pixman_fixed_t dx_small;
1300 pixman_fixed_t dx_big;
1301 };
1302
1303 struct pixman_trapezoid
1304 {
1305 pixman_fixed_t top, bottom;
1306 pixman_line_fixed_t left, right;
1307 };
1308
1309 struct pixman_triangle
1310 {
1311 pixman_point_fixed_t p1, p2, p3;
1312 };
1313
1314 /* whether 't' is a well defined not obviously empty trapezoid */
1315 #define pixman_trapezoid_valid(t) \
1316 ((t)->left.p1.y != (t)->left.p2.y && \
1317 (t)->right.p1.y != (t)->right.p2.y && \
1318 ((t)->bottom > (t)->top))
1319
1320 struct pixman_span_fix
1321 {
1322 pixman_fixed_t l, r, y;
1323 };
1324
1325 struct pixman_trap
1326 {
1327 pixman_span_fix_t top, bot;
1328 };
1329
1330 PIXMAN_API
1331 pixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y,
1332 int bpp);
1333
1334 PIXMAN_API
1335 pixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y,
1336 int bpp);
1337
1338 PIXMAN_API
1339 void pixman_edge_step (pixman_edge_t *e,
1340 int n);
1341
1342 PIXMAN_API
1343 void pixman_edge_init (pixman_edge_t *e,
1344 int bpp,
1345 pixman_fixed_t y_start,
1346 pixman_fixed_t x_top,
1347 pixman_fixed_t y_top,
1348 pixman_fixed_t x_bot,
1349 pixman_fixed_t y_bot);
1350
1351 PIXMAN_API
1352 void pixman_line_fixed_edge_init (pixman_edge_t *e,
1353 int bpp,
1354 pixman_fixed_t y,
1355 const pixman_line_fixed_t *line,
1356 int x_off,
1357 int y_off);
1358
1359 PIXMAN_API
1360 void pixman_rasterize_edges (pixman_image_t *image,
1361 pixman_edge_t *l,
1362 pixman_edge_t *r,
1363 pixman_fixed_t t,
1364 pixman_fixed_t b);
1365
1366 PIXMAN_API
1367 void pixman_add_traps (pixman_image_t *image,
1368 int16_t x_off,
1369 int16_t y_off,
1370 int ntrap,
1371 const pixman_trap_t *traps);
1372
1373 PIXMAN_API
1374 void pixman_add_trapezoids (pixman_image_t *image,
1375 int16_t x_off,
1376 int y_off,
1377 int ntraps,
1378 const pixman_trapezoid_t *traps);
1379
1380 PIXMAN_API
1381 void pixman_rasterize_trapezoid (pixman_image_t *image,
1382 const pixman_trapezoid_t *trap,
1383 int x_off,
1384 int y_off);
1385
1386 PIXMAN_API
1387 void pixman_composite_trapezoids (pixman_op_t op,
1388 pixman_image_t * src,
1389 pixman_image_t * dst,
1390 pixman_format_code_t mask_format,
1391 int x_src,
1392 int y_src,
1393 int x_dst,
1394 int y_dst,
1395 int n_traps,
1396 const pixman_trapezoid_t * traps);
1397
1398 PIXMAN_API
1399 void pixman_composite_triangles (pixman_op_t op,
1400 pixman_image_t * src,
1401 pixman_image_t * dst,
1402 pixman_format_code_t mask_format,
1403 int x_src,
1404 int y_src,
1405 int x_dst,
1406 int y_dst,
1407 int n_tris,
1408 const pixman_triangle_t * tris);
1409
1410 PIXMAN_API
1411 void pixman_add_triangles (pixman_image_t *image,
1412 int32_t x_off,
1413 int32_t y_off,
1414 int n_tris,
1415 const pixman_triangle_t *tris);
1416
1417 PIXMAN_END_DECLS
1418
1419 #endif /* PIXMAN_H__ */