gfx/cairo/libpixman/src/pixman-private.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/libpixman/src/pixman-private.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1187 @@
     1.4 +#ifndef PIXMAN_PRIVATE_H
     1.5 +#define PIXMAN_PRIVATE_H
     1.6 +
     1.7 +/*
     1.8 + * The defines which are shared between C and assembly code
     1.9 + */
    1.10 +
    1.11 +/* bilinear interpolation precision (must be <= 8) */
    1.12 +#ifndef MOZILLA_VERSION
    1.13 +#error "Need mozilla headers"
    1.14 +#endif
    1.15 +#ifdef MOZ_GFX_OPTIMIZE_MOBILE
    1.16 +#define LOW_QUALITY_INTERPOLATION
    1.17 +#define LOWER_QUALITY_INTERPOLATION
    1.18 +#define BILINEAR_INTERPOLATION_BITS 4
    1.19 +#else
    1.20 +#define BILINEAR_INTERPOLATION_BITS 7
    1.21 +#endif
    1.22 +#define BILINEAR_INTERPOLATION_RANGE (1 << BILINEAR_INTERPOLATION_BITS)
    1.23 +
    1.24 +/*
    1.25 + * C specific part
    1.26 + */
    1.27 +
    1.28 +#ifndef __ASSEMBLER__
    1.29 +
    1.30 +#ifndef PACKAGE
    1.31 +#  error config.h must be included before pixman-private.h
    1.32 +#endif
    1.33 +
    1.34 +#define PIXMAN_DISABLE_DEPRECATED
    1.35 +#define PIXMAN_USE_INTERNAL_API
    1.36 +
    1.37 +#include "pixman.h"
    1.38 +#include <time.h>
    1.39 +#include <assert.h>
    1.40 +#include <stdio.h>
    1.41 +#include <string.h>
    1.42 +#include <stddef.h>
    1.43 +
    1.44 +#include "pixman-compiler.h"
    1.45 +
    1.46 +/*
    1.47 + * Images
    1.48 + */
    1.49 +typedef struct image_common image_common_t;
    1.50 +typedef struct solid_fill solid_fill_t;
    1.51 +typedef struct gradient gradient_t;
    1.52 +typedef struct linear_gradient linear_gradient_t;
    1.53 +typedef struct horizontal_gradient horizontal_gradient_t;
    1.54 +typedef struct vertical_gradient vertical_gradient_t;
    1.55 +typedef struct conical_gradient conical_gradient_t;
    1.56 +typedef struct radial_gradient radial_gradient_t;
    1.57 +typedef struct bits_image bits_image_t;
    1.58 +typedef struct circle circle_t;
    1.59 +
    1.60 +typedef struct argb_t argb_t;
    1.61 +
    1.62 +struct argb_t
    1.63 +{
    1.64 +    float a;
    1.65 +    float r;
    1.66 +    float g;
    1.67 +    float b;
    1.68 +};
    1.69 +
    1.70 +typedef void (*fetch_scanline_t) (pixman_image_t *image,
    1.71 +				  int             x,
    1.72 +				  int             y,
    1.73 +				  int             width,
    1.74 +				  uint32_t       *buffer,
    1.75 +				  const uint32_t *mask);
    1.76 +
    1.77 +typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image,
    1.78 +				      int           x,
    1.79 +				      int           y);
    1.80 +
    1.81 +typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image,
    1.82 +				       int           x,
    1.83 +				       int           y);
    1.84 +
    1.85 +typedef void (*store_scanline_t) (bits_image_t *  image,
    1.86 +				  int             x,
    1.87 +				  int             y,
    1.88 +				  int             width,
    1.89 +				  const uint32_t *values);
    1.90 +
    1.91 +typedef enum
    1.92 +{
    1.93 +    BITS,
    1.94 +    LINEAR,
    1.95 +    CONICAL,
    1.96 +    RADIAL,
    1.97 +    SOLID
    1.98 +} image_type_t;
    1.99 +
   1.100 +typedef void (*property_changed_func_t) (pixman_image_t *image);
   1.101 +
   1.102 +struct image_common
   1.103 +{
   1.104 +    image_type_t                type;
   1.105 +    int32_t                     ref_count;
   1.106 +    pixman_region32_t           clip_region;
   1.107 +    int32_t			alpha_count;	    /* How many times this image is being used as an alpha map */
   1.108 +    pixman_bool_t               have_clip_region;   /* FALSE if there is no clip */
   1.109 +    pixman_bool_t               client_clip;        /* Whether the source clip was
   1.110 +						       set by a client */
   1.111 +    pixman_bool_t               clip_sources;       /* Whether the clip applies when
   1.112 +						     * the image is used as a source
   1.113 +						     */
   1.114 +    pixman_bool_t		dirty;
   1.115 +    pixman_transform_t *        transform;
   1.116 +    pixman_repeat_t             repeat;
   1.117 +    pixman_filter_t             filter;
   1.118 +    pixman_fixed_t *            filter_params;
   1.119 +    int                         n_filter_params;
   1.120 +    bits_image_t *              alpha_map;
   1.121 +    int                         alpha_origin_x;
   1.122 +    int                         alpha_origin_y;
   1.123 +    pixman_bool_t               component_alpha;
   1.124 +    property_changed_func_t     property_changed;
   1.125 +
   1.126 +    pixman_image_destroy_func_t destroy_func;
   1.127 +    void *                      destroy_data;
   1.128 +
   1.129 +    uint32_t			flags;
   1.130 +    pixman_format_code_t	extended_format_code;
   1.131 +};
   1.132 +
   1.133 +struct solid_fill
   1.134 +{
   1.135 +    image_common_t common;
   1.136 +    pixman_color_t color;
   1.137 +
   1.138 +    uint32_t	   color_32;
   1.139 +    argb_t	   color_float;
   1.140 +};
   1.141 +
   1.142 +struct gradient
   1.143 +{
   1.144 +    image_common_t	    common;
   1.145 +    int                     n_stops;
   1.146 +    pixman_gradient_stop_t *stops;
   1.147 +};
   1.148 +
   1.149 +struct linear_gradient
   1.150 +{
   1.151 +    gradient_t           common;
   1.152 +    pixman_point_fixed_t p1;
   1.153 +    pixman_point_fixed_t p2;
   1.154 +};
   1.155 +
   1.156 +struct circle
   1.157 +{
   1.158 +    pixman_fixed_t x;
   1.159 +    pixman_fixed_t y;
   1.160 +    pixman_fixed_t radius;
   1.161 +};
   1.162 +
   1.163 +struct radial_gradient
   1.164 +{
   1.165 +    gradient_t common;
   1.166 +
   1.167 +    circle_t   c1;
   1.168 +    circle_t   c2;
   1.169 +
   1.170 +    circle_t   delta;
   1.171 +    double     a;
   1.172 +    double     inva;
   1.173 +    double     mindr;
   1.174 +};
   1.175 +
   1.176 +struct conical_gradient
   1.177 +{
   1.178 +    gradient_t           common;
   1.179 +    pixman_point_fixed_t center;
   1.180 +    double		 angle;
   1.181 +};
   1.182 +
   1.183 +struct bits_image
   1.184 +{
   1.185 +    image_common_t             common;
   1.186 +    pixman_format_code_t       format;
   1.187 +    const pixman_indexed_t *   indexed;
   1.188 +    int                        width;
   1.189 +    int                        height;
   1.190 +    uint32_t *                 bits;
   1.191 +    uint32_t *                 free_me;
   1.192 +    int                        rowstride;  /* in number of uint32_t's */
   1.193 +
   1.194 +    fetch_scanline_t           fetch_scanline_16;
   1.195 +
   1.196 +    fetch_scanline_t           fetch_scanline_32;
   1.197 +    fetch_pixel_32_t	       fetch_pixel_32;
   1.198 +    store_scanline_t           store_scanline_32;
   1.199 +
   1.200 +    fetch_scanline_t	       fetch_scanline_float;
   1.201 +    fetch_pixel_float_t	       fetch_pixel_float;
   1.202 +    store_scanline_t           store_scanline_float;
   1.203 +
   1.204 +    store_scanline_t           store_scanline_16;
   1.205 +
   1.206 +    /* Used for indirect access to the bits */
   1.207 +    pixman_read_memory_func_t  read_func;
   1.208 +    pixman_write_memory_func_t write_func;
   1.209 +};
   1.210 +
   1.211 +union pixman_image
   1.212 +{
   1.213 +    image_type_t       type;
   1.214 +    image_common_t     common;
   1.215 +    bits_image_t       bits;
   1.216 +    gradient_t         gradient;
   1.217 +    linear_gradient_t  linear;
   1.218 +    conical_gradient_t conical;
   1.219 +    radial_gradient_t  radial;
   1.220 +    solid_fill_t       solid;
   1.221 +};
   1.222 +
   1.223 +typedef struct pixman_iter_t pixman_iter_t;
   1.224 +typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask);
   1.225 +typedef void      (* pixman_iter_write_back_t)   (pixman_iter_t *iter);
   1.226 +
   1.227 +typedef enum
   1.228 +{
   1.229 +    ITER_NARROW =		(1 << 0),
   1.230 +
   1.231 +    /* "Localized alpha" is when the alpha channel is used only to compute
   1.232 +     * the alpha value of the destination. This means that the computation
   1.233 +     * of the RGB values of the result is independent of the alpha value.
   1.234 +     *
   1.235 +     * For example, the OVER operator has localized alpha for the
   1.236 +     * destination, because the RGB values of the result can be computed
   1.237 +     * without knowing the destination alpha. Similarly, ADD has localized
   1.238 +     * alpha for both source and destination because the RGB values of the
   1.239 +     * result can be computed without knowing the alpha value of source or
   1.240 +     * destination.
   1.241 +     *
   1.242 +     * When he destination is xRGB, this is useful knowledge, because then
   1.243 +     * we can treat it as if it were ARGB, which means in some cases we can
   1.244 +     * avoid copying it to a temporary buffer.
   1.245 +     */
   1.246 +    ITER_LOCALIZED_ALPHA =	(1 << 1),
   1.247 +    ITER_IGNORE_ALPHA =		(1 << 2),
   1.248 +    ITER_IGNORE_RGB =		(1 << 3),
   1.249 +
   1.250 +    /* With the addition of ITER_16 we now have two flags that to represent
   1.251 +     * 3 pipelines. This means that there can be an invalid state when
   1.252 +     * both ITER_NARROW and ITER_16 are set. In this case
   1.253 +     * ITER_16 overrides NARROW and we should use the 16 bit pipeline.
   1.254 +     * Note: ITER_16 still has a 32 bit mask, which is a bit weird. */
   1.255 +    ITER_16 =			(1 << 4)
   1.256 +} iter_flags_t;
   1.257 +
   1.258 +struct pixman_iter_t
   1.259 +{
   1.260 +    /* These are initialized by _pixman_implementation_{src,dest}_init */
   1.261 +    pixman_image_t *		image;
   1.262 +    uint32_t *			buffer;
   1.263 +    int				x, y;
   1.264 +    int				width;
   1.265 +    int				height;
   1.266 +    iter_flags_t		iter_flags;
   1.267 +    uint32_t			image_flags;
   1.268 +
   1.269 +    /* These function pointers are initialized by the implementation */
   1.270 +    pixman_iter_get_scanline_t	get_scanline;
   1.271 +    pixman_iter_write_back_t	write_back;
   1.272 +
   1.273 +    /* These fields are scratch data that implementations can use */
   1.274 +    void *			data;
   1.275 +    uint8_t *			bits;
   1.276 +    int				stride;
   1.277 +};
   1.278 +
   1.279 +void
   1.280 +_pixman_bits_image_setup_accessors (bits_image_t *image);
   1.281 +
   1.282 +void
   1.283 +_pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter);
   1.284 +
   1.285 +void
   1.286 +_pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter);
   1.287 +
   1.288 +void
   1.289 +_pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t  *iter);
   1.290 +
   1.291 +void
   1.292 +_pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
   1.293 +
   1.294 +void
   1.295 +_pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
   1.296 +
   1.297 +void
   1.298 +_pixman_image_init (pixman_image_t *image);
   1.299 +
   1.300 +pixman_bool_t
   1.301 +_pixman_bits_image_init (pixman_image_t *     image,
   1.302 +                         pixman_format_code_t format,
   1.303 +                         int                  width,
   1.304 +                         int                  height,
   1.305 +                         uint32_t *           bits,
   1.306 +                         int                  rowstride,
   1.307 +			 pixman_bool_t	      clear);
   1.308 +pixman_bool_t
   1.309 +_pixman_image_fini (pixman_image_t *image);
   1.310 +
   1.311 +pixman_image_t *
   1.312 +_pixman_image_allocate (void);
   1.313 +
   1.314 +pixman_bool_t
   1.315 +_pixman_init_gradient (gradient_t *                  gradient,
   1.316 +                       const pixman_gradient_stop_t *stops,
   1.317 +                       int                           n_stops);
   1.318 +void
   1.319 +_pixman_image_reset_clip_region (pixman_image_t *image);
   1.320 +
   1.321 +void
   1.322 +_pixman_image_validate (pixman_image_t *image);
   1.323 +
   1.324 +#define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul)	\
   1.325 +    do									\
   1.326 +    {									\
   1.327 +	uint32_t *__bits__;						\
   1.328 +	int       __stride__;						\
   1.329 +        								\
   1.330 +	__bits__ = image->bits.bits;					\
   1.331 +	__stride__ = image->bits.rowstride;				\
   1.332 +	(out_stride) =							\
   1.333 +	    __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type);	\
   1.334 +	(line) =							\
   1.335 +	    ((type *) __bits__) + (out_stride) * (y) + (mul) * (x);	\
   1.336 +    } while (0)
   1.337 +
   1.338 +/*
   1.339 + * Gradient walker
   1.340 + */
   1.341 +typedef struct
   1.342 +{
   1.343 +    uint32_t                left_ag;
   1.344 +    uint32_t                left_rb;
   1.345 +    uint32_t                right_ag;
   1.346 +    uint32_t                right_rb;
   1.347 +    pixman_fixed_t	    left_x;
   1.348 +    pixman_fixed_t          right_x;
   1.349 +    pixman_fixed_t          stepper;
   1.350 +
   1.351 +    pixman_gradient_stop_t *stops;
   1.352 +    int                     num_stops;
   1.353 +    pixman_repeat_t	    repeat;
   1.354 +
   1.355 +    pixman_bool_t           need_reset;
   1.356 +} pixman_gradient_walker_t;
   1.357 +
   1.358 +void
   1.359 +_pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
   1.360 +                              gradient_t *              gradient,
   1.361 +			      pixman_repeat_t           repeat);
   1.362 +
   1.363 +void
   1.364 +_pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
   1.365 +                               pixman_fixed_48_16_t      pos);
   1.366 +
   1.367 +uint32_t
   1.368 +_pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
   1.369 +                               pixman_fixed_48_16_t      x);
   1.370 +
   1.371 +/*
   1.372 + * Edges
   1.373 + */
   1.374 +
   1.375 +#define MAX_ALPHA(n)    ((1 << (n)) - 1)
   1.376 +#define N_Y_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n) / 2)) - 1)
   1.377 +#define N_X_FRAC(n)     ((n) == 1 ? 1 : (1 << ((n) / 2)) + 1)
   1.378 +
   1.379 +#define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC (n))
   1.380 +#define STEP_Y_BIG(n)   (pixman_fixed_1 - (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
   1.381 +
   1.382 +#define Y_FRAC_FIRST(n) (STEP_Y_BIG (n) / 2)
   1.383 +#define Y_FRAC_LAST(n)  (Y_FRAC_FIRST (n) + (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
   1.384 +
   1.385 +#define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC (n))
   1.386 +#define STEP_X_BIG(n)   (pixman_fixed_1 - (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
   1.387 +
   1.388 +#define X_FRAC_FIRST(n) (STEP_X_BIG (n) / 2)
   1.389 +#define X_FRAC_LAST(n)  (X_FRAC_FIRST (n) + (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
   1.390 +
   1.391 +#define RENDER_SAMPLES_X(x, n)						\
   1.392 +    ((n) == 1? 0 : (pixman_fixed_frac (x) +				\
   1.393 +		    X_FRAC_FIRST (n)) / STEP_X_SMALL (n))
   1.394 +
   1.395 +void
   1.396 +pixman_rasterize_edges_accessors (pixman_image_t *image,
   1.397 +                                  pixman_edge_t * l,
   1.398 +                                  pixman_edge_t * r,
   1.399 +                                  pixman_fixed_t  t,
   1.400 +                                  pixman_fixed_t  b);
   1.401 +
   1.402 +/*
   1.403 + * Implementations
   1.404 + */
   1.405 +typedef struct pixman_implementation_t pixman_implementation_t;
   1.406 +
   1.407 +typedef struct
   1.408 +{
   1.409 +    pixman_op_t              op;
   1.410 +    pixman_image_t *         src_image;
   1.411 +    pixman_image_t *         mask_image;
   1.412 +    pixman_image_t *         dest_image;
   1.413 +    int32_t                  src_x;
   1.414 +    int32_t                  src_y;
   1.415 +    int32_t                  mask_x;
   1.416 +    int32_t                  mask_y;
   1.417 +    int32_t                  dest_x;
   1.418 +    int32_t                  dest_y;
   1.419 +    int32_t                  width;
   1.420 +    int32_t                  height;
   1.421 +
   1.422 +    uint32_t                 src_flags;
   1.423 +    uint32_t                 mask_flags;
   1.424 +    uint32_t                 dest_flags;
   1.425 +} pixman_composite_info_t;
   1.426 +
   1.427 +#define PIXMAN_COMPOSITE_ARGS(info)					\
   1.428 +    MAYBE_UNUSED pixman_op_t        op = info->op;			\
   1.429 +    MAYBE_UNUSED pixman_image_t *   src_image = info->src_image;	\
   1.430 +    MAYBE_UNUSED pixman_image_t *   mask_image = info->mask_image;	\
   1.431 +    MAYBE_UNUSED pixman_image_t *   dest_image = info->dest_image;	\
   1.432 +    MAYBE_UNUSED int32_t            src_x = info->src_x;		\
   1.433 +    MAYBE_UNUSED int32_t            src_y = info->src_y;		\
   1.434 +    MAYBE_UNUSED int32_t            mask_x = info->mask_x;		\
   1.435 +    MAYBE_UNUSED int32_t            mask_y = info->mask_y;		\
   1.436 +    MAYBE_UNUSED int32_t            dest_x = info->dest_x;		\
   1.437 +    MAYBE_UNUSED int32_t            dest_y = info->dest_y;		\
   1.438 +    MAYBE_UNUSED int32_t            width = info->width;		\
   1.439 +    MAYBE_UNUSED int32_t            height = info->height
   1.440 +
   1.441 +typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp,
   1.442 +					  pixman_op_t              op,
   1.443 +					  uint32_t *               dest,
   1.444 +					  const uint32_t *         src,
   1.445 +					  const uint32_t *         mask,
   1.446 +					  int                      width);
   1.447 +
   1.448 +typedef void (*pixman_combine_float_func_t) (pixman_implementation_t *imp,
   1.449 +					     pixman_op_t	      op,
   1.450 +					     float *		      dest,
   1.451 +					     const float *	      src,
   1.452 +					     const float *	      mask,
   1.453 +					     int		      n_pixels);
   1.454 +
   1.455 +typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp,
   1.456 +					 pixman_composite_info_t *info);
   1.457 +typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp,
   1.458 +					    uint32_t *               src_bits,
   1.459 +					    uint32_t *               dst_bits,
   1.460 +					    int                      src_stride,
   1.461 +					    int                      dst_stride,
   1.462 +					    int                      src_bpp,
   1.463 +					    int                      dst_bpp,
   1.464 +					    int                      src_x,
   1.465 +					    int                      src_y,
   1.466 +					    int                      dest_x,
   1.467 +					    int                      dest_y,
   1.468 +					    int                      width,
   1.469 +					    int                      height);
   1.470 +typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
   1.471 +					     uint32_t *               bits,
   1.472 +					     int                      stride,
   1.473 +					     int                      bpp,
   1.474 +					     int                      x,
   1.475 +					     int                      y,
   1.476 +					     int                      width,
   1.477 +					     int                      height,
   1.478 +					     uint32_t                 filler);
   1.479 +typedef pixman_bool_t (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
   1.480 +						  pixman_iter_t           *iter);
   1.481 +
   1.482 +void _pixman_setup_combiner_functions_16 (pixman_implementation_t *imp);
   1.483 +void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
   1.484 +void _pixman_setup_combiner_functions_float (pixman_implementation_t *imp);
   1.485 +
   1.486 +typedef struct
   1.487 +{
   1.488 +    pixman_op_t             op;
   1.489 +    pixman_format_code_t    src_format;
   1.490 +    uint32_t		    src_flags;
   1.491 +    pixman_format_code_t    mask_format;
   1.492 +    uint32_t		    mask_flags;
   1.493 +    pixman_format_code_t    dest_format;
   1.494 +    uint32_t		    dest_flags;
   1.495 +    pixman_composite_func_t func;
   1.496 +} pixman_fast_path_t;
   1.497 +
   1.498 +struct pixman_implementation_t
   1.499 +{
   1.500 +    pixman_implementation_t *	toplevel;
   1.501 +    pixman_implementation_t *	fallback;
   1.502 +    const pixman_fast_path_t *	fast_paths;
   1.503 +
   1.504 +    pixman_blt_func_t		blt;
   1.505 +    pixman_fill_func_t		fill;
   1.506 +    pixman_iter_init_func_t     src_iter_init;
   1.507 +    pixman_iter_init_func_t     dest_iter_init;
   1.508 +
   1.509 +    pixman_combine_32_func_t	combine_16[PIXMAN_N_OPERATORS];
   1.510 +    pixman_combine_32_func_t	combine_16_ca[PIXMAN_N_OPERATORS];
   1.511 +    pixman_combine_32_func_t	combine_32[PIXMAN_N_OPERATORS];
   1.512 +    pixman_combine_32_func_t	combine_32_ca[PIXMAN_N_OPERATORS];
   1.513 +    pixman_combine_float_func_t	combine_float[PIXMAN_N_OPERATORS];
   1.514 +    pixman_combine_float_func_t	combine_float_ca[PIXMAN_N_OPERATORS];
   1.515 +};
   1.516 +
   1.517 +uint32_t
   1.518 +_pixman_image_get_solid (pixman_implementation_t *imp,
   1.519 +			 pixman_image_t *         image,
   1.520 +                         pixman_format_code_t     format);
   1.521 +
   1.522 +pixman_implementation_t *
   1.523 +_pixman_implementation_create (pixman_implementation_t *fallback,
   1.524 +			       const pixman_fast_path_t *fast_paths);
   1.525 +
   1.526 +void
   1.527 +_pixman_implementation_lookup_composite (pixman_implementation_t  *toplevel,
   1.528 +					 pixman_op_t               op,
   1.529 +					 pixman_format_code_t      src_format,
   1.530 +					 uint32_t                  src_flags,
   1.531 +					 pixman_format_code_t      mask_format,
   1.532 +					 uint32_t                  mask_flags,
   1.533 +					 pixman_format_code_t      dest_format,
   1.534 +					 uint32_t                  dest_flags,
   1.535 +					 pixman_implementation_t **out_imp,
   1.536 +					 pixman_composite_func_t  *out_func);
   1.537 +
   1.538 +pixman_combine_32_func_t
   1.539 +_pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
   1.540 +					pixman_op_t		 op,
   1.541 +					pixman_bool_t		 component_alpha,
   1.542 +					pixman_bool_t		 wide,
   1.543 +					pixman_bool_t		 rgb16);
   1.544 +
   1.545 +pixman_bool_t
   1.546 +_pixman_implementation_blt (pixman_implementation_t *imp,
   1.547 +                            uint32_t *               src_bits,
   1.548 +                            uint32_t *               dst_bits,
   1.549 +                            int                      src_stride,
   1.550 +                            int                      dst_stride,
   1.551 +                            int                      src_bpp,
   1.552 +                            int                      dst_bpp,
   1.553 +                            int                      src_x,
   1.554 +                            int                      src_y,
   1.555 +                            int                      dest_x,
   1.556 +                            int                      dest_y,
   1.557 +                            int                      width,
   1.558 +                            int                      height);
   1.559 +
   1.560 +pixman_bool_t
   1.561 +_pixman_implementation_fill (pixman_implementation_t *imp,
   1.562 +                             uint32_t *               bits,
   1.563 +                             int                      stride,
   1.564 +                             int                      bpp,
   1.565 +                             int                      x,
   1.566 +                             int                      y,
   1.567 +                             int                      width,
   1.568 +                             int                      height,
   1.569 +                             uint32_t                 filler);
   1.570 +
   1.571 +pixman_bool_t
   1.572 +_pixman_implementation_src_iter_init (pixman_implementation_t       *imp,
   1.573 +				      pixman_iter_t                 *iter,
   1.574 +				      pixman_image_t                *image,
   1.575 +				      int                            x,
   1.576 +				      int                            y,
   1.577 +				      int                            width,
   1.578 +				      int                            height,
   1.579 +				      uint8_t                       *buffer,
   1.580 +				      iter_flags_t                   flags,
   1.581 +				      uint32_t                       image_flags);
   1.582 +
   1.583 +pixman_bool_t
   1.584 +_pixman_implementation_dest_iter_init (pixman_implementation_t       *imp,
   1.585 +				       pixman_iter_t                 *iter,
   1.586 +				       pixman_image_t                *image,
   1.587 +				       int                            x,
   1.588 +				       int                            y,
   1.589 +				       int                            width,
   1.590 +				       int                            height,
   1.591 +				       uint8_t                       *buffer,
   1.592 +				       iter_flags_t                   flags,
   1.593 +				       uint32_t                       image_flags);
   1.594 +
   1.595 +/* Specific implementations */
   1.596 +pixman_implementation_t *
   1.597 +_pixman_implementation_create_general (void);
   1.598 +
   1.599 +pixman_implementation_t *
   1.600 +_pixman_implementation_create_fast_path (pixman_implementation_t *fallback);
   1.601 +
   1.602 +pixman_implementation_t *
   1.603 +_pixman_implementation_create_noop (pixman_implementation_t *fallback);
   1.604 +
   1.605 +#if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI
   1.606 +pixman_implementation_t *
   1.607 +_pixman_implementation_create_mmx (pixman_implementation_t *fallback);
   1.608 +#endif
   1.609 +
   1.610 +#ifdef USE_SSE2
   1.611 +pixman_implementation_t *
   1.612 +_pixman_implementation_create_sse2 (pixman_implementation_t *fallback);
   1.613 +#endif
   1.614 +
   1.615 +#ifdef USE_ARM_SIMD
   1.616 +pixman_implementation_t *
   1.617 +_pixman_implementation_create_arm_simd (pixman_implementation_t *fallback);
   1.618 +#endif
   1.619 +
   1.620 +#ifdef USE_ARM_NEON
   1.621 +pixman_implementation_t *
   1.622 +_pixman_implementation_create_arm_neon (pixman_implementation_t *fallback);
   1.623 +#endif
   1.624 +
   1.625 +#ifdef USE_MIPS_DSPR2
   1.626 +pixman_implementation_t *
   1.627 +_pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback);
   1.628 +#endif
   1.629 +
   1.630 +#ifdef USE_VMX
   1.631 +pixman_implementation_t *
   1.632 +_pixman_implementation_create_vmx (pixman_implementation_t *fallback);
   1.633 +#endif
   1.634 +
   1.635 +pixman_bool_t
   1.636 +_pixman_implementation_disabled (const char *name);
   1.637 +
   1.638 +pixman_implementation_t *
   1.639 +_pixman_x86_get_implementations (pixman_implementation_t *imp);
   1.640 +
   1.641 +pixman_implementation_t *
   1.642 +_pixman_arm_get_implementations (pixman_implementation_t *imp);
   1.643 +
   1.644 +pixman_implementation_t *
   1.645 +_pixman_ppc_get_implementations (pixman_implementation_t *imp);
   1.646 +
   1.647 +pixman_implementation_t *
   1.648 +_pixman_mips_get_implementations (pixman_implementation_t *imp);
   1.649 +
   1.650 +pixman_implementation_t *
   1.651 +_pixman_choose_implementation (void);
   1.652 +
   1.653 +pixman_bool_t
   1.654 +_pixman_disabled (const char *name);
   1.655 +
   1.656 +
   1.657 +/*
   1.658 + * Utilities
   1.659 + */
   1.660 +pixman_bool_t
   1.661 +_pixman_compute_composite_region32 (pixman_region32_t * region,
   1.662 +				    pixman_image_t *    src_image,
   1.663 +				    pixman_image_t *    mask_image,
   1.664 +				    pixman_image_t *    dest_image,
   1.665 +				    int32_t             src_x,
   1.666 +				    int32_t             src_y,
   1.667 +				    int32_t             mask_x,
   1.668 +				    int32_t             mask_y,
   1.669 +				    int32_t             dest_x,
   1.670 +				    int32_t             dest_y,
   1.671 +				    int32_t             width,
   1.672 +				    int32_t             height);
   1.673 +uint32_t *
   1.674 +_pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask);
   1.675 +
   1.676 +/* These "formats" all have depth 0, so they
   1.677 + * will never clash with any real ones
   1.678 + */
   1.679 +#define PIXMAN_null             PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
   1.680 +#define PIXMAN_solid            PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
   1.681 +#define PIXMAN_pixbuf		PIXMAN_FORMAT (0, 2, 0, 0, 0, 0)
   1.682 +#define PIXMAN_rpixbuf		PIXMAN_FORMAT (0, 3, 0, 0, 0, 0)
   1.683 +#define PIXMAN_unknown		PIXMAN_FORMAT (0, 4, 0, 0, 0, 0)
   1.684 +#define PIXMAN_any		PIXMAN_FORMAT (0, 5, 0, 0, 0, 0)
   1.685 +
   1.686 +#define PIXMAN_OP_any		(PIXMAN_N_OPERATORS + 1)
   1.687 +
   1.688 +#define FAST_PATH_ID_TRANSFORM			(1 <<  0)
   1.689 +#define FAST_PATH_NO_ALPHA_MAP			(1 <<  1)
   1.690 +#define FAST_PATH_NO_CONVOLUTION_FILTER		(1 <<  2)
   1.691 +#define FAST_PATH_NO_PAD_REPEAT			(1 <<  3)
   1.692 +#define FAST_PATH_NO_REFLECT_REPEAT		(1 <<  4)
   1.693 +#define FAST_PATH_NO_ACCESSORS			(1 <<  5)
   1.694 +#define FAST_PATH_NARROW_FORMAT			(1 <<  6)
   1.695 +#define FAST_PATH_COMPONENT_ALPHA		(1 <<  8)
   1.696 +#define FAST_PATH_SAMPLES_OPAQUE		(1 <<  7)
   1.697 +#define FAST_PATH_UNIFIED_ALPHA			(1 <<  9)
   1.698 +#define FAST_PATH_SCALE_TRANSFORM		(1 << 10)
   1.699 +#define FAST_PATH_NEAREST_FILTER		(1 << 11)
   1.700 +#define FAST_PATH_HAS_TRANSFORM			(1 << 12)
   1.701 +#define FAST_PATH_IS_OPAQUE			(1 << 13)
   1.702 +#define FAST_PATH_NO_NORMAL_REPEAT		(1 << 14)
   1.703 +#define FAST_PATH_NO_NONE_REPEAT		(1 << 15)
   1.704 +#define FAST_PATH_X_UNIT_POSITIVE		(1 << 16)
   1.705 +#define FAST_PATH_AFFINE_TRANSFORM		(1 << 17)
   1.706 +#define FAST_PATH_Y_UNIT_ZERO			(1 << 18)
   1.707 +#define FAST_PATH_BILINEAR_FILTER		(1 << 19)
   1.708 +#define FAST_PATH_ROTATE_90_TRANSFORM		(1 << 20)
   1.709 +#define FAST_PATH_ROTATE_180_TRANSFORM		(1 << 21)
   1.710 +#define FAST_PATH_ROTATE_270_TRANSFORM		(1 << 22)
   1.711 +#define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST	(1 << 23)
   1.712 +#define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR	(1 << 24)
   1.713 +#define FAST_PATH_BITS_IMAGE			(1 << 25)
   1.714 +#define FAST_PATH_SEPARABLE_CONVOLUTION_FILTER  (1 << 26)
   1.715 +#define FAST_PATH_16_FORMAT			(1 << 27)
   1.716 +
   1.717 +#define FAST_PATH_PAD_REPEAT						\
   1.718 +    (FAST_PATH_NO_NONE_REPEAT		|				\
   1.719 +     FAST_PATH_NO_NORMAL_REPEAT		|				\
   1.720 +     FAST_PATH_NO_REFLECT_REPEAT)
   1.721 +
   1.722 +#define FAST_PATH_NORMAL_REPEAT						\
   1.723 +    (FAST_PATH_NO_NONE_REPEAT		|				\
   1.724 +     FAST_PATH_NO_PAD_REPEAT		|				\
   1.725 +     FAST_PATH_NO_REFLECT_REPEAT)
   1.726 +
   1.727 +#define FAST_PATH_NONE_REPEAT						\
   1.728 +    (FAST_PATH_NO_NORMAL_REPEAT		|				\
   1.729 +     FAST_PATH_NO_PAD_REPEAT		|				\
   1.730 +     FAST_PATH_NO_REFLECT_REPEAT)
   1.731 +
   1.732 +#define FAST_PATH_REFLECT_REPEAT					\
   1.733 +    (FAST_PATH_NO_NONE_REPEAT		|				\
   1.734 +     FAST_PATH_NO_NORMAL_REPEAT		|				\
   1.735 +     FAST_PATH_NO_PAD_REPEAT)
   1.736 +
   1.737 +#define FAST_PATH_STANDARD_FLAGS					\
   1.738 +    (FAST_PATH_NO_CONVOLUTION_FILTER	|				\
   1.739 +     FAST_PATH_NO_ACCESSORS		|				\
   1.740 +     FAST_PATH_NO_ALPHA_MAP		|				\
   1.741 +     FAST_PATH_NARROW_FORMAT)
   1.742 +
   1.743 +#define FAST_PATH_STD_DEST_FLAGS					\
   1.744 +    (FAST_PATH_NO_ACCESSORS		|				\
   1.745 +     FAST_PATH_NO_ALPHA_MAP		|				\
   1.746 +     FAST_PATH_NARROW_FORMAT)
   1.747 +
   1.748 +#define SOURCE_FLAGS(format)						\
   1.749 +    (FAST_PATH_STANDARD_FLAGS |						\
   1.750 +     ((PIXMAN_ ## format == PIXMAN_solid) ?				\
   1.751 +      0 : (FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | FAST_PATH_NEAREST_FILTER | FAST_PATH_ID_TRANSFORM)))
   1.752 +
   1.753 +#define MASK_FLAGS(format, extra)					\
   1.754 +    ((PIXMAN_ ## format == PIXMAN_null) ? 0 : (SOURCE_FLAGS (format) | extra))
   1.755 +
   1.756 +#define FAST_PATH(op, src, src_flags, mask, mask_flags, dest, dest_flags, func) \
   1.757 +    PIXMAN_OP_ ## op,							\
   1.758 +    PIXMAN_ ## src,							\
   1.759 +    src_flags,							        \
   1.760 +    PIXMAN_ ## mask,						        \
   1.761 +    mask_flags,							        \
   1.762 +    PIXMAN_ ## dest,	                                                \
   1.763 +    dest_flags,							        \
   1.764 +    func
   1.765 +
   1.766 +#define PIXMAN_STD_FAST_PATH(op, src, mask, dest, func)			\
   1.767 +    { FAST_PATH (							\
   1.768 +	    op,								\
   1.769 +	    src,  SOURCE_FLAGS (src),					\
   1.770 +	    mask, MASK_FLAGS (mask, FAST_PATH_UNIFIED_ALPHA),		\
   1.771 +	    dest, FAST_PATH_STD_DEST_FLAGS,				\
   1.772 +	    func) }
   1.773 +
   1.774 +#define PIXMAN_STD_FAST_PATH_CA(op, src, mask, dest, func)		\
   1.775 +    { FAST_PATH (							\
   1.776 +	    op,								\
   1.777 +	    src,  SOURCE_FLAGS (src),					\
   1.778 +	    mask, MASK_FLAGS (mask, FAST_PATH_COMPONENT_ALPHA),		\
   1.779 +	    dest, FAST_PATH_STD_DEST_FLAGS,				\
   1.780 +	    func) }
   1.781 +
   1.782 +extern pixman_implementation_t *global_implementation;
   1.783 +
   1.784 +static force_inline pixman_implementation_t *
   1.785 +get_implementation (void)
   1.786 +{
   1.787 +#ifndef TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR
   1.788 +    if (!global_implementation)
   1.789 +	global_implementation = _pixman_choose_implementation ();
   1.790 +#endif
   1.791 +    return global_implementation;
   1.792 +}
   1.793 +
   1.794 +/* This function is exported for the sake of the test suite and not part
   1.795 + * of the ABI.
   1.796 + */
   1.797 +PIXMAN_EXPORT pixman_implementation_t *
   1.798 +_pixman_internal_only_get_implementation (void);
   1.799 +
   1.800 +/* Memory allocation helpers */
   1.801 +void *
   1.802 +pixman_malloc_ab (unsigned int n, unsigned int b);
   1.803 +
   1.804 +void *
   1.805 +pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
   1.806 +
   1.807 +pixman_bool_t
   1.808 +_pixman_multiply_overflows_size (size_t a, size_t b);
   1.809 +
   1.810 +pixman_bool_t
   1.811 +_pixman_multiply_overflows_int (unsigned int a, unsigned int b);
   1.812 +
   1.813 +pixman_bool_t
   1.814 +_pixman_addition_overflows_int (unsigned int a, unsigned int b);
   1.815 +
   1.816 +/* Compositing utilities */
   1.817 +void
   1.818 +pixman_expand_to_float (argb_t               *dst,
   1.819 +			const uint32_t       *src,
   1.820 +			pixman_format_code_t  format,
   1.821 +			int                   width);
   1.822 +
   1.823 +void
   1.824 +pixman_contract_from_float (uint32_t     *dst,
   1.825 +			    const argb_t *src,
   1.826 +			    int           width);
   1.827 +
   1.828 +/* Region Helpers */
   1.829 +pixman_bool_t
   1.830 +pixman_region32_copy_from_region16 (pixman_region32_t *dst,
   1.831 +                                    pixman_region16_t *src);
   1.832 +
   1.833 +pixman_bool_t
   1.834 +pixman_region16_copy_from_region32 (pixman_region16_t *dst,
   1.835 +                                    pixman_region32_t *src);
   1.836 +
   1.837 +/* Doubly linked lists */
   1.838 +typedef struct pixman_link_t pixman_link_t;
   1.839 +struct pixman_link_t
   1.840 +{
   1.841 +    pixman_link_t *next;
   1.842 +    pixman_link_t *prev;
   1.843 +};
   1.844 +
   1.845 +typedef struct pixman_list_t pixman_list_t;
   1.846 +struct pixman_list_t
   1.847 +{
   1.848 +    pixman_link_t *head;
   1.849 +    pixman_link_t *tail;
   1.850 +};
   1.851 +
   1.852 +static force_inline void
   1.853 +pixman_list_init (pixman_list_t *list)
   1.854 +{
   1.855 +    list->head = (pixman_link_t *)list;
   1.856 +    list->tail = (pixman_link_t *)list;
   1.857 +}
   1.858 +
   1.859 +static force_inline void
   1.860 +pixman_list_prepend (pixman_list_t *list, pixman_link_t *link)
   1.861 +{
   1.862 +    link->next = list->head;
   1.863 +    link->prev = (pixman_link_t *)list;
   1.864 +    list->head->prev = link;
   1.865 +    list->head = link;
   1.866 +}
   1.867 +
   1.868 +static force_inline void
   1.869 +pixman_list_unlink (pixman_link_t *link)
   1.870 +{
   1.871 +    link->prev->next = link->next;
   1.872 +    link->next->prev = link->prev;
   1.873 +}
   1.874 +
   1.875 +static force_inline void
   1.876 +pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link)
   1.877 +{
   1.878 +    pixman_list_unlink (link);
   1.879 +    pixman_list_prepend (list, link);
   1.880 +}
   1.881 +
   1.882 +/* Misc macros */
   1.883 +
   1.884 +#ifndef FALSE
   1.885 +#   define FALSE 0
   1.886 +#endif
   1.887 +
   1.888 +#ifndef TRUE
   1.889 +#   define TRUE 1
   1.890 +#endif
   1.891 +
   1.892 +#ifndef MIN
   1.893 +#  define MIN(a, b) ((a < b) ? a : b)
   1.894 +#endif
   1.895 +
   1.896 +#ifndef MAX
   1.897 +#  define MAX(a, b) ((a > b) ? a : b)
   1.898 +#endif
   1.899 +
   1.900 +/* Integer division that rounds towards -infinity */
   1.901 +#define DIV(a, b)					   \
   1.902 +    ((((a) < 0) == ((b) < 0)) ? (a) / (b) :                \
   1.903 +     ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
   1.904 +
   1.905 +/* Modulus that produces the remainder wrt. DIV */
   1.906 +#define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
   1.907 +
   1.908 +#define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v)))
   1.909 +
   1.910 +/* Conversion between 8888 and 0565 */
   1.911 +
   1.912 +static force_inline uint16_t
   1.913 +convert_8888_to_0565 (uint32_t s)
   1.914 +{
   1.915 +    /* The following code can be compiled into just 4 instructions on ARM */
   1.916 +    uint32_t a, b;
   1.917 +    a = (s >> 3) & 0x1F001F;
   1.918 +    b = s & 0xFC00;
   1.919 +    a |= a >> 5;
   1.920 +    a |= b >> 5;
   1.921 +    return (uint16_t)a;
   1.922 +}
   1.923 +
   1.924 +static force_inline uint32_t
   1.925 +convert_0565_to_0888 (uint16_t s)
   1.926 +{
   1.927 +    return (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) |
   1.928 +            ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) |
   1.929 +            ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)));
   1.930 +}
   1.931 +
   1.932 +static force_inline uint32_t
   1.933 +convert_0565_to_8888 (uint16_t s)
   1.934 +{
   1.935 +    return convert_0565_to_0888 (s) | 0xff000000;
   1.936 +}
   1.937 +
   1.938 +/* Trivial versions that are useful in macros */
   1.939 +
   1.940 +static force_inline uint32_t
   1.941 +convert_8888_to_8888 (uint32_t s)
   1.942 +{
   1.943 +    return s;
   1.944 +}
   1.945 +
   1.946 +static force_inline uint32_t
   1.947 +convert_x888_to_8888 (uint32_t s)
   1.948 +{
   1.949 +    return s | 0xff000000;
   1.950 +}
   1.951 +
   1.952 +static force_inline uint16_t
   1.953 +convert_0565_to_0565 (uint16_t s)
   1.954 +{
   1.955 +    return s;
   1.956 +}
   1.957 +
   1.958 +#define PIXMAN_FORMAT_IS_WIDE(f)					\
   1.959 +    (PIXMAN_FORMAT_A (f) > 8 ||						\
   1.960 +     PIXMAN_FORMAT_R (f) > 8 ||						\
   1.961 +     PIXMAN_FORMAT_G (f) > 8 ||						\
   1.962 +     PIXMAN_FORMAT_B (f) > 8 ||						\
   1.963 +     PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB)
   1.964 +
   1.965 +#ifdef WORDS_BIGENDIAN
   1.966 +#   define SCREEN_SHIFT_LEFT(x,n)	((x) << (n))
   1.967 +#   define SCREEN_SHIFT_RIGHT(x,n)	((x) >> (n))
   1.968 +#else
   1.969 +#   define SCREEN_SHIFT_LEFT(x,n)	((x) >> (n))
   1.970 +#   define SCREEN_SHIFT_RIGHT(x,n)	((x) << (n))
   1.971 +#endif
   1.972 +
   1.973 +static force_inline uint32_t
   1.974 +unorm_to_unorm (uint32_t val, int from_bits, int to_bits)
   1.975 +{
   1.976 +    uint32_t result;
   1.977 +
   1.978 +    if (from_bits == 0)
   1.979 +	return 0;
   1.980 +
   1.981 +    /* Delete any extra bits */
   1.982 +    val &= ((1 << from_bits) - 1);
   1.983 +
   1.984 +    if (from_bits >= to_bits)
   1.985 +	return val >> (from_bits - to_bits);
   1.986 +
   1.987 +    /* Start out with the high bit of val in the high bit of result. */
   1.988 +    result = val << (to_bits - from_bits);
   1.989 +
   1.990 +    /* Copy the bits in result, doubling the number of bits each time, until
   1.991 +     * we fill all to_bits. Unrolled manually because from_bits and to_bits
   1.992 +     * are usually known statically, so the compiler can turn all of this
   1.993 +     * into a few shifts.
   1.994 +     */
   1.995 +#define REPLICATE()							\
   1.996 +    do									\
   1.997 +    {									\
   1.998 +	if (from_bits < to_bits)					\
   1.999 +	{								\
  1.1000 +	    result |= result >> from_bits;				\
  1.1001 +									\
  1.1002 +	    from_bits *= 2;						\
  1.1003 +	}								\
  1.1004 +    }									\
  1.1005 +    while (0)
  1.1006 +
  1.1007 +    REPLICATE();
  1.1008 +    REPLICATE();
  1.1009 +    REPLICATE();
  1.1010 +    REPLICATE();
  1.1011 +    REPLICATE();
  1.1012 +
  1.1013 +    return result;
  1.1014 +}
  1.1015 +
  1.1016 +uint16_t pixman_float_to_unorm (float f, int n_bits);
  1.1017 +float pixman_unorm_to_float (uint16_t u, int n_bits);
  1.1018 +
  1.1019 +/*
  1.1020 + * Various debugging code
  1.1021 + */
  1.1022 +
  1.1023 +#undef DEBUG
  1.1024 +
  1.1025 +#define COMPILE_TIME_ASSERT(x)						\
  1.1026 +    do { typedef int compile_time_assertion [(x)?1:-1]; } while (0)
  1.1027 +
  1.1028 +/* Turn on debugging depending on what type of release this is
  1.1029 + */
  1.1030 +#if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1))
  1.1031 +
  1.1032 +/* Debugging gets turned on for development releases because these
  1.1033 + * are the things that end up in bleeding edge distributions such
  1.1034 + * as Rawhide etc.
  1.1035 + *
  1.1036 + * For performance reasons we don't turn it on for stable releases or
  1.1037 + * random git checkouts. (Random git checkouts are often used for
  1.1038 + * performance work).
  1.1039 + */
  1.1040 +
  1.1041 +#    define DEBUG
  1.1042 +
  1.1043 +#endif
  1.1044 +
  1.1045 +#ifdef DEBUG
  1.1046 +
  1.1047 +void
  1.1048 +_pixman_log_error (const char *function, const char *message);
  1.1049 +
  1.1050 +#define return_if_fail(expr)                                            \
  1.1051 +    do                                                                  \
  1.1052 +    {                                                                   \
  1.1053 +	if (!(expr))							\
  1.1054 +	{								\
  1.1055 +	    _pixman_log_error (FUNC, "The expression " # expr " was false"); \
  1.1056 +	    return;							\
  1.1057 +	}								\
  1.1058 +    }                                                                   \
  1.1059 +    while (0)
  1.1060 +
  1.1061 +#define return_val_if_fail(expr, retval)                                \
  1.1062 +    do                                                                  \
  1.1063 +    {                                                                   \
  1.1064 +	if (!(expr))                                                    \
  1.1065 +	{								\
  1.1066 +	    _pixman_log_error (FUNC, "The expression " # expr " was false"); \
  1.1067 +	    return (retval);						\
  1.1068 +	}								\
  1.1069 +    }                                                                   \
  1.1070 +    while (0)
  1.1071 +
  1.1072 +#define critical_if_fail(expr)						\
  1.1073 +    do									\
  1.1074 +    {									\
  1.1075 +	if (!(expr))							\
  1.1076 +	    _pixman_log_error (FUNC, "The expression " # expr " was false"); \
  1.1077 +    }									\
  1.1078 +    while (0)
  1.1079 +
  1.1080 +
  1.1081 +#else
  1.1082 +
  1.1083 +#define _pixman_log_error(f,m) do { } while (0)
  1.1084 +
  1.1085 +#define return_if_fail(expr)						\
  1.1086 +    do                                                                  \
  1.1087 +    {                                                                   \
  1.1088 +	if (!(expr))							\
  1.1089 +	    return;							\
  1.1090 +    }                                                                   \
  1.1091 +    while (0)
  1.1092 +
  1.1093 +#define return_val_if_fail(expr, retval)                                \
  1.1094 +    do                                                                  \
  1.1095 +    {                                                                   \
  1.1096 +	if (!(expr))							\
  1.1097 +	    return (retval);						\
  1.1098 +    }                                                                   \
  1.1099 +    while (0)
  1.1100 +
  1.1101 +#define critical_if_fail(expr)						\
  1.1102 +    do									\
  1.1103 +    {									\
  1.1104 +    }									\
  1.1105 +    while (0)
  1.1106 +#endif
  1.1107 +
  1.1108 +/*
  1.1109 + * Matrix
  1.1110 + */
  1.1111 +
  1.1112 +typedef struct { pixman_fixed_48_16_t v[3]; } pixman_vector_48_16_t;
  1.1113 +
  1.1114 +pixman_bool_t
  1.1115 +pixman_transform_point_31_16 (const pixman_transform_t    *t,
  1.1116 +                              const pixman_vector_48_16_t *v,
  1.1117 +                              pixman_vector_48_16_t       *result);
  1.1118 +
  1.1119 +void
  1.1120 +pixman_transform_point_31_16_3d (const pixman_transform_t    *t,
  1.1121 +                                 const pixman_vector_48_16_t *v,
  1.1122 +                                 pixman_vector_48_16_t       *result);
  1.1123 +
  1.1124 +void
  1.1125 +pixman_transform_point_31_16_affine (const pixman_transform_t    *t,
  1.1126 +                                     const pixman_vector_48_16_t *v,
  1.1127 +                                     pixman_vector_48_16_t       *result);
  1.1128 +
  1.1129 +/*
  1.1130 + * Timers
  1.1131 + */
  1.1132 +
  1.1133 +#ifdef PIXMAN_TIMERS
  1.1134 +
  1.1135 +static inline uint64_t
  1.1136 +oil_profile_stamp_rdtsc (void)
  1.1137 +{
  1.1138 +    uint32_t hi, lo;
  1.1139 +
  1.1140 +    __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi));
  1.1141 +
  1.1142 +    return lo | (((uint64_t)hi) << 32);
  1.1143 +}
  1.1144 +
  1.1145 +#define OIL_STAMP oil_profile_stamp_rdtsc
  1.1146 +
  1.1147 +typedef struct pixman_timer_t pixman_timer_t;
  1.1148 +
  1.1149 +struct pixman_timer_t
  1.1150 +{
  1.1151 +    int             initialized;
  1.1152 +    const char *    name;
  1.1153 +    uint64_t        n_times;
  1.1154 +    uint64_t        total;
  1.1155 +    pixman_timer_t *next;
  1.1156 +};
  1.1157 +
  1.1158 +extern int timer_defined;
  1.1159 +
  1.1160 +void pixman_timer_register (pixman_timer_t *timer);
  1.1161 +
  1.1162 +#define TIMER_BEGIN(tname)                                              \
  1.1163 +    {                                                                   \
  1.1164 +	static pixman_timer_t timer ## tname;                           \
  1.1165 +	uint64_t              begin ## tname;                           \
  1.1166 +        								\
  1.1167 +	if (!timer ## tname.initialized)				\
  1.1168 +	{                                                               \
  1.1169 +	    timer ## tname.initialized = 1;				\
  1.1170 +	    timer ## tname.name = # tname;				\
  1.1171 +	    pixman_timer_register (&timer ## tname);			\
  1.1172 +	}                                                               \
  1.1173 +									\
  1.1174 +	timer ## tname.n_times++;					\
  1.1175 +	begin ## tname = OIL_STAMP ();
  1.1176 +
  1.1177 +#define TIMER_END(tname)                                                \
  1.1178 +    timer ## tname.total += OIL_STAMP () - begin ## tname;		\
  1.1179 +    }
  1.1180 +
  1.1181 +#else
  1.1182 +
  1.1183 +#define TIMER_BEGIN(tname)
  1.1184 +#define TIMER_END(tname)
  1.1185 +
  1.1186 +#endif /* PIXMAN_TIMERS */
  1.1187 +
  1.1188 +#endif /* __ASSEMBLER__ */
  1.1189 +
  1.1190 +#endif /* PIXMAN_PRIVATE_H */

mercurial