Rename source_pict_class_t to source_image_class_t
[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  * Images
16  */
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;
28
29 typedef void (*fetch_scanline_t) (pixman_image_t *image,
30                                   int             x,
31                                   int             y,
32                                   int             width,
33                                   uint32_t       *buffer,
34                                   const uint32_t *mask,
35                                   uint32_t        mask_bits);
36
37 typedef void (*fetch_pixels_t)   (bits_image_t *  image,
38                                   uint32_t *      buffer,
39                                   int             n_pixels);
40
41 typedef void (*store_scanline_t) (bits_image_t *  image,
42                                   int             x,
43                                   int             y,
44                                   int             width,
45                                   const uint32_t *values);
46
47 typedef enum
48 {
49     BITS,
50     LINEAR,
51     CONICAL,
52     RADIAL,
53     SOLID
54 } image_type_t;
55
56 typedef enum
57 {
58     SOURCE_IMAGE_CLASS_UNKNOWN,
59     SOURCE_IMAGE_CLASS_HORIZONTAL,
60     SOURCE_IMAGE_CLASS_VERTICAL,
61 } source_image_class_t;
62
63 typedef source_image_class_t (*classify_func_t) (pixman_image_t *image,
64                                                 int             x,
65                                                 int             y,
66                                                 int             width,
67                                                 int             height);
68 typedef void (*property_changed_func_t) (pixman_image_t *image);
69
70 struct image_common
71 {
72     image_type_t                type;
73     int32_t                     ref_count;
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
77                                                        set by a client */
78     pixman_bool_t               clip_sources;       /* Whether the clip applies when
79                                                      * the image is used as a source
80                                                      */
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;
86     int                         n_filter_params;
87     bits_image_t *              alpha_map;
88     int                         alpha_origin_x;
89     int                         alpha_origin_y;
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;
95
96     pixman_image_destroy_func_t destroy_func;
97     void *                      destroy_data;
98 };
99
100 struct source_image
101 {
102     image_common_t common;
103     source_image_class_t class;
104 };
105
106 struct solid_fill
107 {
108     source_image_t common;
109     uint32_t       color;    /* FIXME: shouldn't this be a pixman_color_t? */
110 };
111
112 struct gradient
113 {
114     source_image_t          common;
115     int                     n_stops;
116     pixman_gradient_stop_t *stops;
117     int                     stop_range;
118     uint32_t *              color_table;
119     int                     color_table_size;
120 };
121
122 struct linear_gradient
123 {
124     gradient_t           common;
125     pixman_point_fixed_t p1;
126     pixman_point_fixed_t p2;
127 };
128
129 struct circle
130 {
131     pixman_fixed_t x;
132     pixman_fixed_t y;
133     pixman_fixed_t radius;
134 };
135
136 struct radial_gradient
137 {
138     gradient_t common;
139
140     circle_t   c1;
141     circle_t   c2;
142     double     cdx;
143     double     cdy;
144     double     dr;
145     double     A;
146 };
147
148 struct conical_gradient
149 {
150     gradient_t           common;
151     pixman_point_fixed_t center;
152     pixman_fixed_t       angle;
153 };
154
155 struct bits_image
156 {
157     image_common_t             common;
158     pixman_format_code_t       format;
159     const pixman_indexed_t *   indexed;
160     int                        width;
161     int                        height;
162     uint32_t *                 bits;
163     uint32_t *                 free_me;
164     int                        rowstride;  /* in number of uint32_t's */
165
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;
169
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;
173
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;
177
178     /* Store a scanline, taking alpha maps into account */
179     store_scanline_t           store_scanline_32;
180     store_scanline_t           store_scanline_64;
181
182     /* Used for indirect access to the bits */
183     pixman_read_memory_func_t  read_func;
184     pixman_write_memory_func_t write_func;
185 };
186
187 union pixman_image
188 {
189     image_type_t       type;
190     image_common_t     common;
191     bits_image_t       bits;
192     source_image_t     source;
193     gradient_t         gradient;
194     linear_gradient_t  linear;
195     conical_gradient_t conical;
196     radial_gradient_t  radial;
197     solid_fill_t       solid;
198 };
199
200
201 void
202 _pixman_bits_image_setup_raw_accessors (bits_image_t *image);
203
204 void
205 _pixman_image_get_scanline_generic_64  (pixman_image_t *image,
206                                         int             x,
207                                         int             y,
208                                         int             width,
209                                         uint32_t *      buffer,
210                                         const uint32_t *mask,
211                                         uint32_t        mask_bits);
212
213 source_image_class_t
214 _pixman_image_classify (pixman_image_t *image,
215                         int             x,
216                         int             y,
217                         int             width,
218                         int             height);
219
220 void
221 _pixman_image_get_scanline_32 (pixman_image_t *image,
222                                int             x,
223                                int             y,
224                                int             width,
225                                uint32_t *      buffer,
226                                const uint32_t *mask,
227                                uint32_t        mask_bits);
228
229 /* Even thought the type of buffer is uint32_t *, the function actually expects
230  * a uint64_t *buffer.
231  */
232 void
233 _pixman_image_get_scanline_64 (pixman_image_t *image,
234                                int             x,
235                                int             y,
236                                int             width,
237                                uint32_t *      buffer,
238                                const uint32_t *unused,
239                                uint32_t        unused2);
240
241 void
242 _pixman_image_store_scanline_32 (bits_image_t *  image,
243                                  int             x,
244                                  int             y,
245                                  int             width,
246                                  const uint32_t *buffer);
247 void
248 _pixman_image_fetch_pixels (bits_image_t *image,
249                             uint32_t *    buffer,
250                             int           n_pixels);
251
252 /* Even though the type of buffer is uint32_t *, the function
253  * actually expects a uint64_t *buffer.
254  */
255 void
256 _pixman_image_store_scanline_64 (bits_image_t *  image,
257                                  int             x,
258                                  int             y,
259                                  int             width,
260                                  const uint32_t *buffer);
261
262 pixman_image_t *
263 _pixman_image_allocate (void);
264
265 pixman_bool_t
266 _pixman_init_gradient (gradient_t *                  gradient,
267                        const pixman_gradient_stop_t *stops,
268                        int                           n_stops);
269 void
270 _pixman_image_reset_clip_region (pixman_image_t *image);
271
272 pixman_bool_t
273 _pixman_image_is_opaque (pixman_image_t *image);
274
275 pixman_bool_t
276 _pixman_image_is_solid (pixman_image_t *image);
277
278 uint32_t
279 _pixman_image_get_solid (pixman_image_t *     image,
280                          pixman_format_code_t format);
281
282 #define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul) \
283     do                                                                  \
284     {                                                                   \
285         uint32_t *__bits__;                                             \
286         int       __stride__;                                           \
287                                                                         \
288         __bits__ = image->bits.bits;                                    \
289         __stride__ = image->bits.rowstride;                             \
290         (out_stride) =                                                  \
291             __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type); \
292         (line) =                                                        \
293             ((type *) __bits__) + (out_stride) * (y) + (mul) * (x);     \
294     } while (0)
295
296 /*
297  * Gradient walker
298  */
299 typedef struct
300 {
301     uint32_t                left_ag;
302     uint32_t                left_rb;
303     uint32_t                right_ag;
304     uint32_t                right_rb;
305     int32_t                 left_x;
306     int32_t                 right_x;
307     int32_t                 stepper;
308
309     pixman_gradient_stop_t *stops;
310     int                     num_stops;
311     unsigned int            spread;
312
313     int                     need_reset;
314 } pixman_gradient_walker_t;
315
316 void
317 _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
318                               gradient_t *              gradient,
319                               unsigned int              spread);
320
321 void
322 _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
323                                pixman_fixed_32_32_t      pos);
324
325 uint32_t
326 _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
327                                pixman_fixed_32_32_t      x);
328
329 /*
330  * Edges
331  */
332
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)
336
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))
339
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))
342
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))
345
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))
348
349 #define RENDER_SAMPLES_X(x, n)                                          \
350     ((n) == 1? 0 : (pixman_fixed_frac (x) +                             \
351                     X_FRAC_FIRST (n)) / STEP_X_SMALL (n))
352
353 void
354 pixman_rasterize_edges_accessors (pixman_image_t *image,
355                                   pixman_edge_t * l,
356                                   pixman_edge_t * r,
357                                   pixman_fixed_t  t,
358                                   pixman_fixed_t  b);
359
360 /*
361  * Implementations
362  */
363
364 typedef struct pixman_implementation_t pixman_implementation_t;
365
366 typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp,
367                                           pixman_op_t              op,
368                                           uint32_t *               dest,
369                                           const uint32_t *         src,
370                                           const uint32_t *         mask,
371                                           int                      width);
372
373 typedef void (*pixman_combine_64_func_t) (pixman_implementation_t *imp,
374                                           pixman_op_t              op,
375                                           uint64_t *               dest,
376                                           const uint64_t *         src,
377                                           const uint64_t *         mask,
378                                           int                      width);
379
380 typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp,
381                                          pixman_op_t              op,
382                                          pixman_image_t *         src,
383                                          pixman_image_t *         mask,
384                                          pixman_image_t *         dest,
385                                          int32_t                  src_x,
386                                          int32_t                  src_y,
387                                          int32_t                  mask_x,
388                                          int32_t                  mask_y,
389                                          int32_t                  dest_x,
390                                          int32_t                  dest_y,
391                                          int32_t                  width,
392                                          int32_t                  height);
393 typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp,
394                                             uint32_t *               src_bits,
395                                             uint32_t *               dst_bits,
396                                             int                      src_stride,
397                                             int                      dst_stride,
398                                             int                      src_bpp,
399                                             int                      dst_bpp,
400                                             int                      src_x,
401                                             int                      src_y,
402                                             int                      dst_x,
403                                             int                      dst_y,
404                                             int                      width,
405                                             int                      height);
406 typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
407                                              uint32_t *               bits,
408                                              int                      stride,
409                                              int                      bpp,
410                                              int                      x,
411                                              int                      y,
412                                              int                      width,
413                                              int                      height,
414                                              uint32_t                 xor);
415
416 void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
417 void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
418
419 struct pixman_implementation_t
420 {
421     pixman_implementation_t *toplevel;
422     pixman_implementation_t *delegate;
423
424     pixman_composite_func_t  composite;
425     pixman_blt_func_t        blt;
426     pixman_fill_func_t       fill;
427
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];
432 };
433
434 pixman_implementation_t *
435 _pixman_implementation_create (pixman_implementation_t *delegate);
436
437 void
438 _pixman_implementation_combine_32 (pixman_implementation_t *imp,
439                                    pixman_op_t              op,
440                                    uint32_t *               dest,
441                                    const uint32_t *         src,
442                                    const uint32_t *         mask,
443                                    int                      width);
444 void
445 _pixman_implementation_combine_64 (pixman_implementation_t *imp,
446                                    pixman_op_t              op,
447                                    uint64_t *               dest,
448                                    const uint64_t *         src,
449                                    const uint64_t *         mask,
450                                    int                      width);
451 void
452 _pixman_implementation_combine_32_ca (pixman_implementation_t *imp,
453                                       pixman_op_t              op,
454                                       uint32_t *               dest,
455                                       const uint32_t *         src,
456                                       const uint32_t *         mask,
457                                       int                      width);
458 void
459 _pixman_implementation_combine_64_ca (pixman_implementation_t *imp,
460                                       pixman_op_t              op,
461                                       uint64_t *               dest,
462                                       const uint64_t *         src,
463                                       const uint64_t *         mask,
464                                       int                      width);
465 void
466 _pixman_implementation_composite (pixman_implementation_t *imp,
467                                   pixman_op_t              op,
468                                   pixman_image_t *         src,
469                                   pixman_image_t *         mask,
470                                   pixman_image_t *         dest,
471                                   int32_t                  src_x,
472                                   int32_t                  src_y,
473                                   int32_t                  mask_x,
474                                   int32_t                  mask_y,
475                                   int32_t                  dest_x,
476                                   int32_t                  dest_y,
477                                   int32_t                  width,
478                                   int32_t                  height);
479
480 pixman_bool_t
481 _pixman_implementation_blt (pixman_implementation_t *imp,
482                             uint32_t *               src_bits,
483                             uint32_t *               dst_bits,
484                             int                      src_stride,
485                             int                      dst_stride,
486                             int                      src_bpp,
487                             int                      dst_bpp,
488                             int                      src_x,
489                             int                      src_y,
490                             int                      dst_x,
491                             int                      dst_y,
492                             int                      width,
493                             int                      height);
494
495 pixman_bool_t
496 _pixman_implementation_fill (pixman_implementation_t *imp,
497                              uint32_t *               bits,
498                              int                      stride,
499                              int                      bpp,
500                              int                      x,
501                              int                      y,
502                              int                      width,
503                              int                      height,
504                              uint32_t                 xor);
505
506 /* Specific implementations */
507 pixman_implementation_t *
508 _pixman_implementation_create_general (void);
509
510 pixman_implementation_t *
511 _pixman_implementation_create_fast_path (void);
512
513 #ifdef USE_MMX
514 pixman_implementation_t *
515 _pixman_implementation_create_mmx (void);
516 #endif
517
518 #ifdef USE_SSE2
519 pixman_implementation_t *
520 _pixman_implementation_create_sse2 (void);
521 #endif
522
523 #ifdef USE_ARM_SIMD
524 pixman_implementation_t *
525 _pixman_implementation_create_arm_simd (void);
526 #endif
527
528 #ifdef USE_ARM_NEON
529 pixman_implementation_t *
530 _pixman_implementation_create_arm_neon (void);
531 #endif
532
533 #ifdef USE_VMX
534 pixman_implementation_t *
535 _pixman_implementation_create_vmx (void);
536 #endif
537
538 pixman_implementation_t *
539 _pixman_choose_implementation (void);
540
541
542
543 /*
544  * Utilities
545  */
546
547 /* These "formats" both have depth 0, so they
548  * will never clash with any real ones
549  */
550 #define PIXMAN_null             PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
551 #define PIXMAN_solid            PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
552
553 #define NEED_COMPONENT_ALPHA            (1 << 0)
554 #define NEED_PIXBUF                     (1 << 1)
555 #define NEED_SOLID_MASK                 (1 << 2)
556
557 typedef struct
558 {
559     pixman_op_t             op;
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;
564     uint32_t                flags;
565 } pixman_fast_path_t;
566
567 /* Memory allocation helpers */
568 void *
569 pixman_malloc_ab (unsigned int n, unsigned int b);
570
571 void *
572 pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
573
574 pixman_bool_t
575 pixman_multiply_overflows_int (unsigned int a, unsigned int b);
576
577 pixman_bool_t
578 pixman_addition_overflows_int (unsigned int a, unsigned int b);
579
580 /* Compositing utilities */
581 pixman_bool_t
582 _pixman_run_fast_path (const pixman_fast_path_t *paths,
583                        pixman_implementation_t * imp,
584                        pixman_op_t               op,
585                        pixman_image_t *          src,
586                        pixman_image_t *          mask,
587                        pixman_image_t *          dest,
588                        int32_t                   src_x,
589                        int32_t                   src_y,
590                        int32_t                   mask_x,
591                        int32_t                   mask_y,
592                        int32_t                   dest_x,
593                        int32_t                   dest_y,
594                        int32_t                   width,
595                        int32_t                   height);
596
597 void
598 _pixman_walk_composite_region (pixman_implementation_t *imp,
599                                pixman_op_t              op,
600                                pixman_image_t *         src_image,
601                                pixman_image_t *         mask_image,
602                                pixman_image_t *         dst_image,
603                                int16_t                  src_x,
604                                int16_t                  src_y,
605                                int16_t                  mask_x,
606                                int16_t                  mask_y,
607                                int16_t                  dest_x,
608                                int16_t                  dest_y,
609                                uint16_t                 width,
610                                uint16_t                 height,
611                                pixman_composite_func_t  composite_rect);
612
613 void
614 pixman_expand (uint64_t *           dst,
615                const uint32_t *     src,
616                pixman_format_code_t format,
617                int                  width);
618
619 void
620 pixman_contract (uint32_t *      dst,
621                  const uint64_t *src,
622                  int             width);
623
624
625 /* Region Helpers */
626 pixman_bool_t
627 pixman_region32_copy_from_region16 (pixman_region32_t *dst,
628                                     pixman_region16_t *src);
629
630 pixman_bool_t
631 pixman_region16_copy_from_region32 (pixman_region16_t *dst,
632                                     pixman_region32_t *src);
633
634
635 /* Misc macros */
636
637 #ifndef FALSE
638 #   define FALSE 0
639 #endif
640
641 #ifndef TRUE
642 #   define TRUE 1
643 #endif
644
645 #ifndef MIN
646 #  define MIN(a, b) ((a < b) ? a : b)
647 #endif
648
649 #ifndef MAX
650 #  define MAX(a, b) ((a > b) ? a : b)
651 #endif
652
653 /* Integer division that rounds towards -infinity */
654 #define DIV(a, b)                                          \
655     ((((a) < 0) == ((b) < 0)) ? (a) / (b) :                \
656      ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
657
658 /* Modulus that produces the remainder wrt. DIV */
659 #define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
660
661 #define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v)))
662
663 /* Conversion between 8888 and 0565 */
664
665 #define CONVERT_8888_TO_0565(s)                                         \
666     ((((s) >> 3) & 0x001f) |                                            \
667      (((s) >> 5) & 0x07e0) |                                            \
668      (((s) >> 8) & 0xf800))
669
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)))
674
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)
680
681 /*
682  * Various debugging code
683  */
684
685 #undef DEBUG
686 #define DEBUG 0
687
688 #if DEBUG
689
690 #define return_if_fail(expr)                                            \
691     do                                                                  \
692     {                                                                   \
693         if (!(expr))                                                    \
694         {                                                               \
695             fprintf (stderr, "In %s: %s failed\n", FUNC, # expr);       \
696             return;                                                     \
697         }                                                               \
698     }                                                                   \
699     while (0)
700
701 #define return_val_if_fail(expr, retval)                                \
702     do                                                                  \
703     {                                                                   \
704         if (!(expr))                                                    \
705         {                                                               \
706             fprintf (stderr, "In %s: %s failed\n", FUNC, # expr);       \
707             return (retval);                                            \
708         }                                                               \
709     }                                                                   \
710     while (0)
711
712 #else
713
714 #define return_if_fail(expr)                                            \
715     do                                                                  \
716     {                                                                   \
717         if (!(expr))                                                    \
718             return;                                                     \
719     }                                                                   \
720     while (0)
721
722 #define return_val_if_fail(expr, retval)                                \
723     do                                                                  \
724     {                                                                   \
725         if (!(expr))                                                    \
726             return (retval);                                            \
727     }                                                                   \
728     while (0)
729
730 #endif
731
732 /*
733  * Timers
734  */
735
736 #ifdef PIXMAN_TIMERS
737
738 static inline uint64_t
739 oil_profile_stamp_rdtsc (void)
740 {
741     uint64_t ts;
742
743     __asm__ __volatile__ ("rdtsc\n" : "=A" (ts));
744     return ts;
745 }
746
747 #define OIL_STAMP oil_profile_stamp_rdtsc
748
749 typedef struct pixman_timer_t pixman_timer_t;
750
751 struct pixman_timer_t
752 {
753     int             initialized;
754     const char *    name;
755     uint64_t        n_times;
756     uint64_t        total;
757     pixman_timer_t *next;
758 };
759
760 extern int timer_defined;
761
762 void pixman_timer_register (pixman_timer_t *timer);
763
764 #define TIMER_BEGIN(tname)                                              \
765     {                                                                   \
766         static pixman_timer_t timer ## tname;                           \
767         uint64_t              begin ## tname;                           \
768                                                                         \
769         if (!timer ## tname.initialized)                                \
770         {                                                               \
771             timer ## tname.initialized = 1;                             \
772             timer ## tname.name = # tname;                              \
773             pixman_timer_register (&timer ## tname);                    \
774         }                                                               \
775                                                                         \
776         timer ## tname.n_times++;                                       \
777         begin ## tname = OIL_STAMP ();
778
779 #define TIMER_END(tname)                                                \
780     timer ## tname.total += OIL_STAMP () - begin ## tname;              \
781     }
782
783 #endif /* PIXMAN_TIMERS */
784
785 #endif /* PIXMAN_PRIVATE_H */