michael@0: #ifndef PIXMAN_PRIVATE_H michael@0: #define PIXMAN_PRIVATE_H michael@0: michael@0: /* michael@0: * The defines which are shared between C and assembly code michael@0: */ michael@0: michael@0: /* bilinear interpolation precision (must be <= 8) */ michael@0: #ifndef MOZILLA_VERSION michael@0: #error "Need mozilla headers" michael@0: #endif michael@0: #ifdef MOZ_GFX_OPTIMIZE_MOBILE michael@0: #define LOW_QUALITY_INTERPOLATION michael@0: #define LOWER_QUALITY_INTERPOLATION michael@0: #define BILINEAR_INTERPOLATION_BITS 4 michael@0: #else michael@0: #define BILINEAR_INTERPOLATION_BITS 7 michael@0: #endif michael@0: #define BILINEAR_INTERPOLATION_RANGE (1 << BILINEAR_INTERPOLATION_BITS) michael@0: michael@0: /* michael@0: * C specific part michael@0: */ michael@0: michael@0: #ifndef __ASSEMBLER__ michael@0: michael@0: #ifndef PACKAGE michael@0: # error config.h must be included before pixman-private.h michael@0: #endif michael@0: michael@0: #define PIXMAN_DISABLE_DEPRECATED michael@0: #define PIXMAN_USE_INTERNAL_API michael@0: michael@0: #include "pixman.h" michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "pixman-compiler.h" michael@0: michael@0: /* michael@0: * Images michael@0: */ michael@0: typedef struct image_common image_common_t; michael@0: typedef struct solid_fill solid_fill_t; michael@0: typedef struct gradient gradient_t; michael@0: typedef struct linear_gradient linear_gradient_t; michael@0: typedef struct horizontal_gradient horizontal_gradient_t; michael@0: typedef struct vertical_gradient vertical_gradient_t; michael@0: typedef struct conical_gradient conical_gradient_t; michael@0: typedef struct radial_gradient radial_gradient_t; michael@0: typedef struct bits_image bits_image_t; michael@0: typedef struct circle circle_t; michael@0: michael@0: typedef struct argb_t argb_t; michael@0: michael@0: struct argb_t michael@0: { michael@0: float a; michael@0: float r; michael@0: float g; michael@0: float b; michael@0: }; michael@0: michael@0: typedef void (*fetch_scanline_t) (pixman_image_t *image, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: uint32_t *buffer, michael@0: const uint32_t *mask); michael@0: michael@0: typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image, michael@0: int x, michael@0: int y); michael@0: michael@0: typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image, michael@0: int x, michael@0: int y); michael@0: michael@0: typedef void (*store_scanline_t) (bits_image_t * image, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: const uint32_t *values); michael@0: michael@0: typedef enum michael@0: { michael@0: BITS, michael@0: LINEAR, michael@0: CONICAL, michael@0: RADIAL, michael@0: SOLID michael@0: } image_type_t; michael@0: michael@0: typedef void (*property_changed_func_t) (pixman_image_t *image); michael@0: michael@0: struct image_common michael@0: { michael@0: image_type_t type; michael@0: int32_t ref_count; michael@0: pixman_region32_t clip_region; michael@0: int32_t alpha_count; /* How many times this image is being used as an alpha map */ michael@0: pixman_bool_t have_clip_region; /* FALSE if there is no clip */ michael@0: pixman_bool_t client_clip; /* Whether the source clip was michael@0: set by a client */ michael@0: pixman_bool_t clip_sources; /* Whether the clip applies when michael@0: * the image is used as a source michael@0: */ michael@0: pixman_bool_t dirty; michael@0: pixman_transform_t * transform; michael@0: pixman_repeat_t repeat; michael@0: pixman_filter_t filter; michael@0: pixman_fixed_t * filter_params; michael@0: int n_filter_params; michael@0: bits_image_t * alpha_map; michael@0: int alpha_origin_x; michael@0: int alpha_origin_y; michael@0: pixman_bool_t component_alpha; michael@0: property_changed_func_t property_changed; michael@0: michael@0: pixman_image_destroy_func_t destroy_func; michael@0: void * destroy_data; michael@0: michael@0: uint32_t flags; michael@0: pixman_format_code_t extended_format_code; michael@0: }; michael@0: michael@0: struct solid_fill michael@0: { michael@0: image_common_t common; michael@0: pixman_color_t color; michael@0: michael@0: uint32_t color_32; michael@0: argb_t color_float; michael@0: }; michael@0: michael@0: struct gradient michael@0: { michael@0: image_common_t common; michael@0: int n_stops; michael@0: pixman_gradient_stop_t *stops; michael@0: }; michael@0: michael@0: struct linear_gradient michael@0: { michael@0: gradient_t common; michael@0: pixman_point_fixed_t p1; michael@0: pixman_point_fixed_t p2; michael@0: }; michael@0: michael@0: struct circle michael@0: { michael@0: pixman_fixed_t x; michael@0: pixman_fixed_t y; michael@0: pixman_fixed_t radius; michael@0: }; michael@0: michael@0: struct radial_gradient michael@0: { michael@0: gradient_t common; michael@0: michael@0: circle_t c1; michael@0: circle_t c2; michael@0: michael@0: circle_t delta; michael@0: double a; michael@0: double inva; michael@0: double mindr; michael@0: }; michael@0: michael@0: struct conical_gradient michael@0: { michael@0: gradient_t common; michael@0: pixman_point_fixed_t center; michael@0: double angle; michael@0: }; michael@0: michael@0: struct bits_image michael@0: { michael@0: image_common_t common; michael@0: pixman_format_code_t format; michael@0: const pixman_indexed_t * indexed; michael@0: int width; michael@0: int height; michael@0: uint32_t * bits; michael@0: uint32_t * free_me; michael@0: int rowstride; /* in number of uint32_t's */ michael@0: michael@0: fetch_scanline_t fetch_scanline_16; michael@0: michael@0: fetch_scanline_t fetch_scanline_32; michael@0: fetch_pixel_32_t fetch_pixel_32; michael@0: store_scanline_t store_scanline_32; michael@0: michael@0: fetch_scanline_t fetch_scanline_float; michael@0: fetch_pixel_float_t fetch_pixel_float; michael@0: store_scanline_t store_scanline_float; michael@0: michael@0: store_scanline_t store_scanline_16; michael@0: michael@0: /* Used for indirect access to the bits */ michael@0: pixman_read_memory_func_t read_func; michael@0: pixman_write_memory_func_t write_func; michael@0: }; michael@0: michael@0: union pixman_image michael@0: { michael@0: image_type_t type; michael@0: image_common_t common; michael@0: bits_image_t bits; michael@0: gradient_t gradient; michael@0: linear_gradient_t linear; michael@0: conical_gradient_t conical; michael@0: radial_gradient_t radial; michael@0: solid_fill_t solid; michael@0: }; michael@0: michael@0: typedef struct pixman_iter_t pixman_iter_t; michael@0: typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask); michael@0: typedef void (* pixman_iter_write_back_t) (pixman_iter_t *iter); michael@0: michael@0: typedef enum michael@0: { michael@0: ITER_NARROW = (1 << 0), michael@0: michael@0: /* "Localized alpha" is when the alpha channel is used only to compute michael@0: * the alpha value of the destination. This means that the computation michael@0: * of the RGB values of the result is independent of the alpha value. michael@0: * michael@0: * For example, the OVER operator has localized alpha for the michael@0: * destination, because the RGB values of the result can be computed michael@0: * without knowing the destination alpha. Similarly, ADD has localized michael@0: * alpha for both source and destination because the RGB values of the michael@0: * result can be computed without knowing the alpha value of source or michael@0: * destination. michael@0: * michael@0: * When he destination is xRGB, this is useful knowledge, because then michael@0: * we can treat it as if it were ARGB, which means in some cases we can michael@0: * avoid copying it to a temporary buffer. michael@0: */ michael@0: ITER_LOCALIZED_ALPHA = (1 << 1), michael@0: ITER_IGNORE_ALPHA = (1 << 2), michael@0: ITER_IGNORE_RGB = (1 << 3), michael@0: michael@0: /* With the addition of ITER_16 we now have two flags that to represent michael@0: * 3 pipelines. This means that there can be an invalid state when michael@0: * both ITER_NARROW and ITER_16 are set. In this case michael@0: * ITER_16 overrides NARROW and we should use the 16 bit pipeline. michael@0: * Note: ITER_16 still has a 32 bit mask, which is a bit weird. */ michael@0: ITER_16 = (1 << 4) michael@0: } iter_flags_t; michael@0: michael@0: struct pixman_iter_t michael@0: { michael@0: /* These are initialized by _pixman_implementation_{src,dest}_init */ michael@0: pixman_image_t * image; michael@0: uint32_t * buffer; michael@0: int x, y; michael@0: int width; michael@0: int height; michael@0: iter_flags_t iter_flags; michael@0: uint32_t image_flags; michael@0: michael@0: /* These function pointers are initialized by the implementation */ michael@0: pixman_iter_get_scanline_t get_scanline; michael@0: pixman_iter_write_back_t write_back; michael@0: michael@0: /* These fields are scratch data that implementations can use */ michael@0: void * data; michael@0: uint8_t * bits; michael@0: int stride; michael@0: }; michael@0: michael@0: void michael@0: _pixman_bits_image_setup_accessors (bits_image_t *image); michael@0: michael@0: void michael@0: _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter); michael@0: michael@0: void michael@0: _pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter); michael@0: michael@0: void michael@0: _pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); michael@0: michael@0: void michael@0: _pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); michael@0: michael@0: void michael@0: _pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); michael@0: michael@0: void michael@0: _pixman_image_init (pixman_image_t *image); michael@0: michael@0: pixman_bool_t michael@0: _pixman_bits_image_init (pixman_image_t * image, michael@0: pixman_format_code_t format, michael@0: int width, michael@0: int height, michael@0: uint32_t * bits, michael@0: int rowstride, michael@0: pixman_bool_t clear); michael@0: pixman_bool_t michael@0: _pixman_image_fini (pixman_image_t *image); michael@0: michael@0: pixman_image_t * michael@0: _pixman_image_allocate (void); michael@0: michael@0: pixman_bool_t michael@0: _pixman_init_gradient (gradient_t * gradient, michael@0: const pixman_gradient_stop_t *stops, michael@0: int n_stops); michael@0: void michael@0: _pixman_image_reset_clip_region (pixman_image_t *image); michael@0: michael@0: void michael@0: _pixman_image_validate (pixman_image_t *image); michael@0: michael@0: #define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul) \ michael@0: do \ michael@0: { \ michael@0: uint32_t *__bits__; \ michael@0: int __stride__; \ michael@0: \ michael@0: __bits__ = image->bits.bits; \ michael@0: __stride__ = image->bits.rowstride; \ michael@0: (out_stride) = \ michael@0: __stride__ * (int) sizeof (uint32_t) / (int) sizeof (type); \ michael@0: (line) = \ michael@0: ((type *) __bits__) + (out_stride) * (y) + (mul) * (x); \ michael@0: } while (0) michael@0: michael@0: /* michael@0: * Gradient walker michael@0: */ michael@0: typedef struct michael@0: { michael@0: uint32_t left_ag; michael@0: uint32_t left_rb; michael@0: uint32_t right_ag; michael@0: uint32_t right_rb; michael@0: pixman_fixed_t left_x; michael@0: pixman_fixed_t right_x; michael@0: pixman_fixed_t stepper; michael@0: michael@0: pixman_gradient_stop_t *stops; michael@0: int num_stops; michael@0: pixman_repeat_t repeat; michael@0: michael@0: pixman_bool_t need_reset; michael@0: } pixman_gradient_walker_t; michael@0: michael@0: void michael@0: _pixman_gradient_walker_init (pixman_gradient_walker_t *walker, michael@0: gradient_t * gradient, michael@0: pixman_repeat_t repeat); michael@0: michael@0: void michael@0: _pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, michael@0: pixman_fixed_48_16_t pos); michael@0: michael@0: uint32_t michael@0: _pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, michael@0: pixman_fixed_48_16_t x); michael@0: michael@0: /* michael@0: * Edges michael@0: */ michael@0: michael@0: #define MAX_ALPHA(n) ((1 << (n)) - 1) michael@0: #define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) - 1) michael@0: #define N_X_FRAC(n) ((n) == 1 ? 1 : (1 << ((n) / 2)) + 1) michael@0: michael@0: #define STEP_Y_SMALL(n) (pixman_fixed_1 / N_Y_FRAC (n)) michael@0: #define STEP_Y_BIG(n) (pixman_fixed_1 - (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n)) michael@0: michael@0: #define Y_FRAC_FIRST(n) (STEP_Y_BIG (n) / 2) michael@0: #define Y_FRAC_LAST(n) (Y_FRAC_FIRST (n) + (N_Y_FRAC (n) - 1) * STEP_Y_SMALL (n)) michael@0: michael@0: #define STEP_X_SMALL(n) (pixman_fixed_1 / N_X_FRAC (n)) michael@0: #define STEP_X_BIG(n) (pixman_fixed_1 - (N_X_FRAC (n) - 1) * STEP_X_SMALL (n)) michael@0: michael@0: #define X_FRAC_FIRST(n) (STEP_X_BIG (n) / 2) michael@0: #define X_FRAC_LAST(n) (X_FRAC_FIRST (n) + (N_X_FRAC (n) - 1) * STEP_X_SMALL (n)) michael@0: michael@0: #define RENDER_SAMPLES_X(x, n) \ michael@0: ((n) == 1? 0 : (pixman_fixed_frac (x) + \ michael@0: X_FRAC_FIRST (n)) / STEP_X_SMALL (n)) michael@0: michael@0: void michael@0: pixman_rasterize_edges_accessors (pixman_image_t *image, michael@0: pixman_edge_t * l, michael@0: pixman_edge_t * r, michael@0: pixman_fixed_t t, michael@0: pixman_fixed_t b); michael@0: michael@0: /* michael@0: * Implementations michael@0: */ michael@0: typedef struct pixman_implementation_t pixman_implementation_t; michael@0: michael@0: typedef struct michael@0: { michael@0: pixman_op_t op; michael@0: pixman_image_t * src_image; michael@0: pixman_image_t * mask_image; michael@0: pixman_image_t * dest_image; michael@0: int32_t src_x; michael@0: int32_t src_y; michael@0: int32_t mask_x; michael@0: int32_t mask_y; michael@0: int32_t dest_x; michael@0: int32_t dest_y; michael@0: int32_t width; michael@0: int32_t height; michael@0: michael@0: uint32_t src_flags; michael@0: uint32_t mask_flags; michael@0: uint32_t dest_flags; michael@0: } pixman_composite_info_t; michael@0: michael@0: #define PIXMAN_COMPOSITE_ARGS(info) \ michael@0: MAYBE_UNUSED pixman_op_t op = info->op; \ michael@0: MAYBE_UNUSED pixman_image_t * src_image = info->src_image; \ michael@0: MAYBE_UNUSED pixman_image_t * mask_image = info->mask_image; \ michael@0: MAYBE_UNUSED pixman_image_t * dest_image = info->dest_image; \ michael@0: MAYBE_UNUSED int32_t src_x = info->src_x; \ michael@0: MAYBE_UNUSED int32_t src_y = info->src_y; \ michael@0: MAYBE_UNUSED int32_t mask_x = info->mask_x; \ michael@0: MAYBE_UNUSED int32_t mask_y = info->mask_y; \ michael@0: MAYBE_UNUSED int32_t dest_x = info->dest_x; \ michael@0: MAYBE_UNUSED int32_t dest_y = info->dest_y; \ michael@0: MAYBE_UNUSED int32_t width = info->width; \ michael@0: MAYBE_UNUSED int32_t height = info->height michael@0: michael@0: typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: uint32_t * dest, michael@0: const uint32_t * src, michael@0: const uint32_t * mask, michael@0: int width); michael@0: michael@0: typedef void (*pixman_combine_float_func_t) (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: float * dest, michael@0: const float * src, michael@0: const float * mask, michael@0: int n_pixels); michael@0: michael@0: typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info); michael@0: typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp, michael@0: uint32_t * src_bits, michael@0: uint32_t * dst_bits, michael@0: int src_stride, michael@0: int dst_stride, michael@0: int src_bpp, michael@0: int dst_bpp, michael@0: int src_x, michael@0: int src_y, michael@0: int dest_x, michael@0: int dest_y, michael@0: int width, michael@0: int height); michael@0: typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp, michael@0: uint32_t * bits, michael@0: int stride, michael@0: int bpp, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler); michael@0: typedef pixman_bool_t (*pixman_iter_init_func_t) (pixman_implementation_t *imp, michael@0: pixman_iter_t *iter); michael@0: michael@0: void _pixman_setup_combiner_functions_16 (pixman_implementation_t *imp); michael@0: void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp); michael@0: void _pixman_setup_combiner_functions_float (pixman_implementation_t *imp); michael@0: michael@0: typedef struct michael@0: { michael@0: pixman_op_t op; michael@0: pixman_format_code_t src_format; michael@0: uint32_t src_flags; michael@0: pixman_format_code_t mask_format; michael@0: uint32_t mask_flags; michael@0: pixman_format_code_t dest_format; michael@0: uint32_t dest_flags; michael@0: pixman_composite_func_t func; michael@0: } pixman_fast_path_t; michael@0: michael@0: struct pixman_implementation_t michael@0: { michael@0: pixman_implementation_t * toplevel; michael@0: pixman_implementation_t * fallback; michael@0: const pixman_fast_path_t * fast_paths; michael@0: michael@0: pixman_blt_func_t blt; michael@0: pixman_fill_func_t fill; michael@0: pixman_iter_init_func_t src_iter_init; michael@0: pixman_iter_init_func_t dest_iter_init; michael@0: michael@0: pixman_combine_32_func_t combine_16[PIXMAN_N_OPERATORS]; michael@0: pixman_combine_32_func_t combine_16_ca[PIXMAN_N_OPERATORS]; michael@0: pixman_combine_32_func_t combine_32[PIXMAN_N_OPERATORS]; michael@0: pixman_combine_32_func_t combine_32_ca[PIXMAN_N_OPERATORS]; michael@0: pixman_combine_float_func_t combine_float[PIXMAN_N_OPERATORS]; michael@0: pixman_combine_float_func_t combine_float_ca[PIXMAN_N_OPERATORS]; michael@0: }; michael@0: michael@0: uint32_t michael@0: _pixman_image_get_solid (pixman_implementation_t *imp, michael@0: pixman_image_t * image, michael@0: pixman_format_code_t format); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create (pixman_implementation_t *fallback, michael@0: const pixman_fast_path_t *fast_paths); michael@0: michael@0: void michael@0: _pixman_implementation_lookup_composite (pixman_implementation_t *toplevel, michael@0: pixman_op_t op, michael@0: pixman_format_code_t src_format, michael@0: uint32_t src_flags, michael@0: pixman_format_code_t mask_format, michael@0: uint32_t mask_flags, michael@0: pixman_format_code_t dest_format, michael@0: uint32_t dest_flags, michael@0: pixman_implementation_t **out_imp, michael@0: pixman_composite_func_t *out_func); michael@0: michael@0: pixman_combine_32_func_t michael@0: _pixman_implementation_lookup_combiner (pixman_implementation_t *imp, michael@0: pixman_op_t op, michael@0: pixman_bool_t component_alpha, michael@0: pixman_bool_t wide, michael@0: pixman_bool_t rgb16); michael@0: michael@0: pixman_bool_t michael@0: _pixman_implementation_blt (pixman_implementation_t *imp, michael@0: uint32_t * src_bits, michael@0: uint32_t * dst_bits, michael@0: int src_stride, michael@0: int dst_stride, michael@0: int src_bpp, michael@0: int dst_bpp, michael@0: int src_x, michael@0: int src_y, michael@0: int dest_x, michael@0: int dest_y, michael@0: int width, michael@0: int height); michael@0: michael@0: pixman_bool_t michael@0: _pixman_implementation_fill (pixman_implementation_t *imp, michael@0: uint32_t * bits, michael@0: int stride, michael@0: int bpp, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler); michael@0: michael@0: pixman_bool_t michael@0: _pixman_implementation_src_iter_init (pixman_implementation_t *imp, michael@0: pixman_iter_t *iter, michael@0: pixman_image_t *image, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint8_t *buffer, michael@0: iter_flags_t flags, michael@0: uint32_t image_flags); michael@0: michael@0: pixman_bool_t michael@0: _pixman_implementation_dest_iter_init (pixman_implementation_t *imp, michael@0: pixman_iter_t *iter, michael@0: pixman_image_t *image, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint8_t *buffer, michael@0: iter_flags_t flags, michael@0: uint32_t image_flags); michael@0: michael@0: /* Specific implementations */ michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_general (void); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_fast_path (pixman_implementation_t *fallback); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_noop (pixman_implementation_t *fallback); michael@0: michael@0: #if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_mmx (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: #ifdef USE_SSE2 michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_sse2 (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: #ifdef USE_ARM_SIMD michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_arm_simd (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: #ifdef USE_ARM_NEON michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_arm_neon (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: #ifdef USE_MIPS_DSPR2 michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: #ifdef USE_VMX michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_vmx (pixman_implementation_t *fallback); michael@0: #endif michael@0: michael@0: pixman_bool_t michael@0: _pixman_implementation_disabled (const char *name); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_x86_get_implementations (pixman_implementation_t *imp); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_arm_get_implementations (pixman_implementation_t *imp); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_ppc_get_implementations (pixman_implementation_t *imp); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_mips_get_implementations (pixman_implementation_t *imp); michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_choose_implementation (void); michael@0: michael@0: pixman_bool_t michael@0: _pixman_disabled (const char *name); michael@0: michael@0: michael@0: /* michael@0: * Utilities michael@0: */ michael@0: pixman_bool_t michael@0: _pixman_compute_composite_region32 (pixman_region32_t * region, michael@0: pixman_image_t * src_image, michael@0: pixman_image_t * mask_image, michael@0: pixman_image_t * dest_image, michael@0: int32_t src_x, michael@0: int32_t src_y, michael@0: int32_t mask_x, michael@0: int32_t mask_y, michael@0: int32_t dest_x, michael@0: int32_t dest_y, michael@0: int32_t width, michael@0: int32_t height); michael@0: uint32_t * michael@0: _pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask); michael@0: michael@0: /* These "formats" all have depth 0, so they michael@0: * will never clash with any real ones michael@0: */ michael@0: #define PIXMAN_null PIXMAN_FORMAT (0, 0, 0, 0, 0, 0) michael@0: #define PIXMAN_solid PIXMAN_FORMAT (0, 1, 0, 0, 0, 0) michael@0: #define PIXMAN_pixbuf PIXMAN_FORMAT (0, 2, 0, 0, 0, 0) michael@0: #define PIXMAN_rpixbuf PIXMAN_FORMAT (0, 3, 0, 0, 0, 0) michael@0: #define PIXMAN_unknown PIXMAN_FORMAT (0, 4, 0, 0, 0, 0) michael@0: #define PIXMAN_any PIXMAN_FORMAT (0, 5, 0, 0, 0, 0) michael@0: michael@0: #define PIXMAN_OP_any (PIXMAN_N_OPERATORS + 1) michael@0: michael@0: #define FAST_PATH_ID_TRANSFORM (1 << 0) michael@0: #define FAST_PATH_NO_ALPHA_MAP (1 << 1) michael@0: #define FAST_PATH_NO_CONVOLUTION_FILTER (1 << 2) michael@0: #define FAST_PATH_NO_PAD_REPEAT (1 << 3) michael@0: #define FAST_PATH_NO_REFLECT_REPEAT (1 << 4) michael@0: #define FAST_PATH_NO_ACCESSORS (1 << 5) michael@0: #define FAST_PATH_NARROW_FORMAT (1 << 6) michael@0: #define FAST_PATH_COMPONENT_ALPHA (1 << 8) michael@0: #define FAST_PATH_SAMPLES_OPAQUE (1 << 7) michael@0: #define FAST_PATH_UNIFIED_ALPHA (1 << 9) michael@0: #define FAST_PATH_SCALE_TRANSFORM (1 << 10) michael@0: #define FAST_PATH_NEAREST_FILTER (1 << 11) michael@0: #define FAST_PATH_HAS_TRANSFORM (1 << 12) michael@0: #define FAST_PATH_IS_OPAQUE (1 << 13) michael@0: #define FAST_PATH_NO_NORMAL_REPEAT (1 << 14) michael@0: #define FAST_PATH_NO_NONE_REPEAT (1 << 15) michael@0: #define FAST_PATH_X_UNIT_POSITIVE (1 << 16) michael@0: #define FAST_PATH_AFFINE_TRANSFORM (1 << 17) michael@0: #define FAST_PATH_Y_UNIT_ZERO (1 << 18) michael@0: #define FAST_PATH_BILINEAR_FILTER (1 << 19) michael@0: #define FAST_PATH_ROTATE_90_TRANSFORM (1 << 20) michael@0: #define FAST_PATH_ROTATE_180_TRANSFORM (1 << 21) michael@0: #define FAST_PATH_ROTATE_270_TRANSFORM (1 << 22) michael@0: #define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST (1 << 23) michael@0: #define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR (1 << 24) michael@0: #define FAST_PATH_BITS_IMAGE (1 << 25) michael@0: #define FAST_PATH_SEPARABLE_CONVOLUTION_FILTER (1 << 26) michael@0: #define FAST_PATH_16_FORMAT (1 << 27) michael@0: michael@0: #define FAST_PATH_PAD_REPEAT \ michael@0: (FAST_PATH_NO_NONE_REPEAT | \ michael@0: FAST_PATH_NO_NORMAL_REPEAT | \ michael@0: FAST_PATH_NO_REFLECT_REPEAT) michael@0: michael@0: #define FAST_PATH_NORMAL_REPEAT \ michael@0: (FAST_PATH_NO_NONE_REPEAT | \ michael@0: FAST_PATH_NO_PAD_REPEAT | \ michael@0: FAST_PATH_NO_REFLECT_REPEAT) michael@0: michael@0: #define FAST_PATH_NONE_REPEAT \ michael@0: (FAST_PATH_NO_NORMAL_REPEAT | \ michael@0: FAST_PATH_NO_PAD_REPEAT | \ michael@0: FAST_PATH_NO_REFLECT_REPEAT) michael@0: michael@0: #define FAST_PATH_REFLECT_REPEAT \ michael@0: (FAST_PATH_NO_NONE_REPEAT | \ michael@0: FAST_PATH_NO_NORMAL_REPEAT | \ michael@0: FAST_PATH_NO_PAD_REPEAT) michael@0: michael@0: #define FAST_PATH_STANDARD_FLAGS \ michael@0: (FAST_PATH_NO_CONVOLUTION_FILTER | \ michael@0: FAST_PATH_NO_ACCESSORS | \ michael@0: FAST_PATH_NO_ALPHA_MAP | \ michael@0: FAST_PATH_NARROW_FORMAT) michael@0: michael@0: #define FAST_PATH_STD_DEST_FLAGS \ michael@0: (FAST_PATH_NO_ACCESSORS | \ michael@0: FAST_PATH_NO_ALPHA_MAP | \ michael@0: FAST_PATH_NARROW_FORMAT) michael@0: michael@0: #define SOURCE_FLAGS(format) \ michael@0: (FAST_PATH_STANDARD_FLAGS | \ michael@0: ((PIXMAN_ ## format == PIXMAN_solid) ? \ michael@0: 0 : (FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | FAST_PATH_NEAREST_FILTER | FAST_PATH_ID_TRANSFORM))) michael@0: michael@0: #define MASK_FLAGS(format, extra) \ michael@0: ((PIXMAN_ ## format == PIXMAN_null) ? 0 : (SOURCE_FLAGS (format) | extra)) michael@0: michael@0: #define FAST_PATH(op, src, src_flags, mask, mask_flags, dest, dest_flags, func) \ michael@0: PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## src, \ michael@0: src_flags, \ michael@0: PIXMAN_ ## mask, \ michael@0: mask_flags, \ michael@0: PIXMAN_ ## dest, \ michael@0: dest_flags, \ michael@0: func michael@0: michael@0: #define PIXMAN_STD_FAST_PATH(op, src, mask, dest, func) \ michael@0: { FAST_PATH ( \ michael@0: op, \ michael@0: src, SOURCE_FLAGS (src), \ michael@0: mask, MASK_FLAGS (mask, FAST_PATH_UNIFIED_ALPHA), \ michael@0: dest, FAST_PATH_STD_DEST_FLAGS, \ michael@0: func) } michael@0: michael@0: #define PIXMAN_STD_FAST_PATH_CA(op, src, mask, dest, func) \ michael@0: { FAST_PATH ( \ michael@0: op, \ michael@0: src, SOURCE_FLAGS (src), \ michael@0: mask, MASK_FLAGS (mask, FAST_PATH_COMPONENT_ALPHA), \ michael@0: dest, FAST_PATH_STD_DEST_FLAGS, \ michael@0: func) } michael@0: michael@0: extern pixman_implementation_t *global_implementation; michael@0: michael@0: static force_inline pixman_implementation_t * michael@0: get_implementation (void) michael@0: { michael@0: #ifndef TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR michael@0: if (!global_implementation) michael@0: global_implementation = _pixman_choose_implementation (); michael@0: #endif michael@0: return global_implementation; michael@0: } michael@0: michael@0: /* This function is exported for the sake of the test suite and not part michael@0: * of the ABI. michael@0: */ michael@0: PIXMAN_EXPORT pixman_implementation_t * michael@0: _pixman_internal_only_get_implementation (void); michael@0: michael@0: /* Memory allocation helpers */ michael@0: void * michael@0: pixman_malloc_ab (unsigned int n, unsigned int b); michael@0: michael@0: void * michael@0: pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c); michael@0: michael@0: pixman_bool_t michael@0: _pixman_multiply_overflows_size (size_t a, size_t b); michael@0: michael@0: pixman_bool_t michael@0: _pixman_multiply_overflows_int (unsigned int a, unsigned int b); michael@0: michael@0: pixman_bool_t michael@0: _pixman_addition_overflows_int (unsigned int a, unsigned int b); michael@0: michael@0: /* Compositing utilities */ michael@0: void michael@0: pixman_expand_to_float (argb_t *dst, michael@0: const uint32_t *src, michael@0: pixman_format_code_t format, michael@0: int width); michael@0: michael@0: void michael@0: pixman_contract_from_float (uint32_t *dst, michael@0: const argb_t *src, michael@0: int width); michael@0: michael@0: /* Region Helpers */ michael@0: pixman_bool_t michael@0: pixman_region32_copy_from_region16 (pixman_region32_t *dst, michael@0: pixman_region16_t *src); michael@0: michael@0: pixman_bool_t michael@0: pixman_region16_copy_from_region32 (pixman_region16_t *dst, michael@0: pixman_region32_t *src); michael@0: michael@0: /* Doubly linked lists */ michael@0: typedef struct pixman_link_t pixman_link_t; michael@0: struct pixman_link_t michael@0: { michael@0: pixman_link_t *next; michael@0: pixman_link_t *prev; michael@0: }; michael@0: michael@0: typedef struct pixman_list_t pixman_list_t; michael@0: struct pixman_list_t michael@0: { michael@0: pixman_link_t *head; michael@0: pixman_link_t *tail; michael@0: }; michael@0: michael@0: static force_inline void michael@0: pixman_list_init (pixman_list_t *list) michael@0: { michael@0: list->head = (pixman_link_t *)list; michael@0: list->tail = (pixman_link_t *)list; michael@0: } michael@0: michael@0: static force_inline void michael@0: pixman_list_prepend (pixman_list_t *list, pixman_link_t *link) michael@0: { michael@0: link->next = list->head; michael@0: link->prev = (pixman_link_t *)list; michael@0: list->head->prev = link; michael@0: list->head = link; michael@0: } michael@0: michael@0: static force_inline void michael@0: pixman_list_unlink (pixman_link_t *link) michael@0: { michael@0: link->prev->next = link->next; michael@0: link->next->prev = link->prev; michael@0: } michael@0: michael@0: static force_inline void michael@0: pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link) michael@0: { michael@0: pixman_list_unlink (link); michael@0: pixman_list_prepend (list, link); michael@0: } michael@0: michael@0: /* Misc macros */ michael@0: michael@0: #ifndef FALSE michael@0: # define FALSE 0 michael@0: #endif michael@0: michael@0: #ifndef TRUE michael@0: # define TRUE 1 michael@0: #endif michael@0: michael@0: #ifndef MIN michael@0: # define MIN(a, b) ((a < b) ? a : b) michael@0: #endif michael@0: michael@0: #ifndef MAX michael@0: # define MAX(a, b) ((a > b) ? a : b) michael@0: #endif michael@0: michael@0: /* Integer division that rounds towards -infinity */ michael@0: #define DIV(a, b) \ michael@0: ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \ michael@0: ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) michael@0: michael@0: /* Modulus that produces the remainder wrt. DIV */ michael@0: #define MOD(a, b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) michael@0: michael@0: #define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v))) michael@0: michael@0: /* Conversion between 8888 and 0565 */ michael@0: michael@0: static force_inline uint16_t michael@0: convert_8888_to_0565 (uint32_t s) michael@0: { michael@0: /* The following code can be compiled into just 4 instructions on ARM */ michael@0: uint32_t a, b; michael@0: a = (s >> 3) & 0x1F001F; michael@0: b = s & 0xFC00; michael@0: a |= a >> 5; michael@0: a |= b >> 5; michael@0: return (uint16_t)a; michael@0: } michael@0: michael@0: static force_inline uint32_t michael@0: convert_0565_to_0888 (uint16_t s) michael@0: { michael@0: return (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | michael@0: ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | michael@0: ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))); michael@0: } michael@0: michael@0: static force_inline uint32_t michael@0: convert_0565_to_8888 (uint16_t s) michael@0: { michael@0: return convert_0565_to_0888 (s) | 0xff000000; michael@0: } michael@0: michael@0: /* Trivial versions that are useful in macros */ michael@0: michael@0: static force_inline uint32_t michael@0: convert_8888_to_8888 (uint32_t s) michael@0: { michael@0: return s; michael@0: } michael@0: michael@0: static force_inline uint32_t michael@0: convert_x888_to_8888 (uint32_t s) michael@0: { michael@0: return s | 0xff000000; michael@0: } michael@0: michael@0: static force_inline uint16_t michael@0: convert_0565_to_0565 (uint16_t s) michael@0: { michael@0: return s; michael@0: } michael@0: michael@0: #define PIXMAN_FORMAT_IS_WIDE(f) \ michael@0: (PIXMAN_FORMAT_A (f) > 8 || \ michael@0: PIXMAN_FORMAT_R (f) > 8 || \ michael@0: PIXMAN_FORMAT_G (f) > 8 || \ michael@0: PIXMAN_FORMAT_B (f) > 8 || \ michael@0: PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB) michael@0: michael@0: #ifdef WORDS_BIGENDIAN michael@0: # define SCREEN_SHIFT_LEFT(x,n) ((x) << (n)) michael@0: # define SCREEN_SHIFT_RIGHT(x,n) ((x) >> (n)) michael@0: #else michael@0: # define SCREEN_SHIFT_LEFT(x,n) ((x) >> (n)) michael@0: # define SCREEN_SHIFT_RIGHT(x,n) ((x) << (n)) michael@0: #endif michael@0: michael@0: static force_inline uint32_t michael@0: unorm_to_unorm (uint32_t val, int from_bits, int to_bits) michael@0: { michael@0: uint32_t result; michael@0: michael@0: if (from_bits == 0) michael@0: return 0; michael@0: michael@0: /* Delete any extra bits */ michael@0: val &= ((1 << from_bits) - 1); michael@0: michael@0: if (from_bits >= to_bits) michael@0: return val >> (from_bits - to_bits); michael@0: michael@0: /* Start out with the high bit of val in the high bit of result. */ michael@0: result = val << (to_bits - from_bits); michael@0: michael@0: /* Copy the bits in result, doubling the number of bits each time, until michael@0: * we fill all to_bits. Unrolled manually because from_bits and to_bits michael@0: * are usually known statically, so the compiler can turn all of this michael@0: * into a few shifts. michael@0: */ michael@0: #define REPLICATE() \ michael@0: do \ michael@0: { \ michael@0: if (from_bits < to_bits) \ michael@0: { \ michael@0: result |= result >> from_bits; \ michael@0: \ michael@0: from_bits *= 2; \ michael@0: } \ michael@0: } \ michael@0: while (0) michael@0: michael@0: REPLICATE(); michael@0: REPLICATE(); michael@0: REPLICATE(); michael@0: REPLICATE(); michael@0: REPLICATE(); michael@0: michael@0: return result; michael@0: } michael@0: michael@0: uint16_t pixman_float_to_unorm (float f, int n_bits); michael@0: float pixman_unorm_to_float (uint16_t u, int n_bits); michael@0: michael@0: /* michael@0: * Various debugging code michael@0: */ michael@0: michael@0: #undef DEBUG michael@0: michael@0: #define COMPILE_TIME_ASSERT(x) \ michael@0: do { typedef int compile_time_assertion [(x)?1:-1]; } while (0) michael@0: michael@0: /* Turn on debugging depending on what type of release this is michael@0: */ michael@0: #if (((PIXMAN_VERSION_MICRO % 2) == 0) && ((PIXMAN_VERSION_MINOR % 2) == 1)) michael@0: michael@0: /* Debugging gets turned on for development releases because these michael@0: * are the things that end up in bleeding edge distributions such michael@0: * as Rawhide etc. michael@0: * michael@0: * For performance reasons we don't turn it on for stable releases or michael@0: * random git checkouts. (Random git checkouts are often used for michael@0: * performance work). michael@0: */ michael@0: michael@0: # define DEBUG michael@0: michael@0: #endif michael@0: michael@0: #ifdef DEBUG michael@0: michael@0: void michael@0: _pixman_log_error (const char *function, const char *message); michael@0: michael@0: #define return_if_fail(expr) \ michael@0: do \ michael@0: { \ michael@0: if (!(expr)) \ michael@0: { \ michael@0: _pixman_log_error (FUNC, "The expression " # expr " was false"); \ michael@0: return; \ michael@0: } \ michael@0: } \ michael@0: while (0) michael@0: michael@0: #define return_val_if_fail(expr, retval) \ michael@0: do \ michael@0: { \ michael@0: if (!(expr)) \ michael@0: { \ michael@0: _pixman_log_error (FUNC, "The expression " # expr " was false"); \ michael@0: return (retval); \ michael@0: } \ michael@0: } \ michael@0: while (0) michael@0: michael@0: #define critical_if_fail(expr) \ michael@0: do \ michael@0: { \ michael@0: if (!(expr)) \ michael@0: _pixman_log_error (FUNC, "The expression " # expr " was false"); \ michael@0: } \ michael@0: while (0) michael@0: michael@0: michael@0: #else michael@0: michael@0: #define _pixman_log_error(f,m) do { } while (0) michael@0: michael@0: #define return_if_fail(expr) \ michael@0: do \ michael@0: { \ michael@0: if (!(expr)) \ michael@0: return; \ michael@0: } \ michael@0: while (0) michael@0: michael@0: #define return_val_if_fail(expr, retval) \ michael@0: do \ michael@0: { \ michael@0: if (!(expr)) \ michael@0: return (retval); \ michael@0: } \ michael@0: while (0) michael@0: michael@0: #define critical_if_fail(expr) \ michael@0: do \ michael@0: { \ michael@0: } \ michael@0: while (0) michael@0: #endif michael@0: michael@0: /* michael@0: * Matrix michael@0: */ michael@0: michael@0: typedef struct { pixman_fixed_48_16_t v[3]; } pixman_vector_48_16_t; michael@0: michael@0: pixman_bool_t michael@0: pixman_transform_point_31_16 (const pixman_transform_t *t, michael@0: const pixman_vector_48_16_t *v, michael@0: pixman_vector_48_16_t *result); michael@0: michael@0: void michael@0: pixman_transform_point_31_16_3d (const pixman_transform_t *t, michael@0: const pixman_vector_48_16_t *v, michael@0: pixman_vector_48_16_t *result); michael@0: michael@0: void michael@0: pixman_transform_point_31_16_affine (const pixman_transform_t *t, michael@0: const pixman_vector_48_16_t *v, michael@0: pixman_vector_48_16_t *result); michael@0: michael@0: /* michael@0: * Timers michael@0: */ michael@0: michael@0: #ifdef PIXMAN_TIMERS michael@0: michael@0: static inline uint64_t michael@0: oil_profile_stamp_rdtsc (void) michael@0: { michael@0: uint32_t hi, lo; michael@0: michael@0: __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi)); michael@0: michael@0: return lo | (((uint64_t)hi) << 32); michael@0: } michael@0: michael@0: #define OIL_STAMP oil_profile_stamp_rdtsc michael@0: michael@0: typedef struct pixman_timer_t pixman_timer_t; michael@0: michael@0: struct pixman_timer_t michael@0: { michael@0: int initialized; michael@0: const char * name; michael@0: uint64_t n_times; michael@0: uint64_t total; michael@0: pixman_timer_t *next; michael@0: }; michael@0: michael@0: extern int timer_defined; michael@0: michael@0: void pixman_timer_register (pixman_timer_t *timer); michael@0: michael@0: #define TIMER_BEGIN(tname) \ michael@0: { \ michael@0: static pixman_timer_t timer ## tname; \ michael@0: uint64_t begin ## tname; \ michael@0: \ michael@0: if (!timer ## tname.initialized) \ michael@0: { \ michael@0: timer ## tname.initialized = 1; \ michael@0: timer ## tname.name = # tname; \ michael@0: pixman_timer_register (&timer ## tname); \ michael@0: } \ michael@0: \ michael@0: timer ## tname.n_times++; \ michael@0: begin ## tname = OIL_STAMP (); michael@0: michael@0: #define TIMER_END(tname) \ michael@0: timer ## tname.total += OIL_STAMP () - begin ## tname; \ michael@0: } michael@0: michael@0: #else michael@0: michael@0: #define TIMER_BEGIN(tname) michael@0: #define TIMER_END(tname) michael@0: michael@0: #endif /* PIXMAN_TIMERS */ michael@0: michael@0: #endif /* __ASSEMBLER__ */ michael@0: michael@0: #endif /* PIXMAN_PRIVATE_H */