2 # error config.h must be included before pixman-private.h
5 #ifndef PIXMAN_PRIVATE_H
6 #define PIXMAN_PRIVATE_H
12 #include "pixman-compiler.h"
17 typedef struct image_common image_common_t;
18 typedef struct source_image source_image_t;
19 typedef struct solid_fill solid_fill_t;
20 typedef struct gradient gradient_t;
21 typedef struct linear_gradient linear_gradient_t;
22 typedef struct horizontal_gradient horizontal_gradient_t;
23 typedef struct vertical_gradient vertical_gradient_t;
24 typedef struct conical_gradient conical_gradient_t;
25 typedef struct radial_gradient radial_gradient_t;
26 typedef struct bits_image bits_image_t;
27 typedef struct circle circle_t;
29 typedef void (*fetch_scanline_t) (pixman_image_t *pict,
37 typedef void (*fetch_pixels_t) (bits_image_t * image,
41 typedef void (*store_scanline_t) (bits_image_t * image,
45 const uint32_t *values);
58 SOURCE_IMAGE_CLASS_UNKNOWN,
59 SOURCE_IMAGE_CLASS_HORIZONTAL,
60 SOURCE_IMAGE_CLASS_VERTICAL,
61 } source_pict_class_t;
63 typedef source_pict_class_t (*classify_func_t) (pixman_image_t *image,
68 typedef void (*property_changed_func_t) (pixman_image_t *image);
74 pixman_region32_t clip_region;
75 pixman_bool_t have_clip_region; /* FALSE if there is no clip */
76 pixman_bool_t client_clip; /* Whether the source clip was
78 pixman_bool_t clip_sources; /* Whether the clip applies when
79 * the image is used as a source
81 pixman_bool_t need_workaround;
82 pixman_transform_t * transform;
83 pixman_repeat_t repeat;
84 pixman_filter_t filter;
85 pixman_fixed_t * filter_params;
87 bits_image_t * alpha_map;
90 pixman_bool_t component_alpha;
91 classify_func_t classify;
92 property_changed_func_t property_changed;
93 fetch_scanline_t get_scanline_32;
94 fetch_scanline_t get_scanline_64;
96 pixman_image_destroy_func_t destroy_func;
102 image_common_t common;
103 source_pict_class_t class;
108 source_image_t common;
109 uint32_t color; /* FIXME: shouldn't this be a pixman_color_t? */
114 source_image_t common;
116 pixman_gradient_stop_t *stops;
118 uint32_t * color_table;
119 int color_table_size;
122 struct linear_gradient
125 pixman_point_fixed_t p1;
126 pixman_point_fixed_t p2;
133 pixman_fixed_t radius;
136 struct radial_gradient
148 struct conical_gradient
151 pixman_point_fixed_t center;
152 pixman_fixed_t angle;
157 image_common_t common;
158 pixman_format_code_t format;
159 const pixman_indexed_t * indexed;
164 int rowstride; /* in number of uint32_t's */
166 /* Fetch raw pixels, with no regard for transformations, alpha map etc. */
167 fetch_pixels_t fetch_pixels_raw_32;
168 fetch_pixels_t fetch_pixels_raw_64;
170 /* Fetch raw scanlines, with no regard for transformations, alpha maps etc. */
171 fetch_scanline_t fetch_scanline_raw_32;
172 fetch_scanline_t fetch_scanline_raw_64;
174 /* Store scanlines with no regard for alpha maps */
175 store_scanline_t store_scanline_raw_32;
176 store_scanline_t store_scanline_raw_64;
178 /* Store a scanline, taking alpha maps into account */
179 store_scanline_t store_scanline_32;
180 store_scanline_t store_scanline_64;
182 /* Used for indirect access to the bits */
183 pixman_read_memory_func_t read_func;
184 pixman_write_memory_func_t write_func;
190 image_common_t common;
192 source_image_t source;
194 linear_gradient_t linear;
195 conical_gradient_t conical;
196 radial_gradient_t radial;
202 _pixman_bits_image_setup_raw_accessors (bits_image_t *image);
205 _pixman_image_get_scanline_generic_64 (pixman_image_t *pict,
210 const uint32_t *mask,
214 _pixman_image_classify (pixman_image_t *image,
221 _pixman_image_get_scanline_32 (pixman_image_t *image,
226 const uint32_t *mask,
229 /* Even thought the type of buffer is uint32_t *, the function actually expects
230 * a uint64_t *buffer.
233 _pixman_image_get_scanline_64 (pixman_image_t *image,
238 const uint32_t *unused,
242 _pixman_image_store_scanline_32 (bits_image_t * image,
246 const uint32_t *buffer);
248 _pixman_image_fetch_pixels (bits_image_t *image,
252 /* Even though the type of buffer is uint32_t *, the function
253 * actually expects a uint64_t *buffer.
256 _pixman_image_store_scanline_64 (bits_image_t * image,
260 const uint32_t *buffer);
263 _pixman_image_allocate (void);
266 _pixman_init_gradient (gradient_t * gradient,
267 const pixman_gradient_stop_t *stops,
270 _pixman_image_reset_clip_region (pixman_image_t *image);
273 _pixman_image_is_opaque (pixman_image_t *image);
276 _pixman_image_is_solid (pixman_image_t *image);
279 _pixman_image_get_solid (pixman_image_t * image,
280 pixman_format_code_t format);
282 #define PIXMAN_IMAGE_GET_LINE(pict, x, y, type, out_stride, line, mul) \
285 uint32_t *__bits__; \
288 __bits__ = pict->bits.bits; \
289 __stride__ = pict->bits.rowstride; \
291 __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type); \
293 ((type *) __bits__) + (out_stride) * (y) + (mul) * (x); \
309 pixman_gradient_stop_t *stops;
314 } pixman_gradient_walker_t;
317 _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
318 gradient_t * gradient,
319 unsigned int spread);
322 _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
323 pixman_fixed_32_32_t pos);
326 _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
327 pixman_fixed_32_32_t x);
333 #define MAX_ALPHA(n) ((1 << (n)) - 1)
334 #define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) - 1)
335 #define N_X_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) + 1)
337 #define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC (n))
338 #define STEP_Y_BIG(n) (pixman_fixed_1 - (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
340 #define Y_FRAC_FIRST(n) (STEP_Y_SMALL (n) / 2)
341 #define Y_FRAC_LAST(n) (Y_FRAC_FIRST (n) + (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
343 #define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC (n))
344 #define STEP_X_BIG(n) (pixman_fixed_1 - (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
346 #define X_FRAC_FIRST(n) (STEP_X_SMALL (n) / 2)
347 #define X_FRAC_LAST(n) (X_FRAC_FIRST (n) + (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
349 #define RENDER_SAMPLES_X(x, n) \
350 ((n) == 1? 0 : (pixman_fixed_frac (x) + \
351 X_FRAC_FIRST (n)) / STEP_X_SMALL (n))
354 pixman_rasterize_edges_accessors (pixman_image_t *image,
364 typedef struct pixman_implementation_t pixman_implementation_t;
366 typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp,
369 const uint32_t * src,
370 const uint32_t * mask,
373 typedef void (*pixman_combine_64_func_t) (pixman_implementation_t *imp,
376 const uint64_t * src,
377 const uint64_t * mask,
380 typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp,
382 pixman_image_t * src,
383 pixman_image_t * mask,
384 pixman_image_t * dest,
393 typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp,
406 typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
416 void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
417 void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
419 struct pixman_implementation_t
421 pixman_implementation_t *toplevel;
422 pixman_implementation_t *delegate;
424 pixman_composite_func_t composite;
425 pixman_blt_func_t blt;
426 pixman_fill_func_t fill;
428 pixman_combine_32_func_t combine_32[PIXMAN_OP_LAST];
429 pixman_combine_32_func_t combine_32_ca[PIXMAN_OP_LAST];
430 pixman_combine_64_func_t combine_64[PIXMAN_OP_LAST];
431 pixman_combine_64_func_t combine_64_ca[PIXMAN_OP_LAST];
434 pixman_implementation_t *
435 _pixman_implementation_create (pixman_implementation_t *delegate);
438 _pixman_implementation_combine_32 (pixman_implementation_t *imp,
441 const uint32_t * src,
442 const uint32_t * mask,
445 _pixman_implementation_combine_64 (pixman_implementation_t *imp,
448 const uint64_t * src,
449 const uint64_t * mask,
452 _pixman_implementation_combine_32_ca (pixman_implementation_t *imp,
455 const uint32_t * src,
456 const uint32_t * mask,
459 _pixman_implementation_combine_64_ca (pixman_implementation_t *imp,
462 const uint64_t * src,
463 const uint64_t * mask,
466 _pixman_implementation_composite (pixman_implementation_t *imp,
468 pixman_image_t * src,
469 pixman_image_t * mask,
470 pixman_image_t * dest,
481 _pixman_implementation_blt (pixman_implementation_t *imp,
496 _pixman_implementation_fill (pixman_implementation_t *imp,
506 /* Specific implementations */
507 pixman_implementation_t *
508 _pixman_implementation_create_general (void);
510 pixman_implementation_t *
511 _pixman_implementation_create_fast_path (void);
514 pixman_implementation_t *
515 _pixman_implementation_create_mmx (void);
519 pixman_implementation_t *
520 _pixman_implementation_create_sse2 (void);
524 pixman_implementation_t *
525 _pixman_implementation_create_arm_simd (void);
529 pixman_implementation_t *
530 _pixman_implementation_create_arm_neon (void);
534 pixman_implementation_t *
535 _pixman_implementation_create_vmx (void);
538 pixman_implementation_t *
539 _pixman_choose_implementation (void);
547 /* These "formats" both have depth 0, so they
548 * will never clash with any real ones
550 #define PIXMAN_null PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
551 #define PIXMAN_solid PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
553 #define NEED_COMPONENT_ALPHA (1 << 0)
554 #define NEED_PIXBUF (1 << 1)
555 #define NEED_SOLID_MASK (1 << 2)
560 pixman_format_code_t src_format;
561 pixman_format_code_t mask_format;
562 pixman_format_code_t dest_format;
563 pixman_composite_func_t func;
565 } pixman_fast_path_t;
567 /* Memory allocation helpers */
569 pixman_malloc_ab (unsigned int n, unsigned int b);
572 pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
575 pixman_multiply_overflows_int (unsigned int a, unsigned int b);
578 pixman_addition_overflows_int (unsigned int a, unsigned int b);
580 /* Compositing utilities */
582 _pixman_run_fast_path (const pixman_fast_path_t *paths,
583 pixman_implementation_t * imp,
585 pixman_image_t * src,
586 pixman_image_t * mask,
587 pixman_image_t * dest,
598 _pixman_walk_composite_region (pixman_implementation_t *imp,
600 pixman_image_t * src_image,
601 pixman_image_t * mask_image,
602 pixman_image_t * dst_image,
611 pixman_composite_func_t composite_rect);
614 pixman_expand (uint64_t * dst,
615 const uint32_t * src,
616 pixman_format_code_t format,
620 pixman_contract (uint32_t * dst,
627 pixman_region32_copy_from_region16 (pixman_region32_t *dst,
628 pixman_region16_t *src);
631 pixman_region16_copy_from_region32 (pixman_region16_t *dst,
632 pixman_region32_t *src);
646 # define MIN(a, b) ((a < b) ? a : b)
650 # define MAX(a, b) ((a > b) ? a : b)
653 /* Integer division that rounds towards -infinity */
655 ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \
656 ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
658 /* Modulus that produces the remainder wrt. DIV */
659 #define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
661 #define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v)))
663 /* Conversion between 8888 and 0565 */
665 #define CONVERT_8888_TO_0565(s) \
666 ((((s) >> 3) & 0x001f) | \
667 (((s) >> 5) & 0x07e0) | \
668 (((s) >> 8) & 0xf800))
670 #define CONVERT_0565_TO_0888(s) \
671 (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
672 ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
673 ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
675 #define PIXMAN_FORMAT_IS_WIDE(f) \
676 (PIXMAN_FORMAT_A (f) > 8 || \
677 PIXMAN_FORMAT_R (f) > 8 || \
678 PIXMAN_FORMAT_G (f) > 8 || \
679 PIXMAN_FORMAT_B (f) > 8)
682 * Various debugging code
690 #define return_if_fail(expr) \
695 fprintf (stderr, "In %s: %s failed\n", FUNC, # expr); \
701 #define return_val_if_fail(expr, retval) \
706 fprintf (stderr, "In %s: %s failed\n", FUNC, # expr); \
714 #define return_if_fail(expr) \
722 #define return_val_if_fail(expr, retval) \
738 static inline uint64_t
739 oil_profile_stamp_rdtsc (void)
743 __asm__ __volatile__ ("rdtsc\n" : "=A" (ts));
747 #define OIL_STAMP oil_profile_stamp_rdtsc
749 typedef struct pixman_timer_t pixman_timer_t;
751 struct pixman_timer_t
757 pixman_timer_t *next;
760 extern int timer_defined;
762 void pixman_timer_register (pixman_timer_t *timer);
764 #define TIMER_BEGIN(tname) \
766 static pixman_timer_t timer ## tname; \
767 uint64_t begin ## tname; \
769 if (!timer ## tname.initialized) \
771 timer ## tname.initialized = 1; \
772 timer ## tname.name = # tname; \
773 pixman_timer_register (&timer ## tname); \
776 timer ## tname.n_times++; \
777 begin ## tname = OIL_STAMP ();
779 #define TIMER_END(tname) \
780 timer ## tname.total += OIL_STAMP () - begin ## tname; \
783 #endif /* PIXMAN_TIMERS */
785 #endif /* PIXMAN_PRIVATE_H */