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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #ifndef PIXMAN_PRIVATE_H
michael@0 2 #define PIXMAN_PRIVATE_H
michael@0 3
michael@0 4 /*
michael@0 5 * The defines which are shared between C and assembly code
michael@0 6 */
michael@0 7
michael@0 8 /* bilinear interpolation precision (must be <= 8) */
michael@0 9 #ifndef MOZILLA_VERSION
michael@0 10 #error "Need mozilla headers"
michael@0 11 #endif
michael@0 12 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
michael@0 13 #define LOW_QUALITY_INTERPOLATION
michael@0 14 #define LOWER_QUALITY_INTERPOLATION
michael@0 15 #define BILINEAR_INTERPOLATION_BITS 4
michael@0 16 #else
michael@0 17 #define BILINEAR_INTERPOLATION_BITS 7
michael@0 18 #endif
michael@0 19 #define BILINEAR_INTERPOLATION_RANGE (1 << BILINEAR_INTERPOLATION_BITS)
michael@0 20
michael@0 21 /*
michael@0 22 * C specific part
michael@0 23 */
michael@0 24
michael@0 25 #ifndef __ASSEMBLER__
michael@0 26
michael@0 27 #ifndef PACKAGE
michael@0 28 # error config.h must be included before pixman-private.h
michael@0 29 #endif
michael@0 30
michael@0 31 #define PIXMAN_DISABLE_DEPRECATED
michael@0 32 #define PIXMAN_USE_INTERNAL_API
michael@0 33
michael@0 34 #include "pixman.h"
michael@0 35 #include <time.h>
michael@0 36 #include <assert.h>
michael@0 37 #include <stdio.h>
michael@0 38 #include <string.h>
michael@0 39 #include <stddef.h>
michael@0 40
michael@0 41 #include "pixman-compiler.h"
michael@0 42
michael@0 43 /*
michael@0 44 * Images
michael@0 45 */
michael@0 46 typedef struct image_common image_common_t;
michael@0 47 typedef struct solid_fill solid_fill_t;
michael@0 48 typedef struct gradient gradient_t;
michael@0 49 typedef struct linear_gradient linear_gradient_t;
michael@0 50 typedef struct horizontal_gradient horizontal_gradient_t;
michael@0 51 typedef struct vertical_gradient vertical_gradient_t;
michael@0 52 typedef struct conical_gradient conical_gradient_t;
michael@0 53 typedef struct radial_gradient radial_gradient_t;
michael@0 54 typedef struct bits_image bits_image_t;
michael@0 55 typedef struct circle circle_t;
michael@0 56
michael@0 57 typedef struct argb_t argb_t;
michael@0 58
michael@0 59 struct argb_t
michael@0 60 {
michael@0 61 float a;
michael@0 62 float r;
michael@0 63 float g;
michael@0 64 float b;
michael@0 65 };
michael@0 66
michael@0 67 typedef void (*fetch_scanline_t) (pixman_image_t *image,
michael@0 68 int x,
michael@0 69 int y,
michael@0 70 int width,
michael@0 71 uint32_t *buffer,
michael@0 72 const uint32_t *mask);
michael@0 73
michael@0 74 typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image,
michael@0 75 int x,
michael@0 76 int y);
michael@0 77
michael@0 78 typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image,
michael@0 79 int x,
michael@0 80 int y);
michael@0 81
michael@0 82 typedef void (*store_scanline_t) (bits_image_t * image,
michael@0 83 int x,
michael@0 84 int y,
michael@0 85 int width,
michael@0 86 const uint32_t *values);
michael@0 87
michael@0 88 typedef enum
michael@0 89 {
michael@0 90 BITS,
michael@0 91 LINEAR,
michael@0 92 CONICAL,
michael@0 93 RADIAL,
michael@0 94 SOLID
michael@0 95 } image_type_t;
michael@0 96
michael@0 97 typedef void (*property_changed_func_t) (pixman_image_t *image);
michael@0 98
michael@0 99 struct image_common
michael@0 100 {
michael@0 101 image_type_t type;
michael@0 102 int32_t ref_count;
michael@0 103 pixman_region32_t clip_region;
michael@0 104 int32_t alpha_count; /* How many times this image is being used as an alpha map */
michael@0 105 pixman_bool_t have_clip_region; /* FALSE if there is no clip */
michael@0 106 pixman_bool_t client_clip; /* Whether the source clip was
michael@0 107 set by a client */
michael@0 108 pixman_bool_t clip_sources; /* Whether the clip applies when
michael@0 109 * the image is used as a source
michael@0 110 */
michael@0 111 pixman_bool_t dirty;
michael@0 112 pixman_transform_t * transform;
michael@0 113 pixman_repeat_t repeat;
michael@0 114 pixman_filter_t filter;
michael@0 115 pixman_fixed_t * filter_params;
michael@0 116 int n_filter_params;
michael@0 117 bits_image_t * alpha_map;
michael@0 118 int alpha_origin_x;
michael@0 119 int alpha_origin_y;
michael@0 120 pixman_bool_t component_alpha;
michael@0 121 property_changed_func_t property_changed;
michael@0 122
michael@0 123 pixman_image_destroy_func_t destroy_func;
michael@0 124 void * destroy_data;
michael@0 125
michael@0 126 uint32_t flags;
michael@0 127 pixman_format_code_t extended_format_code;
michael@0 128 };
michael@0 129
michael@0 130 struct solid_fill
michael@0 131 {
michael@0 132 image_common_t common;
michael@0 133 pixman_color_t color;
michael@0 134
michael@0 135 uint32_t color_32;
michael@0 136 argb_t color_float;
michael@0 137 };
michael@0 138
michael@0 139 struct gradient
michael@0 140 {
michael@0 141 image_common_t common;
michael@0 142 int n_stops;
michael@0 143 pixman_gradient_stop_t *stops;
michael@0 144 };
michael@0 145
michael@0 146 struct linear_gradient
michael@0 147 {
michael@0 148 gradient_t common;
michael@0 149 pixman_point_fixed_t p1;
michael@0 150 pixman_point_fixed_t p2;
michael@0 151 };
michael@0 152
michael@0 153 struct circle
michael@0 154 {
michael@0 155 pixman_fixed_t x;
michael@0 156 pixman_fixed_t y;
michael@0 157 pixman_fixed_t radius;
michael@0 158 };
michael@0 159
michael@0 160 struct radial_gradient
michael@0 161 {
michael@0 162 gradient_t common;
michael@0 163
michael@0 164 circle_t c1;
michael@0 165 circle_t c2;
michael@0 166
michael@0 167 circle_t delta;
michael@0 168 double a;
michael@0 169 double inva;
michael@0 170 double mindr;
michael@0 171 };
michael@0 172
michael@0 173 struct conical_gradient
michael@0 174 {
michael@0 175 gradient_t common;
michael@0 176 pixman_point_fixed_t center;
michael@0 177 double angle;
michael@0 178 };
michael@0 179
michael@0 180 struct bits_image
michael@0 181 {
michael@0 182 image_common_t common;
michael@0 183 pixman_format_code_t format;
michael@0 184 const pixman_indexed_t * indexed;
michael@0 185 int width;
michael@0 186 int height;
michael@0 187 uint32_t * bits;
michael@0 188 uint32_t * free_me;
michael@0 189 int rowstride; /* in number of uint32_t's */
michael@0 190
michael@0 191 fetch_scanline_t fetch_scanline_16;
michael@0 192
michael@0 193 fetch_scanline_t fetch_scanline_32;
michael@0 194 fetch_pixel_32_t fetch_pixel_32;
michael@0 195 store_scanline_t store_scanline_32;
michael@0 196
michael@0 197 fetch_scanline_t fetch_scanline_float;
michael@0 198 fetch_pixel_float_t fetch_pixel_float;
michael@0 199 store_scanline_t store_scanline_float;
michael@0 200
michael@0 201 store_scanline_t store_scanline_16;
michael@0 202
michael@0 203 /* Used for indirect access to the bits */
michael@0 204 pixman_read_memory_func_t read_func;
michael@0 205 pixman_write_memory_func_t write_func;
michael@0 206 };
michael@0 207
michael@0 208 union pixman_image
michael@0 209 {
michael@0 210 image_type_t type;
michael@0 211 image_common_t common;
michael@0 212 bits_image_t bits;
michael@0 213 gradient_t gradient;
michael@0 214 linear_gradient_t linear;
michael@0 215 conical_gradient_t conical;
michael@0 216 radial_gradient_t radial;
michael@0 217 solid_fill_t solid;
michael@0 218 };
michael@0 219
michael@0 220 typedef struct pixman_iter_t pixman_iter_t;
michael@0 221 typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask);
michael@0 222 typedef void (* pixman_iter_write_back_t) (pixman_iter_t *iter);
michael@0 223
michael@0 224 typedef enum
michael@0 225 {
michael@0 226 ITER_NARROW = (1 << 0),
michael@0 227
michael@0 228 /* "Localized alpha" is when the alpha channel is used only to compute
michael@0 229 * the alpha value of the destination. This means that the computation
michael@0 230 * of the RGB values of the result is independent of the alpha value.
michael@0 231 *
michael@0 232 * For example, the OVER operator has localized alpha for the
michael@0 233 * destination, because the RGB values of the result can be computed
michael@0 234 * without knowing the destination alpha. Similarly, ADD has localized
michael@0 235 * alpha for both source and destination because the RGB values of the
michael@0 236 * result can be computed without knowing the alpha value of source or
michael@0 237 * destination.
michael@0 238 *
michael@0 239 * When he destination is xRGB, this is useful knowledge, because then
michael@0 240 * we can treat it as if it were ARGB, which means in some cases we can
michael@0 241 * avoid copying it to a temporary buffer.
michael@0 242 */
michael@0 243 ITER_LOCALIZED_ALPHA = (1 << 1),
michael@0 244 ITER_IGNORE_ALPHA = (1 << 2),
michael@0 245 ITER_IGNORE_RGB = (1 << 3),
michael@0 246
michael@0 247 /* With the addition of ITER_16 we now have two flags that to represent
michael@0 248 * 3 pipelines. This means that there can be an invalid state when
michael@0 249 * both ITER_NARROW and ITER_16 are set. In this case
michael@0 250 * ITER_16 overrides NARROW and we should use the 16 bit pipeline.
michael@0 251 * Note: ITER_16 still has a 32 bit mask, which is a bit weird. */
michael@0 252 ITER_16 = (1 << 4)
michael@0 253 } iter_flags_t;
michael@0 254
michael@0 255 struct pixman_iter_t
michael@0 256 {
michael@0 257 /* These are initialized by _pixman_implementation_{src,dest}_init */
michael@0 258 pixman_image_t * image;
michael@0 259 uint32_t * buffer;
michael@0 260 int x, y;
michael@0 261 int width;
michael@0 262 int height;
michael@0 263 iter_flags_t iter_flags;
michael@0 264 uint32_t image_flags;
michael@0 265
michael@0 266 /* These function pointers are initialized by the implementation */
michael@0 267 pixman_iter_get_scanline_t get_scanline;
michael@0 268 pixman_iter_write_back_t write_back;
michael@0 269
michael@0 270 /* These fields are scratch data that implementations can use */
michael@0 271 void * data;
michael@0 272 uint8_t * bits;
michael@0 273 int stride;
michael@0 274 };
michael@0 275
michael@0 276 void
michael@0 277 _pixman_bits_image_setup_accessors (bits_image_t *image);
michael@0 278
michael@0 279 void
michael@0 280 _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter);
michael@0 281
michael@0 282 void
michael@0 283 _pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter);
michael@0 284
michael@0 285 void
michael@0 286 _pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
michael@0 287
michael@0 288 void
michael@0 289 _pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
michael@0 290
michael@0 291 void
michael@0 292 _pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter);
michael@0 293
michael@0 294 void
michael@0 295 _pixman_image_init (pixman_image_t *image);
michael@0 296
michael@0 297 pixman_bool_t
michael@0 298 _pixman_bits_image_init (pixman_image_t * image,
michael@0 299 pixman_format_code_t format,
michael@0 300 int width,
michael@0 301 int height,
michael@0 302 uint32_t * bits,
michael@0 303 int rowstride,
michael@0 304 pixman_bool_t clear);
michael@0 305 pixman_bool_t
michael@0 306 _pixman_image_fini (pixman_image_t *image);
michael@0 307
michael@0 308 pixman_image_t *
michael@0 309 _pixman_image_allocate (void);
michael@0 310
michael@0 311 pixman_bool_t
michael@0 312 _pixman_init_gradient (gradient_t * gradient,
michael@0 313 const pixman_gradient_stop_t *stops,
michael@0 314 int n_stops);
michael@0 315 void
michael@0 316 _pixman_image_reset_clip_region (pixman_image_t *image);
michael@0 317
michael@0 318 void
michael@0 319 _pixman_image_validate (pixman_image_t *image);
michael@0 320
michael@0 321 #define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul) \
michael@0 322 do \
michael@0 323 { \
michael@0 324 uint32_t *__bits__; \
michael@0 325 int __stride__; \
michael@0 326 \
michael@0 327 __bits__ = image->bits.bits; \
michael@0 328 __stride__ = image->bits.rowstride; \
michael@0 329 (out_stride) = \
michael@0 330 __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type); \
michael@0 331 (line) = \
michael@0 332 ((type *) __bits__) + (out_stride) * (y) + (mul) * (x); \
michael@0 333 } while (0)
michael@0 334
michael@0 335 /*
michael@0 336 * Gradient walker
michael@0 337 */
michael@0 338 typedef struct
michael@0 339 {
michael@0 340 uint32_t left_ag;
michael@0 341 uint32_t left_rb;
michael@0 342 uint32_t right_ag;
michael@0 343 uint32_t right_rb;
michael@0 344 pixman_fixed_t left_x;
michael@0 345 pixman_fixed_t right_x;
michael@0 346 pixman_fixed_t stepper;
michael@0 347
michael@0 348 pixman_gradient_stop_t *stops;
michael@0 349 int num_stops;
michael@0 350 pixman_repeat_t repeat;
michael@0 351
michael@0 352 pixman_bool_t need_reset;
michael@0 353 } pixman_gradient_walker_t;
michael@0 354
michael@0 355 void
michael@0 356 _pixman_gradient_walker_init (pixman_gradient_walker_t *walker,
michael@0 357 gradient_t * gradient,
michael@0 358 pixman_repeat_t repeat);
michael@0 359
michael@0 360 void
michael@0 361 _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker,
michael@0 362 pixman_fixed_48_16_t pos);
michael@0 363
michael@0 364 uint32_t
michael@0 365 _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker,
michael@0 366 pixman_fixed_48_16_t x);
michael@0 367
michael@0 368 /*
michael@0 369 * Edges
michael@0 370 */
michael@0 371
michael@0 372 #define MAX_ALPHA(n) ((1 << (n)) - 1)
michael@0 373 #define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) - 1)
michael@0 374 #define N_X_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) + 1)
michael@0 375
michael@0 376 #define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC (n))
michael@0 377 #define STEP_Y_BIG(n) (pixman_fixed_1 - (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
michael@0 378
michael@0 379 #define Y_FRAC_FIRST(n) (STEP_Y_BIG (n) / 2)
michael@0 380 #define Y_FRAC_LAST(n) (Y_FRAC_FIRST (n) + (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n))
michael@0 381
michael@0 382 #define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC (n))
michael@0 383 #define STEP_X_BIG(n) (pixman_fixed_1 - (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
michael@0 384
michael@0 385 #define X_FRAC_FIRST(n) (STEP_X_BIG (n) / 2)
michael@0 386 #define X_FRAC_LAST(n) (X_FRAC_FIRST (n) + (N_X_FRAC (n) - 1) * STEP_X_SMALL (n))
michael@0 387
michael@0 388 #define RENDER_SAMPLES_X(x, n) \
michael@0 389 ((n) == 1? 0 : (pixman_fixed_frac (x) + \
michael@0 390 X_FRAC_FIRST (n)) / STEP_X_SMALL (n))
michael@0 391
michael@0 392 void
michael@0 393 pixman_rasterize_edges_accessors (pixman_image_t *image,
michael@0 394 pixman_edge_t * l,
michael@0 395 pixman_edge_t * r,
michael@0 396 pixman_fixed_t t,
michael@0 397 pixman_fixed_t b);
michael@0 398
michael@0 399 /*
michael@0 400 * Implementations
michael@0 401 */
michael@0 402 typedef struct pixman_implementation_t pixman_implementation_t;
michael@0 403
michael@0 404 typedef struct
michael@0 405 {
michael@0 406 pixman_op_t op;
michael@0 407 pixman_image_t * src_image;
michael@0 408 pixman_image_t * mask_image;
michael@0 409 pixman_image_t * dest_image;
michael@0 410 int32_t src_x;
michael@0 411 int32_t src_y;
michael@0 412 int32_t mask_x;
michael@0 413 int32_t mask_y;
michael@0 414 int32_t dest_x;
michael@0 415 int32_t dest_y;
michael@0 416 int32_t width;
michael@0 417 int32_t height;
michael@0 418
michael@0 419 uint32_t src_flags;
michael@0 420 uint32_t mask_flags;
michael@0 421 uint32_t dest_flags;
michael@0 422 } pixman_composite_info_t;
michael@0 423
michael@0 424 #define PIXMAN_COMPOSITE_ARGS(info) \
michael@0 425 MAYBE_UNUSED pixman_op_t op = info->op; \
michael@0 426 MAYBE_UNUSED pixman_image_t * src_image = info->src_image; \
michael@0 427 MAYBE_UNUSED pixman_image_t * mask_image = info->mask_image; \
michael@0 428 MAYBE_UNUSED pixman_image_t * dest_image = info->dest_image; \
michael@0 429 MAYBE_UNUSED int32_t src_x = info->src_x; \
michael@0 430 MAYBE_UNUSED int32_t src_y = info->src_y; \
michael@0 431 MAYBE_UNUSED int32_t mask_x = info->mask_x; \
michael@0 432 MAYBE_UNUSED int32_t mask_y = info->mask_y; \
michael@0 433 MAYBE_UNUSED int32_t dest_x = info->dest_x; \
michael@0 434 MAYBE_UNUSED int32_t dest_y = info->dest_y; \
michael@0 435 MAYBE_UNUSED int32_t width = info->width; \
michael@0 436 MAYBE_UNUSED int32_t height = info->height
michael@0 437
michael@0 438 typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp,
michael@0 439 pixman_op_t op,
michael@0 440 uint32_t * dest,
michael@0 441 const uint32_t * src,
michael@0 442 const uint32_t * mask,
michael@0 443 int width);
michael@0 444
michael@0 445 typedef void (*pixman_combine_float_func_t) (pixman_implementation_t *imp,
michael@0 446 pixman_op_t op,
michael@0 447 float * dest,
michael@0 448 const float * src,
michael@0 449 const float * mask,
michael@0 450 int n_pixels);
michael@0 451
michael@0 452 typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp,
michael@0 453 pixman_composite_info_t *info);
michael@0 454 typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp,
michael@0 455 uint32_t * src_bits,
michael@0 456 uint32_t * dst_bits,
michael@0 457 int src_stride,
michael@0 458 int dst_stride,
michael@0 459 int src_bpp,
michael@0 460 int dst_bpp,
michael@0 461 int src_x,
michael@0 462 int src_y,
michael@0 463 int dest_x,
michael@0 464 int dest_y,
michael@0 465 int width,
michael@0 466 int height);
michael@0 467 typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp,
michael@0 468 uint32_t * bits,
michael@0 469 int stride,
michael@0 470 int bpp,
michael@0 471 int x,
michael@0 472 int y,
michael@0 473 int width,
michael@0 474 int height,
michael@0 475 uint32_t filler);
michael@0 476 typedef pixman_bool_t (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
michael@0 477 pixman_iter_t *iter);
michael@0 478
michael@0 479 void _pixman_setup_combiner_functions_16 (pixman_implementation_t *imp);
michael@0 480 void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
michael@0 481 void _pixman_setup_combiner_functions_float (pixman_implementation_t *imp);
michael@0 482
michael@0 483 typedef struct
michael@0 484 {
michael@0 485 pixman_op_t op;
michael@0 486 pixman_format_code_t src_format;
michael@0 487 uint32_t src_flags;
michael@0 488 pixman_format_code_t mask_format;
michael@0 489 uint32_t mask_flags;
michael@0 490 pixman_format_code_t dest_format;
michael@0 491 uint32_t dest_flags;
michael@0 492 pixman_composite_func_t func;
michael@0 493 } pixman_fast_path_t;
michael@0 494
michael@0 495 struct pixman_implementation_t
michael@0 496 {
michael@0 497 pixman_implementation_t * toplevel;
michael@0 498 pixman_implementation_t * fallback;
michael@0 499 const pixman_fast_path_t * fast_paths;
michael@0 500
michael@0 501 pixman_blt_func_t blt;
michael@0 502 pixman_fill_func_t fill;
michael@0 503 pixman_iter_init_func_t src_iter_init;
michael@0 504 pixman_iter_init_func_t dest_iter_init;
michael@0 505
michael@0 506 pixman_combine_32_func_t combine_16[PIXMAN_N_OPERATORS];
michael@0 507 pixman_combine_32_func_t combine_16_ca[PIXMAN_N_OPERATORS];
michael@0 508 pixman_combine_32_func_t combine_32[PIXMAN_N_OPERATORS];
michael@0 509 pixman_combine_32_func_t combine_32_ca[PIXMAN_N_OPERATORS];
michael@0 510 pixman_combine_float_func_t combine_float[PIXMAN_N_OPERATORS];
michael@0 511 pixman_combine_float_func_t combine_float_ca[PIXMAN_N_OPERATORS];
michael@0 512 };
michael@0 513
michael@0 514 uint32_t
michael@0 515 _pixman_image_get_solid (pixman_implementation_t *imp,
michael@0 516 pixman_image_t * image,
michael@0 517 pixman_format_code_t format);
michael@0 518
michael@0 519 pixman_implementation_t *
michael@0 520 _pixman_implementation_create (pixman_implementation_t *fallback,
michael@0 521 const pixman_fast_path_t *fast_paths);
michael@0 522
michael@0 523 void
michael@0 524 _pixman_implementation_lookup_composite (pixman_implementation_t *toplevel,
michael@0 525 pixman_op_t op,
michael@0 526 pixman_format_code_t src_format,
michael@0 527 uint32_t src_flags,
michael@0 528 pixman_format_code_t mask_format,
michael@0 529 uint32_t mask_flags,
michael@0 530 pixman_format_code_t dest_format,
michael@0 531 uint32_t dest_flags,
michael@0 532 pixman_implementation_t **out_imp,
michael@0 533 pixman_composite_func_t *out_func);
michael@0 534
michael@0 535 pixman_combine_32_func_t
michael@0 536 _pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
michael@0 537 pixman_op_t op,
michael@0 538 pixman_bool_t component_alpha,
michael@0 539 pixman_bool_t wide,
michael@0 540 pixman_bool_t rgb16);
michael@0 541
michael@0 542 pixman_bool_t
michael@0 543 _pixman_implementation_blt (pixman_implementation_t *imp,
michael@0 544 uint32_t * src_bits,
michael@0 545 uint32_t * dst_bits,
michael@0 546 int src_stride,
michael@0 547 int dst_stride,
michael@0 548 int src_bpp,
michael@0 549 int dst_bpp,
michael@0 550 int src_x,
michael@0 551 int src_y,
michael@0 552 int dest_x,
michael@0 553 int dest_y,
michael@0 554 int width,
michael@0 555 int height);
michael@0 556
michael@0 557 pixman_bool_t
michael@0 558 _pixman_implementation_fill (pixman_implementation_t *imp,
michael@0 559 uint32_t * bits,
michael@0 560 int stride,
michael@0 561 int bpp,
michael@0 562 int x,
michael@0 563 int y,
michael@0 564 int width,
michael@0 565 int height,
michael@0 566 uint32_t filler);
michael@0 567
michael@0 568 pixman_bool_t
michael@0 569 _pixman_implementation_src_iter_init (pixman_implementation_t *imp,
michael@0 570 pixman_iter_t *iter,
michael@0 571 pixman_image_t *image,
michael@0 572 int x,
michael@0 573 int y,
michael@0 574 int width,
michael@0 575 int height,
michael@0 576 uint8_t *buffer,
michael@0 577 iter_flags_t flags,
michael@0 578 uint32_t image_flags);
michael@0 579
michael@0 580 pixman_bool_t
michael@0 581 _pixman_implementation_dest_iter_init (pixman_implementation_t *imp,
michael@0 582 pixman_iter_t *iter,
michael@0 583 pixman_image_t *image,
michael@0 584 int x,
michael@0 585 int y,
michael@0 586 int width,
michael@0 587 int height,
michael@0 588 uint8_t *buffer,
michael@0 589 iter_flags_t flags,
michael@0 590 uint32_t image_flags);
michael@0 591
michael@0 592 /* Specific implementations */
michael@0 593 pixman_implementation_t *
michael@0 594 _pixman_implementation_create_general (void);
michael@0 595
michael@0 596 pixman_implementation_t *
michael@0 597 _pixman_implementation_create_fast_path (pixman_implementation_t *fallback);
michael@0 598
michael@0 599 pixman_implementation_t *
michael@0 600 _pixman_implementation_create_noop (pixman_implementation_t *fallback);
michael@0 601
michael@0 602 #if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI
michael@0 603 pixman_implementation_t *
michael@0 604 _pixman_implementation_create_mmx (pixman_implementation_t *fallback);
michael@0 605 #endif
michael@0 606
michael@0 607 #ifdef USE_SSE2
michael@0 608 pixman_implementation_t *
michael@0 609 _pixman_implementation_create_sse2 (pixman_implementation_t *fallback);
michael@0 610 #endif
michael@0 611
michael@0 612 #ifdef USE_ARM_SIMD
michael@0 613 pixman_implementation_t *
michael@0 614 _pixman_implementation_create_arm_simd (pixman_implementation_t *fallback);
michael@0 615 #endif
michael@0 616
michael@0 617 #ifdef USE_ARM_NEON
michael@0 618 pixman_implementation_t *
michael@0 619 _pixman_implementation_create_arm_neon (pixman_implementation_t *fallback);
michael@0 620 #endif
michael@0 621
michael@0 622 #ifdef USE_MIPS_DSPR2
michael@0 623 pixman_implementation_t *
michael@0 624 _pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback);
michael@0 625 #endif
michael@0 626
michael@0 627 #ifdef USE_VMX
michael@0 628 pixman_implementation_t *
michael@0 629 _pixman_implementation_create_vmx (pixman_implementation_t *fallback);
michael@0 630 #endif
michael@0 631
michael@0 632 pixman_bool_t
michael@0 633 _pixman_implementation_disabled (const char *name);
michael@0 634
michael@0 635 pixman_implementation_t *
michael@0 636 _pixman_x86_get_implementations (pixman_implementation_t *imp);
michael@0 637
michael@0 638 pixman_implementation_t *
michael@0 639 _pixman_arm_get_implementations (pixman_implementation_t *imp);
michael@0 640
michael@0 641 pixman_implementation_t *
michael@0 642 _pixman_ppc_get_implementations (pixman_implementation_t *imp);
michael@0 643
michael@0 644 pixman_implementation_t *
michael@0 645 _pixman_mips_get_implementations (pixman_implementation_t *imp);
michael@0 646
michael@0 647 pixman_implementation_t *
michael@0 648 _pixman_choose_implementation (void);
michael@0 649
michael@0 650 pixman_bool_t
michael@0 651 _pixman_disabled (const char *name);
michael@0 652
michael@0 653
michael@0 654 /*
michael@0 655 * Utilities
michael@0 656 */
michael@0 657 pixman_bool_t
michael@0 658 _pixman_compute_composite_region32 (pixman_region32_t * region,
michael@0 659 pixman_image_t * src_image,
michael@0 660 pixman_image_t * mask_image,
michael@0 661 pixman_image_t * dest_image,
michael@0 662 int32_t src_x,
michael@0 663 int32_t src_y,
michael@0 664 int32_t mask_x,
michael@0 665 int32_t mask_y,
michael@0 666 int32_t dest_x,
michael@0 667 int32_t dest_y,
michael@0 668 int32_t width,
michael@0 669 int32_t height);
michael@0 670 uint32_t *
michael@0 671 _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask);
michael@0 672
michael@0 673 /* These "formats" all have depth 0, so they
michael@0 674 * will never clash with any real ones
michael@0 675 */
michael@0 676 #define PIXMAN_null PIXMAN_FORMAT (0, 0, 0, 0, 0, 0)
michael@0 677 #define PIXMAN_solid PIXMAN_FORMAT (0, 1, 0, 0, 0, 0)
michael@0 678 #define PIXMAN_pixbuf PIXMAN_FORMAT (0, 2, 0, 0, 0, 0)
michael@0 679 #define PIXMAN_rpixbuf PIXMAN_FORMAT (0, 3, 0, 0, 0, 0)
michael@0 680 #define PIXMAN_unknown PIXMAN_FORMAT (0, 4, 0, 0, 0, 0)
michael@0 681 #define PIXMAN_any PIXMAN_FORMAT (0, 5, 0, 0, 0, 0)
michael@0 682
michael@0 683 #define PIXMAN_OP_any (PIXMAN_N_OPERATORS + 1)
michael@0 684
michael@0 685 #define FAST_PATH_ID_TRANSFORM (1 << 0)
michael@0 686 #define FAST_PATH_NO_ALPHA_MAP (1 << 1)
michael@0 687 #define FAST_PATH_NO_CONVOLUTION_FILTER (1 << 2)
michael@0 688 #define FAST_PATH_NO_PAD_REPEAT (1 << 3)
michael@0 689 #define FAST_PATH_NO_REFLECT_REPEAT (1 << 4)
michael@0 690 #define FAST_PATH_NO_ACCESSORS (1 << 5)
michael@0 691 #define FAST_PATH_NARROW_FORMAT (1 << 6)
michael@0 692 #define FAST_PATH_COMPONENT_ALPHA (1 << 8)
michael@0 693 #define FAST_PATH_SAMPLES_OPAQUE (1 << 7)
michael@0 694 #define FAST_PATH_UNIFIED_ALPHA (1 << 9)
michael@0 695 #define FAST_PATH_SCALE_TRANSFORM (1 << 10)
michael@0 696 #define FAST_PATH_NEAREST_FILTER (1 << 11)
michael@0 697 #define FAST_PATH_HAS_TRANSFORM (1 << 12)
michael@0 698 #define FAST_PATH_IS_OPAQUE (1 << 13)
michael@0 699 #define FAST_PATH_NO_NORMAL_REPEAT (1 << 14)
michael@0 700 #define FAST_PATH_NO_NONE_REPEAT (1 << 15)
michael@0 701 #define FAST_PATH_X_UNIT_POSITIVE (1 << 16)
michael@0 702 #define FAST_PATH_AFFINE_TRANSFORM (1 << 17)
michael@0 703 #define FAST_PATH_Y_UNIT_ZERO (1 << 18)
michael@0 704 #define FAST_PATH_BILINEAR_FILTER (1 << 19)
michael@0 705 #define FAST_PATH_ROTATE_90_TRANSFORM (1 << 20)
michael@0 706 #define FAST_PATH_ROTATE_180_TRANSFORM (1 << 21)
michael@0 707 #define FAST_PATH_ROTATE_270_TRANSFORM (1 << 22)
michael@0 708 #define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST (1 << 23)
michael@0 709 #define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR (1 << 24)
michael@0 710 #define FAST_PATH_BITS_IMAGE (1 << 25)
michael@0 711 #define FAST_PATH_SEPARABLE_CONVOLUTION_FILTER (1 << 26)
michael@0 712 #define FAST_PATH_16_FORMAT (1 << 27)
michael@0 713
michael@0 714 #define FAST_PATH_PAD_REPEAT \
michael@0 715 (FAST_PATH_NO_NONE_REPEAT | \
michael@0 716 FAST_PATH_NO_NORMAL_REPEAT | \
michael@0 717 FAST_PATH_NO_REFLECT_REPEAT)
michael@0 718
michael@0 719 #define FAST_PATH_NORMAL_REPEAT \
michael@0 720 (FAST_PATH_NO_NONE_REPEAT | \
michael@0 721 FAST_PATH_NO_PAD_REPEAT | \
michael@0 722 FAST_PATH_NO_REFLECT_REPEAT)
michael@0 723
michael@0 724 #define FAST_PATH_NONE_REPEAT \
michael@0 725 (FAST_PATH_NO_NORMAL_REPEAT | \
michael@0 726 FAST_PATH_NO_PAD_REPEAT | \
michael@0 727 FAST_PATH_NO_REFLECT_REPEAT)
michael@0 728
michael@0 729 #define FAST_PATH_REFLECT_REPEAT \
michael@0 730 (FAST_PATH_NO_NONE_REPEAT | \
michael@0 731 FAST_PATH_NO_NORMAL_REPEAT | \
michael@0 732 FAST_PATH_NO_PAD_REPEAT)
michael@0 733
michael@0 734 #define FAST_PATH_STANDARD_FLAGS \
michael@0 735 (FAST_PATH_NO_CONVOLUTION_FILTER | \
michael@0 736 FAST_PATH_NO_ACCESSORS | \
michael@0 737 FAST_PATH_NO_ALPHA_MAP | \
michael@0 738 FAST_PATH_NARROW_FORMAT)
michael@0 739
michael@0 740 #define FAST_PATH_STD_DEST_FLAGS \
michael@0 741 (FAST_PATH_NO_ACCESSORS | \
michael@0 742 FAST_PATH_NO_ALPHA_MAP | \
michael@0 743 FAST_PATH_NARROW_FORMAT)
michael@0 744
michael@0 745 #define SOURCE_FLAGS(format) \
michael@0 746 (FAST_PATH_STANDARD_FLAGS | \
michael@0 747 ((PIXMAN_ ## format == PIXMAN_solid) ? \
michael@0 748 0 : (FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | FAST_PATH_NEAREST_FILTER | FAST_PATH_ID_TRANSFORM)))
michael@0 749
michael@0 750 #define MASK_FLAGS(format, extra) \
michael@0 751 ((PIXMAN_ ## format == PIXMAN_null) ? 0 : (SOURCE_FLAGS (format) | extra))
michael@0 752
michael@0 753 #define FAST_PATH(op, src, src_flags, mask, mask_flags, dest, dest_flags, func) \
michael@0 754 PIXMAN_OP_ ## op, \
michael@0 755 PIXMAN_ ## src, \
michael@0 756 src_flags, \
michael@0 757 PIXMAN_ ## mask, \
michael@0 758 mask_flags, \
michael@0 759 PIXMAN_ ## dest, \
michael@0 760 dest_flags, \
michael@0 761 func
michael@0 762
michael@0 763 #define PIXMAN_STD_FAST_PATH(op, src, mask, dest, func) \
michael@0 764 { FAST_PATH ( \
michael@0 765 op, \
michael@0 766 src, SOURCE_FLAGS (src), \
michael@0 767 mask, MASK_FLAGS (mask, FAST_PATH_UNIFIED_ALPHA), \
michael@0 768 dest, FAST_PATH_STD_DEST_FLAGS, \
michael@0 769 func) }
michael@0 770
michael@0 771 #define PIXMAN_STD_FAST_PATH_CA(op, src, mask, dest, func) \
michael@0 772 { FAST_PATH ( \
michael@0 773 op, \
michael@0 774 src, SOURCE_FLAGS (src), \
michael@0 775 mask, MASK_FLAGS (mask, FAST_PATH_COMPONENT_ALPHA), \
michael@0 776 dest, FAST_PATH_STD_DEST_FLAGS, \
michael@0 777 func) }
michael@0 778
michael@0 779 extern pixman_implementation_t *global_implementation;
michael@0 780
michael@0 781 static force_inline pixman_implementation_t *
michael@0 782 get_implementation (void)
michael@0 783 {
michael@0 784 #ifndef TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR
michael@0 785 if (!global_implementation)
michael@0 786 global_implementation = _pixman_choose_implementation ();
michael@0 787 #endif
michael@0 788 return global_implementation;
michael@0 789 }
michael@0 790
michael@0 791 /* This function is exported for the sake of the test suite and not part
michael@0 792 * of the ABI.
michael@0 793 */
michael@0 794 PIXMAN_EXPORT pixman_implementation_t *
michael@0 795 _pixman_internal_only_get_implementation (void);
michael@0 796
michael@0 797 /* Memory allocation helpers */
michael@0 798 void *
michael@0 799 pixman_malloc_ab (unsigned int n, unsigned int b);
michael@0 800
michael@0 801 void *
michael@0 802 pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
michael@0 803
michael@0 804 pixman_bool_t
michael@0 805 _pixman_multiply_overflows_size (size_t a, size_t b);
michael@0 806
michael@0 807 pixman_bool_t
michael@0 808 _pixman_multiply_overflows_int (unsigned int a, unsigned int b);
michael@0 809
michael@0 810 pixman_bool_t
michael@0 811 _pixman_addition_overflows_int (unsigned int a, unsigned int b);
michael@0 812
michael@0 813 /* Compositing utilities */
michael@0 814 void
michael@0 815 pixman_expand_to_float (argb_t *dst,
michael@0 816 const uint32_t *src,
michael@0 817 pixman_format_code_t format,
michael@0 818 int width);
michael@0 819
michael@0 820 void
michael@0 821 pixman_contract_from_float (uint32_t *dst,
michael@0 822 const argb_t *src,
michael@0 823 int width);
michael@0 824
michael@0 825 /* Region Helpers */
michael@0 826 pixman_bool_t
michael@0 827 pixman_region32_copy_from_region16 (pixman_region32_t *dst,
michael@0 828 pixman_region16_t *src);
michael@0 829
michael@0 830 pixman_bool_t
michael@0 831 pixman_region16_copy_from_region32 (pixman_region16_t *dst,
michael@0 832 pixman_region32_t *src);
michael@0 833
michael@0 834 /* Doubly linked lists */
michael@0 835 typedef struct pixman_link_t pixman_link_t;
michael@0 836 struct pixman_link_t
michael@0 837 {
michael@0 838 pixman_link_t *next;
michael@0 839 pixman_link_t *prev;
michael@0 840 };
michael@0 841
michael@0 842 typedef struct pixman_list_t pixman_list_t;
michael@0 843 struct pixman_list_t
michael@0 844 {
michael@0 845 pixman_link_t *head;
michael@0 846 pixman_link_t *tail;
michael@0 847 };
michael@0 848
michael@0 849 static force_inline void
michael@0 850 pixman_list_init (pixman_list_t *list)
michael@0 851 {
michael@0 852 list->head = (pixman_link_t *)list;
michael@0 853 list->tail = (pixman_link_t *)list;
michael@0 854 }
michael@0 855
michael@0 856 static force_inline void
michael@0 857 pixman_list_prepend (pixman_list_t *list, pixman_link_t *link)
michael@0 858 {
michael@0 859 link->next = list->head;
michael@0 860 link->prev = (pixman_link_t *)list;
michael@0 861 list->head->prev = link;
michael@0 862 list->head = link;
michael@0 863 }
michael@0 864
michael@0 865 static force_inline void
michael@0 866 pixman_list_unlink (pixman_link_t *link)
michael@0 867 {
michael@0 868 link->prev->next = link->next;
michael@0 869 link->next->prev = link->prev;
michael@0 870 }
michael@0 871
michael@0 872 static force_inline void
michael@0 873 pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link)
michael@0 874 {
michael@0 875 pixman_list_unlink (link);
michael@0 876 pixman_list_prepend (list, link);
michael@0 877 }
michael@0 878
michael@0 879 /* Misc macros */
michael@0 880
michael@0 881 #ifndef FALSE
michael@0 882 # define FALSE 0
michael@0 883 #endif
michael@0 884
michael@0 885 #ifndef TRUE
michael@0 886 # define TRUE 1
michael@0 887 #endif
michael@0 888
michael@0 889 #ifndef MIN
michael@0 890 # define MIN(a, b) ((a < b) ? a : b)
michael@0 891 #endif
michael@0 892
michael@0 893 #ifndef MAX
michael@0 894 # define MAX(a, b) ((a > b) ? a : b)
michael@0 895 #endif
michael@0 896
michael@0 897 /* Integer division that rounds towards -infinity */
michael@0 898 #define DIV(a, b) \
michael@0 899 ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \
michael@0 900 ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
michael@0 901
michael@0 902 /* Modulus that produces the remainder wrt. DIV */
michael@0 903 #define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
michael@0 904
michael@0 905 #define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v)))
michael@0 906
michael@0 907 /* Conversion between 8888 and 0565 */
michael@0 908
michael@0 909 static force_inline uint16_t
michael@0 910 convert_8888_to_0565 (uint32_t s)
michael@0 911 {
michael@0 912 /* The following code can be compiled into just 4 instructions on ARM */
michael@0 913 uint32_t a, b;
michael@0 914 a = (s >> 3) & 0x1F001F;
michael@0 915 b = s & 0xFC00;
michael@0 916 a |= a >> 5;
michael@0 917 a |= b >> 5;
michael@0 918 return (uint16_t)a;
michael@0 919 }
michael@0 920
michael@0 921 static force_inline uint32_t
michael@0 922 convert_0565_to_0888 (uint16_t s)
michael@0 923 {
michael@0 924 return (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) |
michael@0 925 ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) |
michael@0 926 ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)));
michael@0 927 }
michael@0 928
michael@0 929 static force_inline uint32_t
michael@0 930 convert_0565_to_8888 (uint16_t s)
michael@0 931 {
michael@0 932 return convert_0565_to_0888 (s) | 0xff000000;
michael@0 933 }
michael@0 934
michael@0 935 /* Trivial versions that are useful in macros */
michael@0 936
michael@0 937 static force_inline uint32_t
michael@0 938 convert_8888_to_8888 (uint32_t s)
michael@0 939 {
michael@0 940 return s;
michael@0 941 }
michael@0 942
michael@0 943 static force_inline uint32_t
michael@0 944 convert_x888_to_8888 (uint32_t s)
michael@0 945 {
michael@0 946 return s | 0xff000000;
michael@0 947 }
michael@0 948
michael@0 949 static force_inline uint16_t
michael@0 950 convert_0565_to_0565 (uint16_t s)
michael@0 951 {
michael@0 952 return s;
michael@0 953 }
michael@0 954
michael@0 955 #define PIXMAN_FORMAT_IS_WIDE(f) \
michael@0 956 (PIXMAN_FORMAT_A (f) > 8 || \
michael@0 957 PIXMAN_FORMAT_R (f) > 8 || \
michael@0 958 PIXMAN_FORMAT_G (f) > 8 || \
michael@0 959 PIXMAN_FORMAT_B (f) > 8 || \
michael@0 960 PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB)
michael@0 961
michael@0 962 #ifdef WORDS_BIGENDIAN
michael@0 963 # define SCREEN_SHIFT_LEFT(x,n) ((x) << (n))
michael@0 964 # define SCREEN_SHIFT_RIGHT(x,n) ((x) >> (n))
michael@0 965 #else
michael@0 966 # define SCREEN_SHIFT_LEFT(x,n) ((x) >> (n))
michael@0 967 # define SCREEN_SHIFT_RIGHT(x,n) ((x) << (n))
michael@0 968 #endif
michael@0 969
michael@0 970 static force_inline uint32_t
michael@0 971 unorm_to_unorm (uint32_t val, int from_bits, int to_bits)
michael@0 972 {
michael@0 973 uint32_t result;
michael@0 974
michael@0 975 if (from_bits == 0)
michael@0 976 return 0;
michael@0 977
michael@0 978 /* Delete any extra bits */
michael@0 979 val &= ((1 << from_bits) - 1);
michael@0 980
michael@0 981 if (from_bits >= to_bits)
michael@0 982 return val >> (from_bits - to_bits);
michael@0 983
michael@0 984 /* Start out with the high bit of val in the high bit of result. */
michael@0 985 result = val << (to_bits - from_bits);
michael@0 986
michael@0 987 /* Copy the bits in result, doubling the number of bits each time, until
michael@0 988 * we fill all to_bits. Unrolled manually because from_bits and to_bits
michael@0 989 * are usually known statically, so the compiler can turn all of this
michael@0 990 * into a few shifts.
michael@0 991 */
michael@0 992 #define REPLICATE() \
michael@0 993 do \
michael@0 994 { \
michael@0 995 if (from_bits < to_bits) \
michael@0 996 { \
michael@0 997 result |= result >> from_bits; \
michael@0 998 \
michael@0 999 from_bits *= 2; \
michael@0 1000 } \
michael@0 1001 } \
michael@0 1002 while (0)
michael@0 1003
michael@0 1004 REPLICATE();
michael@0 1005 REPLICATE();
michael@0 1006 REPLICATE();
michael@0 1007 REPLICATE();
michael@0 1008 REPLICATE();
michael@0 1009
michael@0 1010 return result;
michael@0 1011 }
michael@0 1012
michael@0 1013 uint16_t pixman_float_to_unorm (float f, int n_bits);
michael@0 1014 float pixman_unorm_to_float (uint16_t u, int n_bits);
michael@0 1015
michael@0 1016 /*
michael@0 1017 * Various debugging code
michael@0 1018 */
michael@0 1019
michael@0 1020 #undef DEBUG
michael@0 1021
michael@0 1022 #define COMPILE_TIME_ASSERT(x) \
michael@0 1023 do { typedef int compile_time_assertion [(x)?1:-1]; } while (0)
michael@0 1024
michael@0 1025 /* Turn on debugging depending on what type of release this is
michael@0 1026 */
michael@0 1027 #if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1))
michael@0 1028
michael@0 1029 /* Debugging gets turned on for development releases because these
michael@0 1030 * are the things that end up in bleeding edge distributions such
michael@0 1031 * as Rawhide etc.
michael@0 1032 *
michael@0 1033 * For performance reasons we don't turn it on for stable releases or
michael@0 1034 * random git checkouts. (Random git checkouts are often used for
michael@0 1035 * performance work).
michael@0 1036 */
michael@0 1037
michael@0 1038 # define DEBUG
michael@0 1039
michael@0 1040 #endif
michael@0 1041
michael@0 1042 #ifdef DEBUG
michael@0 1043
michael@0 1044 void
michael@0 1045 _pixman_log_error (const char *function, const char *message);
michael@0 1046
michael@0 1047 #define return_if_fail(expr) \
michael@0 1048 do \
michael@0 1049 { \
michael@0 1050 if (!(expr)) \
michael@0 1051 { \
michael@0 1052 _pixman_log_error (FUNC, "The expression " # expr " was false"); \
michael@0 1053 return; \
michael@0 1054 } \
michael@0 1055 } \
michael@0 1056 while (0)
michael@0 1057
michael@0 1058 #define return_val_if_fail(expr, retval) \
michael@0 1059 do \
michael@0 1060 { \
michael@0 1061 if (!(expr)) \
michael@0 1062 { \
michael@0 1063 _pixman_log_error (FUNC, "The expression " # expr " was false"); \
michael@0 1064 return (retval); \
michael@0 1065 } \
michael@0 1066 } \
michael@0 1067 while (0)
michael@0 1068
michael@0 1069 #define critical_if_fail(expr) \
michael@0 1070 do \
michael@0 1071 { \
michael@0 1072 if (!(expr)) \
michael@0 1073 _pixman_log_error (FUNC, "The expression " # expr " was false"); \
michael@0 1074 } \
michael@0 1075 while (0)
michael@0 1076
michael@0 1077
michael@0 1078 #else
michael@0 1079
michael@0 1080 #define _pixman_log_error(f,m) do { } while (0)
michael@0 1081
michael@0 1082 #define return_if_fail(expr) \
michael@0 1083 do \
michael@0 1084 { \
michael@0 1085 if (!(expr)) \
michael@0 1086 return; \
michael@0 1087 } \
michael@0 1088 while (0)
michael@0 1089
michael@0 1090 #define return_val_if_fail(expr, retval) \
michael@0 1091 do \
michael@0 1092 { \
michael@0 1093 if (!(expr)) \
michael@0 1094 return (retval); \
michael@0 1095 } \
michael@0 1096 while (0)
michael@0 1097
michael@0 1098 #define critical_if_fail(expr) \
michael@0 1099 do \
michael@0 1100 { \
michael@0 1101 } \
michael@0 1102 while (0)
michael@0 1103 #endif
michael@0 1104
michael@0 1105 /*
michael@0 1106 * Matrix
michael@0 1107 */
michael@0 1108
michael@0 1109 typedef struct { pixman_fixed_48_16_t v[3]; } pixman_vector_48_16_t;
michael@0 1110
michael@0 1111 pixman_bool_t
michael@0 1112 pixman_transform_point_31_16 (const pixman_transform_t *t,
michael@0 1113 const pixman_vector_48_16_t *v,
michael@0 1114 pixman_vector_48_16_t *result);
michael@0 1115
michael@0 1116 void
michael@0 1117 pixman_transform_point_31_16_3d (const pixman_transform_t *t,
michael@0 1118 const pixman_vector_48_16_t *v,
michael@0 1119 pixman_vector_48_16_t *result);
michael@0 1120
michael@0 1121 void
michael@0 1122 pixman_transform_point_31_16_affine (const pixman_transform_t *t,
michael@0 1123 const pixman_vector_48_16_t *v,
michael@0 1124 pixman_vector_48_16_t *result);
michael@0 1125
michael@0 1126 /*
michael@0 1127 * Timers
michael@0 1128 */
michael@0 1129
michael@0 1130 #ifdef PIXMAN_TIMERS
michael@0 1131
michael@0 1132 static inline uint64_t
michael@0 1133 oil_profile_stamp_rdtsc (void)
michael@0 1134 {
michael@0 1135 uint32_t hi, lo;
michael@0 1136
michael@0 1137 __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi));
michael@0 1138
michael@0 1139 return lo | (((uint64_t)hi) << 32);
michael@0 1140 }
michael@0 1141
michael@0 1142 #define OIL_STAMP oil_profile_stamp_rdtsc
michael@0 1143
michael@0 1144 typedef struct pixman_timer_t pixman_timer_t;
michael@0 1145
michael@0 1146 struct pixman_timer_t
michael@0 1147 {
michael@0 1148 int initialized;
michael@0 1149 const char * name;
michael@0 1150 uint64_t n_times;
michael@0 1151 uint64_t total;
michael@0 1152 pixman_timer_t *next;
michael@0 1153 };
michael@0 1154
michael@0 1155 extern int timer_defined;
michael@0 1156
michael@0 1157 void pixman_timer_register (pixman_timer_t *timer);
michael@0 1158
michael@0 1159 #define TIMER_BEGIN(tname) \
michael@0 1160 { \
michael@0 1161 static pixman_timer_t timer ## tname; \
michael@0 1162 uint64_t begin ## tname; \
michael@0 1163 \
michael@0 1164 if (!timer ## tname.initialized) \
michael@0 1165 { \
michael@0 1166 timer ## tname.initialized = 1; \
michael@0 1167 timer ## tname.name = # tname; \
michael@0 1168 pixman_timer_register (&timer ## tname); \
michael@0 1169 } \
michael@0 1170 \
michael@0 1171 timer ## tname.n_times++; \
michael@0 1172 begin ## tname = OIL_STAMP ();
michael@0 1173
michael@0 1174 #define TIMER_END(tname) \
michael@0 1175 timer ## tname.total += OIL_STAMP () - begin ## tname; \
michael@0 1176 }
michael@0 1177
michael@0 1178 #else
michael@0 1179
michael@0 1180 #define TIMER_BEGIN(tname)
michael@0 1181 #define TIMER_END(tname)
michael@0 1182
michael@0 1183 #endif /* PIXMAN_TIMERS */
michael@0 1184
michael@0 1185 #endif /* __ASSEMBLER__ */
michael@0 1186
michael@0 1187 #endif /* PIXMAN_PRIVATE_H */

mercurial