Get rid of indexed argument to store functions
[profile/ivi/pixman.git] / pixman / pixman-private.h
1 #ifndef PACKAGE
2 #  error config.h must be included before pixman-private.h
3 #endif
4
5 #ifndef PIXMAN_PRIVATE_H
6 #define PIXMAN_PRIVATE_H
7
8 #include "pixman.h"
9 #include <time.h>
10 #include <assert.h>
11
12 #include "pixman-compiler.h"
13
14 /*
15  * Various useful macros
16  */
17 #ifndef FALSE
18 #define FALSE 0
19 #endif
20
21 #ifndef TRUE
22 #define TRUE 1
23 #endif
24
25 /* Integer division that rounds towards -infinity */
26 #define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :                \
27                   ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
28
29 /* Modulus that produces the remainder wrt. DIV */
30 #define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
31
32 #define CLIP(a,b,c) ((a) < (b) ? (b) : ((a) > (c) ? (c) : (a)))
33
34 #ifndef MIN
35 #  define MIN(a,b) ((a < b)? a : b)
36 #endif
37
38 #ifndef MAX
39 #  define MAX(a,b) ((a > b)? a : b)
40 #endif
41
42 #undef DEBUG
43 #define DEBUG 0
44
45 /*
46  * Utilities
47  */
48
49 /* Memory allocation helpers */
50 void          *pixman_malloc_ab (unsigned int n, unsigned int b);
51 void          *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
52 pixman_bool_t  pixman_multiply_overflows_int (unsigned int a, unsigned int b);
53 pixman_bool_t  pixman_addition_overflows_int (unsigned int a, unsigned int b);
54
55 #if DEBUG
56
57 #define return_if_fail(expr)                                            \
58     do                                                                  \
59     {                                                                   \
60         if (!(expr))                                                    \
61         {                                                               \
62             fprintf(stderr, "In %s: %s failed\n", FUNC, #expr);         \
63             return;                                                     \
64         }                                                               \
65     }                                                                   \
66     while (0)
67
68 #define return_val_if_fail(expr, retval)                                \
69     do                                                                  \
70     {                                                                   \
71         if (!(expr))                                                    \
72         {                                                               \
73             fprintf(stderr, "In %s: %s failed\n", FUNC, #expr);         \
74             return (retval);                                            \
75         }                                                               \
76     }                                                                   \
77     while (0)
78
79 #else
80
81 #define return_if_fail(expr)                                            \
82     do                                                                  \
83     {                                                                   \
84         if (!(expr))                                                    \
85             return;                                                     \
86     }                                                                   \
87     while (0)
88
89 #define return_val_if_fail(expr, retval)                                \
90     do                                                                  \
91     {                                                                   \
92         if (!(expr))                                                    \
93             return (retval);                                            \
94     }                                                                   \
95     while (0)
96
97 #endif
98
99
100
101 typedef struct image_common image_common_t;
102 typedef struct source_image source_image_t;
103 typedef struct solid_fill solid_fill_t;
104 typedef struct gradient gradient_t;
105 typedef struct linear_gradient linear_gradient_t;
106 typedef struct horizontal_gradient horizontal_gradient_t;
107 typedef struct vertical_gradient vertical_gradient_t;
108 typedef struct conical_gradient conical_gradient_t;
109 typedef struct radial_gradient radial_gradient_t;
110 typedef struct bits_image bits_image_t;
111 typedef struct circle circle_t;
112 typedef struct point point_t;
113
114 /* FIXME - the types and structures below should be give proper names
115  */
116
117 typedef void (*fetchProc32)(bits_image_t *pict, int x, int y, int width,
118                                      uint32_t *buffer);
119 typedef uint32_t (*fetchPixelProc32)(bits_image_t *pict, int offset, int line);
120 typedef void (*storeProc32)(pixman_image_t *, uint32_t *bits,
121                             const uint32_t *values, int x, int width);
122
123 typedef void (*fetchProc64)(bits_image_t *pict, int x, int y, int width,
124                                      uint64_t *buffer);
125 typedef uint64_t (*fetchPixelProc64)(bits_image_t *pict, int offset, int line);
126 typedef void (*storeProc64)(pixman_image_t *, uint32_t *bits,
127                             const uint64_t *values, int x, int width);
128
129 typedef void (* fetch_pixels_32_t) (bits_image_t *image, uint32_t *buffer, int n_pixels);
130 typedef void (* fetch_pixels_64_t) (bits_image_t *image, uint64_t *buffer, int n_pixels);
131
132 void _pixman_bits_image_setup_raw_accessors (bits_image_t *image);
133
134 void pixman_expand(uint64_t *dst, const uint32_t *src, pixman_format_code_t, int width);
135 void pixman_contract(uint32_t *dst, const uint64_t *src, int width);
136
137 void _pixman_image_get_scanline_64_generic (pixman_image_t * pict, int x, int y, int width,
138                                             uint64_t *buffer, uint64_t *mask, uint32_t maskBits);
139
140 /* end */
141
142 typedef enum
143 {
144     BITS,
145     LINEAR,
146     CONICAL,
147     RADIAL,
148     SOLID
149 } image_type_t;
150
151 typedef enum
152 {
153     SOURCE_IMAGE_CLASS_UNKNOWN,
154     SOURCE_IMAGE_CLASS_HORIZONTAL,
155     SOURCE_IMAGE_CLASS_VERTICAL,
156 } source_pict_class_t;
157
158 typedef void (*scanStoreProc)(bits_image_t *img, int x, int y, int width, uint32_t *buffer);
159 typedef void (*scanFetchProc)(pixman_image_t *, int, int, int, uint32_t *,
160                               uint32_t *, uint32_t);
161
162 source_pict_class_t
163 _pixman_image_classify (pixman_image_t *image,
164                         int             x,
165                         int             y,
166                         int             width,
167                         int             height);
168
169 void
170 _pixman_image_get_scanline_32 (pixman_image_t *image, int x, int y, int width,
171                                uint32_t *buffer, uint32_t *mask, uint32_t mask_bits);
172
173 /* Even thought the type of buffer is uint32_t *, the function actually expects
174  * a uint64_t *buffer.
175  */
176 void
177 _pixman_image_get_scanline_64 (pixman_image_t *image, int x, int y, int width,
178                                uint32_t *buffer, uint32_t *unused, uint32_t unused2);
179
180 void
181 _pixman_image_store_scanline_32 (bits_image_t *image, int x, int y, int width,
182                                  uint32_t *buffer);
183 void
184 _pixman_image_fetch_pixels (bits_image_t *image, uint32_t *buffer, int n_pixels);
185
186 /* Even thought the type of buffer is uint32_t *, the function actually expects
187  * a uint64_t *buffer.
188  */
189 void
190 _pixman_image_store_scanline_64 (bits_image_t *image, int x, int y, int width,
191                                  uint32_t *buffer);
192
193 pixman_image_t *
194 _pixman_image_allocate (void);
195
196 pixman_bool_t
197 _pixman_init_gradient (gradient_t     *gradient,
198                        const pixman_gradient_stop_t *stops,
199                        int             n_stops);
200 void
201 _pixman_image_reset_clip_region (pixman_image_t *image);
202
203 struct point
204 {
205     int16_t x, y;
206 };
207
208 typedef source_pict_class_t (* classify_func_t) (pixman_image_t *image,
209                                                  int             x,
210                                                  int             y,
211                                                  int             width,
212                                                  int             height);
213 typedef void (* property_changed_func_t)        (pixman_image_t *image);
214
215 struct image_common
216 {
217     image_type_t                type;
218     int32_t                     ref_count;
219     pixman_region32_t           clip_region;
220     pixman_bool_t               have_clip_region;       /* FALSE if there is no clip */
221     pixman_bool_t               client_clip;    /* Whether the source clip was set by a client */
222     pixman_bool_t               clip_sources;           /* Whether the clip applies when
223                                                          * the image is used as a source
224                                                          */
225     pixman_transform_t         *transform;
226     pixman_repeat_t             repeat;
227     pixman_filter_t             filter;
228     pixman_fixed_t             *filter_params;
229     int                         n_filter_params;
230     bits_image_t               *alpha_map;
231     point_t                     alpha_origin;
232     pixman_bool_t               component_alpha;
233     pixman_read_memory_func_t   read_func;
234     pixman_write_memory_func_t  write_func;
235     classify_func_t             classify;
236     property_changed_func_t     property_changed;
237     scanFetchProc               get_scanline_32;
238     scanFetchProc               get_scanline_64;
239
240     pixman_image_destroy_func_t destroy_func;
241     void *                      destroy_data;
242 };
243
244 struct source_image
245 {
246     image_common_t      common;
247     source_pict_class_t class;
248 };
249
250 struct solid_fill
251 {
252     source_image_t      common;
253     uint32_t            color;          /* FIXME: shouldn't this be a pixman_color_t? */
254 };
255
256 struct gradient
257 {
258     source_image_t              common;
259     int                         n_stops;
260     pixman_gradient_stop_t *    stops;
261     int                         stop_range;
262     uint32_t *                  color_table;
263     int                         color_table_size;
264 };
265
266 struct linear_gradient
267 {
268     gradient_t                  common;
269     pixman_point_fixed_t        p1;
270     pixman_point_fixed_t        p2;
271 };
272
273 struct circle
274 {
275     pixman_fixed_t x;
276     pixman_fixed_t y;
277     pixman_fixed_t radius;
278 };
279
280 struct radial_gradient
281 {
282     gradient_t  common;
283
284     circle_t    c1;
285     circle_t    c2;
286     double      cdx;
287     double      cdy;
288     double      dr;
289     double      A;
290 };
291
292 struct conical_gradient
293 {
294     gradient_t                  common;
295     pixman_point_fixed_t        center;
296     pixman_fixed_t              angle;
297 };
298
299 struct bits_image
300 {
301     image_common_t              common;
302     pixman_format_code_t        format;
303     const pixman_indexed_t     *indexed;
304     int                         width;
305     int                         height;
306     uint32_t *                  bits;
307     uint32_t *                  free_me;
308     int                         rowstride; /* in number of uint32_t's */
309
310     /* Fetch raw pixels, with no regard for transformations, alpha map etc. */
311     fetch_pixels_32_t           fetch_pixels_raw_32;
312     fetch_pixels_64_t           fetch_pixels_raw_64;
313
314     /* Fetch raw scanlines, with no regard for transformations, alpha maps etc. */
315     fetchProc32                 fetch_scanline_raw_32;
316     fetchProc64                 fetch_scanline_raw_64;
317
318     /* Store scanlines with no regard for alpha maps */
319     storeProc32                 store_scanline_raw_32;
320     storeProc64                 store_scanline_raw_64;
321
322     /* Store a scanline, taking alpha maps into account */
323     scanStoreProc               store_scanline_32;
324     scanStoreProc               store_scanline_64;
325
326     /* Used for indirect access to the bits */
327     pixman_read_memory_func_t   read_func;
328     pixman_write_memory_func_t  write_func;
329 };
330
331 union pixman_image
332 {
333     image_type_t                type;
334     image_common_t              common;
335     bits_image_t                bits;
336     source_image_t              source;
337     gradient_t                  gradient;
338     linear_gradient_t           linear;
339     conical_gradient_t          conical;
340     radial_gradient_t           radial;
341     solid_fill_t                solid;
342 };
343
344 /*
345  * Gradient walker
346  */
347 typedef struct
348 {
349     uint32_t        left_ag;
350     uint32_t        left_rb;
351     uint32_t        right_ag;
352     uint32_t        right_rb;
353     int32_t       left_x;
354     int32_t       right_x;
355     int32_t       stepper;
356
357     pixman_gradient_stop_t      *stops;
358     int                      num_stops;
359     unsigned int             spread;
360
361     int           need_reset;
362 } pixman_gradient_walker_t;
363
364 void
365 _pixman_gradient_walker_init (pixman_gradient_walker_t  *walker,
366                               gradient_t      *gradient,
367                               unsigned int     spread);
368
369 void
370 _pixman_gradient_walker_reset (pixman_gradient_walker_t       *walker,
371                                pixman_fixed_32_32_t  pos);
372
373 uint32_t
374 _pixman_gradient_walker_pixel (pixman_gradient_walker_t       *walker,
375                                pixman_fixed_32_32_t  x);
376
377
378
379 #ifdef WORDS_BIGENDIAN
380 #define Fetch24(img, a)  ((unsigned long) (a) & 1 ?           \
381     ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \
382     ((READ(img, (uint16_t *) (a)) << 8) | READ(img, (a)+2)))
383 #define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
384     (WRITE(img, a, (uint8_t) ((v) >> 16)),                \
385      WRITE(img, (uint16_t *) ((a)+1), (uint16_t) (v))) :  \
386     (WRITE(img, (uint16_t *) (a), (uint16_t) ((v) >> 8)), \
387      WRITE(img, (a)+2, (uint8_t) (v))))
388 #else
389 #define Fetch24(img,a)  ((unsigned long) (a) & 1 ?                           \
390     (READ(img, a) | (READ(img, (uint16_t *) ((a)+1)) << 8)) : \
391     (READ(img, (uint16_t *) (a)) | (READ(img, (a)+2) << 16)))
392 #define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
393     (WRITE(img, a, (uint8_t) (v)),                              \
394      WRITE(img, (uint16_t *) ((a)+1), (uint16_t) ((v) >> 8))) : \
395     (WRITE(img, (uint16_t *) (a), (uint16_t) (v)),              \
396      WRITE(img, (a)+2, (uint8_t) ((v) >> 16))))
397 #endif
398
399 #define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
400 #define FbIntDiv(a,b)    (((uint16_t) (a) * 255) / (b))
401
402 #define FbGet8(v,i)   ((uint16_t) (uint8_t) ((v) >> i))
403
404
405 #define cvt8888to0565(s)    ((((s) >> 3) & 0x001f) | \
406                              (((s) >> 5) & 0x07e0) | \
407                              (((s) >> 8) & 0xf800))
408 #define cvt0565to0888(s)    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
409                              ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
410                              ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
411
412 /*
413  * There are two ways of handling alpha -- either as a single unified value or
414  * a separate value for each component, hence each macro must have two
415  * versions.  The unified alpha version has a 'U' at the end of the name,
416  * the component version has a 'C'.  Similarly, functions which deal with
417  * this difference will have two versions using the same convention.
418  */
419
420 #define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i), \
421                             (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
422
423 #define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i), \
424                             (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
425
426 #define FbInU(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
427
428 #define FbInC(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
429
430 #define FbAdd(x,y,i,t)  ((t) = FbGet8(x,i) + FbGet8(y,i),               \
431                          (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
432
433 #define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
434 #define div_65535(x) (((x) + 0x8000 + (((x) + 0x8000) >> 16)) >> 16)
435
436 #ifdef PIXMAN_FB_ACCESSORS
437
438 #define ACCESS(sym) sym##_accessors
439
440 #define READ(img, ptr)                                                  \
441     ((img)->common.read_func ((ptr), sizeof(*(ptr))))
442 #define WRITE(img, ptr,val)                                             \
443     ((img)->common.write_func ((ptr), (val), sizeof (*(ptr))))
444
445 #define MEMCPY_WRAPPED(img, dst, src, size)                             \
446     do {                                                                \
447         size_t _i;                                                      \
448         uint8_t *_dst = (uint8_t*)(dst), *_src = (uint8_t*)(src);       \
449         for(_i = 0; _i < size; _i++) {                                  \
450             WRITE((img), _dst +_i, READ((img), _src + _i));             \
451         }                                                               \
452     } while (0)
453
454 #define MEMSET_WRAPPED(img, dst, val, size)                             \
455     do {                                                                \
456         size_t _i;                                                      \
457         uint8_t *_dst = (uint8_t*)(dst);                                \
458         for(_i = 0; _i < (size_t) size; _i++) {                         \
459             WRITE((img), _dst +_i, (val));                              \
460         }                                                               \
461     } while (0)
462
463 #else
464
465 #define ACCESS(sym) sym
466
467 #define READ(img, ptr)          (*(ptr))
468 #define WRITE(img, ptr, val)    (*(ptr) = (val))
469 #define MEMCPY_WRAPPED(img, dst, src, size)                             \
470     memcpy(dst, src, size)
471 #define MEMSET_WRAPPED(img, dst, val, size)                             \
472     memset(dst, val, size)
473
474 #endif
475
476 #define fbComposeGetStart(pict,x,y,type,out_stride,line,mul) do {       \
477         uint32_t        *__bits__;                                      \
478         int             __stride__;                                     \
479         int             __bpp__;                                        \
480                                                                         \
481         __bits__ = pict->bits.bits;                                     \
482         __stride__ = pict->bits.rowstride;                              \
483         __bpp__ = PIXMAN_FORMAT_BPP(pict->bits.format);                 \
484         (out_stride) = __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type);      \
485         (line) = ((type *) __bits__) +                                  \
486             (out_stride) * (y) + (mul) * (x);                           \
487     } while (0)
488
489
490 #define PIXMAN_FORMAT_16BPC(f)  (PIXMAN_FORMAT_A(f) > 8 || \
491                                  PIXMAN_FORMAT_R(f) > 8 || \
492                                  PIXMAN_FORMAT_G(f) > 8 || \
493                                  PIXMAN_FORMAT_B(f) > 8)
494 /*
495  * Edges
496  */
497
498 #define MAX_ALPHA(n)    ((1 << (n)) - 1)
499 #define N_Y_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n)/2)) - 1)
500 #define N_X_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n)/2)) + 1)
501
502 #define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC(n))
503 #define STEP_Y_BIG(n)   (pixman_fixed_1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
504
505 #define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2)
506 #define Y_FRAC_LAST(n)  (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n))
507
508 #define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC(n))
509 #define STEP_X_BIG(n)   (pixman_fixed_1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
510
511 #define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2)
512 #define X_FRAC_LAST(n)  (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n))
513
514 #define RenderSamplesX(x,n)     ((n) == 1 ? 0 : (pixman_fixed_frac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n))
515
516 /*
517  * Step across a small sample grid gap
518  */
519 void
520 pixman_rasterize_edges_accessors (pixman_image_t *image,
521                                   pixman_edge_t *l,
522                                   pixman_edge_t *r,
523                                   pixman_fixed_t        t,
524                                   pixman_fixed_t        b);
525
526 pixman_bool_t
527 pixman_image_is_opaque(pixman_image_t *image);
528
529 pixman_bool_t
530 pixman_image_is_solid (pixman_image_t *image);
531
532 uint32_t
533 pixman_image_get_solid (pixman_image_t *image,
534                         pixman_format_code_t format);
535
536 pixman_bool_t
537 pixman_compute_composite_region32 (pixman_region32_t *  pRegion,
538                                    pixman_image_t *     pSrc,
539                                    pixman_image_t *     pMask,
540                                    pixman_image_t *     pDst,
541                                    int16_t              xSrc,
542                                    int16_t              ySrc,
543                                    int16_t              xMask,
544                                    int16_t              yMask,
545                                    int16_t              xDst,
546                                    int16_t              yDst,
547                                    uint16_t             width,
548                                    uint16_t             height);
549
550 /* Region Helpers */
551 pixman_bool_t pixman_region32_copy_from_region16 (pixman_region32_t *dst,
552                                                   pixman_region16_t *src);
553 pixman_bool_t pixman_region16_copy_from_region32 (pixman_region16_t *dst,
554                                                   pixman_region32_t *src);
555
556 #ifdef PIXMAN_TIMERS
557
558 /* Timing */
559 static inline uint64_t
560 oil_profile_stamp_rdtsc (void)
561 {
562     uint64_t ts;
563     __asm__ __volatile__("rdtsc\n" : "=A" (ts));
564     return ts;
565 }
566 #define OIL_STAMP oil_profile_stamp_rdtsc
567
568 typedef struct pixman_timer_t pixman_timer_t;
569
570 struct pixman_timer_t
571 {
572     int initialized;
573     const char *name;
574     uint64_t n_times;
575     uint64_t total;
576     pixman_timer_t *next;
577 };
578
579 extern int timer_defined;
580 void pixman_timer_register (pixman_timer_t *timer);
581
582 #define TIMER_BEGIN(tname)                                              \
583     {                                                                   \
584         static pixman_timer_t   timer##tname;                           \
585         uint64_t                begin##tname;                           \
586                                                                         \
587         if (!timer##tname.initialized)                                  \
588         {                                                               \
589             timer##tname.initialized = 1;                               \
590             timer##tname.name = #tname;                                 \
591             pixman_timer_register (&timer##tname);                      \
592         }                                                               \
593                                                                         \
594         timer##tname.n_times++;                                         \
595         begin##tname = OIL_STAMP();
596
597 #define TIMER_END(tname)                                                \
598         timer##tname.total += OIL_STAMP() - begin##tname;               \
599     }
600
601 #endif /* PIXMAN_TIMERS */
602
603 typedef struct pixman_implementation_t pixman_implementation_t;
604
605 typedef void (* pixman_combine_32_func_t) (pixman_implementation_t *    imp,
606                                            pixman_op_t                  op,
607                                            uint32_t *                   dest,
608                                            const uint32_t *             src,
609                                            const uint32_t *             mask,
610                                            int                          width);
611
612 typedef void (* pixman_combine_64_func_t) (pixman_implementation_t *    imp,
613                                            pixman_op_t                  op,
614                                            uint64_t *                   dest,
615                                            const uint64_t *             src,
616                                            const uint64_t *             mask,
617                                            int                          width);
618
619 typedef void (* pixman_composite_func_t)  (pixman_implementation_t *    imp,
620                                            pixman_op_t                  op,
621                                            pixman_image_t *             src,
622                                            pixman_image_t *             mask,
623                                            pixman_image_t *             dest,
624                                            int32_t                      src_x,
625                                            int32_t                      src_y,
626                                            int32_t                      mask_x,
627                                            int32_t                      mask_y,
628                                            int32_t                      dest_x,
629                                            int32_t                      dest_y,
630                                            int32_t                      width,
631                                            int32_t                      height);
632 typedef pixman_bool_t (* pixman_blt_func_t) (pixman_implementation_t *  imp,
633                                              uint32_t *                 src_bits,
634                                              uint32_t *                 dst_bits,
635                                              int                        src_stride,
636                                              int                        dst_stride,
637                                              int                        src_bpp,
638                                              int                        dst_bpp,
639                                              int                        src_x,
640                                              int                        src_y,
641                                              int                        dst_x,
642                                              int                        dst_y,
643                                              int                        width,
644                                              int                        height);
645 typedef pixman_bool_t (* pixman_fill_func_t) (pixman_implementation_t *imp,
646                                               uint32_t *bits,
647                                               int stride,
648                                               int bpp,
649                                               int x,
650                                               int y,
651                                               int width,
652                                               int height,
653                                               uint32_t xor);
654
655 void
656 _pixman_walk_composite_region (pixman_implementation_t *imp,
657                                pixman_op_t op,
658                                pixman_image_t * pSrc,
659                                pixman_image_t * pMask,
660                                pixman_image_t * pDst,
661                                int16_t xSrc,
662                                int16_t ySrc,
663                                int16_t xMask,
664                                int16_t yMask,
665                                int16_t xDst,
666                                int16_t yDst,
667                                uint16_t width,
668                                uint16_t height,
669                                pixman_composite_func_t compositeRect);
670
671 void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
672 void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
673
674 /* These "formats" both have depth 0, so they
675  * will never clash with any real ones
676  */
677 #define PIXMAN_null             PIXMAN_FORMAT(0,0,0,0,0,0)
678 #define PIXMAN_solid            PIXMAN_FORMAT(0,1,0,0,0,0)
679
680 #define NEED_COMPONENT_ALPHA            (1 << 0)
681 #define NEED_PIXBUF                     (1 << 1)
682 #define NEED_SOLID_MASK                 (1 << 2)
683
684 typedef struct
685 {
686     pixman_op_t                 op;
687     pixman_format_code_t        src_format;
688     pixman_format_code_t        mask_format;
689     pixman_format_code_t        dest_format;
690     pixman_composite_func_t     func;
691     uint32_t                    flags;
692 } pixman_fast_path_t;
693
694 struct pixman_implementation_t
695 {
696     pixman_implementation_t *   toplevel;
697     pixman_implementation_t *   delegate;
698
699     pixman_composite_func_t     composite;
700     pixman_blt_func_t           blt;
701     pixman_fill_func_t          fill;
702     
703     pixman_combine_32_func_t    combine_32[PIXMAN_OP_LAST];
704     pixman_combine_32_func_t    combine_32_ca[PIXMAN_OP_LAST];
705     pixman_combine_64_func_t    combine_64[PIXMAN_OP_LAST];
706     pixman_combine_64_func_t    combine_64_ca[PIXMAN_OP_LAST];
707 };
708
709 pixman_implementation_t *
710 _pixman_implementation_create (pixman_implementation_t *delegate);
711
712 void
713 _pixman_implementation_combine_32 (pixman_implementation_t *    imp,
714                                    pixman_op_t                  op,
715                                    uint32_t *                   dest,
716                                    const uint32_t *             src,
717                                    const uint32_t *             mask,
718                                    int                          width);
719 void
720 _pixman_implementation_combine_64 (pixman_implementation_t *    imp,
721                                    pixman_op_t                  op,
722                                    uint64_t *                   dest,
723                                    const uint64_t *             src,
724                                    const uint64_t *             mask,
725                                    int                          width);
726 void
727 _pixman_implementation_combine_32_ca (pixman_implementation_t * imp,
728                                       pixman_op_t               op,
729                                       uint32_t *                dest,
730                                       const uint32_t *          src,
731                                       const uint32_t *          mask,
732                                       int                       width);
733 void
734 _pixman_implementation_combine_64_ca (pixman_implementation_t * imp,
735                                       pixman_op_t               op,
736                                       uint64_t *                dest,
737                                       const uint64_t *          src,
738                                       const uint64_t *          mask,
739                                       int                       width);
740 void
741 _pixman_implementation_composite (pixman_implementation_t *     imp,
742                                   pixman_op_t                   op,
743                                   pixman_image_t *              src,
744                                   pixman_image_t *              mask,
745                                   pixman_image_t *              dest,
746                                   int32_t                       src_x,
747                                   int32_t                       src_y,
748                                   int32_t                       mask_x,
749                                   int32_t                       mask_y,
750                                   int32_t                       dest_x,
751                                   int32_t                       dest_y,
752                                   int32_t                       width,
753                                   int32_t                       height);
754
755 pixman_bool_t
756 _pixman_implementation_blt (pixman_implementation_t *   imp,
757                             uint32_t *                  src_bits,
758                             uint32_t *                  dst_bits,
759                             int                         src_stride,
760                             int                         dst_stride,
761                             int                         src_bpp,
762                             int                         dst_bpp,
763                             int                         src_x,
764                             int                         src_y,
765                             int                         dst_x,
766                             int                         dst_y,
767                             int                         width,
768                             int                         height);
769 pixman_bool_t
770 _pixman_implementation_fill (pixman_implementation_t *   imp,
771                              uint32_t *bits,
772                              int stride,
773                              int bpp,
774                              int x,
775                              int y,
776                              int width,
777                              int height,
778                              uint32_t xor);
779     
780 /* Specific implementations */
781 pixman_implementation_t *
782 _pixman_implementation_create_general (void);
783 pixman_implementation_t *
784 _pixman_implementation_create_fast_path (void);
785 #ifdef USE_MMX
786 pixman_implementation_t *
787 _pixman_implementation_create_mmx (void);
788 #endif
789 #ifdef USE_SSE2
790 pixman_implementation_t *
791 _pixman_implementation_create_sse2 (void);
792 #endif
793 #ifdef USE_ARM_SIMD
794 pixman_implementation_t *
795 _pixman_implementation_create_arm_simd (void);
796 #endif
797 #ifdef USE_ARM_NEON
798 pixman_implementation_t *
799 _pixman_implementation_create_arm_neon (void);
800 #endif
801 #ifdef USE_VMX
802 pixman_implementation_t *
803 _pixman_implementation_create_vmx (void);
804 #endif
805
806 pixman_bool_t
807 _pixman_run_fast_path (const pixman_fast_path_t *paths,
808                        pixman_implementation_t *imp,
809                        pixman_op_t op,
810                        pixman_image_t *src,
811                        pixman_image_t *mask,
812                        pixman_image_t *dest,
813                        int32_t src_x,
814                        int32_t src_y,
815                        int32_t mask_x,
816                        int32_t mask_y,
817                        int32_t dest_x,
818                        int32_t dest_y,
819                        int32_t width,
820                        int32_t height);
821     
822 pixman_implementation_t *
823 _pixman_choose_implementation (void);
824
825 #endif /* PIXMAN_PRIVATE_H */