1,7 → 1,26 |
#include <float.h> |
|
#ifndef PIXMAN_PRIVATE_H |
#define PIXMAN_PRIVATE_H |
|
/* |
* The defines which are shared between C and assembly code |
*/ |
|
/* bilinear interpolation precision (must be <= 8) */ |
#define BILINEAR_INTERPOLATION_BITS 7 |
#define BILINEAR_INTERPOLATION_RANGE (1 << BILINEAR_INTERPOLATION_BITS) |
|
/* |
* C specific part |
*/ |
|
#ifndef __ASSEMBLER__ |
|
#ifndef PACKAGE |
# error config.h must be included before pixman-private.h |
#endif |
|
#define PIXMAN_DISABLE_DEPRECATED |
#define PIXMAN_USE_INTERNAL_API |
|
10,6 → 29,7 |
#include <assert.h> |
#include <stdio.h> |
#include <string.h> |
#include <stddef.h> |
|
#include "pixman-compiler.h" |
|
17,7 → 37,6 |
* Images |
*/ |
typedef struct image_common image_common_t; |
typedef struct source_image source_image_t; |
typedef struct solid_fill solid_fill_t; |
typedef struct gradient gradient_t; |
typedef struct linear_gradient linear_gradient_t; |
28,6 → 47,16 |
typedef struct bits_image bits_image_t; |
typedef struct circle circle_t; |
|
typedef struct argb_t argb_t; |
|
struct argb_t |
{ |
float a; |
float r; |
float g; |
float b; |
}; |
|
typedef void (*fetch_scanline_t) (pixman_image_t *image, |
int x, |
int y, |
39,7 → 68,7 |
int x, |
int y); |
|
typedef uint64_t (*fetch_pixel_64_t) (bits_image_t *image, |
typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image, |
int x, |
int y); |
|
58,17 → 87,6 |
SOLID |
} image_type_t; |
|
typedef enum |
{ |
SOURCE_IMAGE_CLASS_UNKNOWN, |
SOURCE_IMAGE_CLASS_HORIZONTAL, |
} source_image_class_t; |
|
typedef source_image_class_t (*classify_func_t) (pixman_image_t *image, |
int x, |
int y, |
int width, |
int height); |
typedef void (*property_changed_func_t) (pixman_image_t *image); |
|
struct image_common |
93,10 → 111,7 |
int alpha_origin_x; |
int alpha_origin_y; |
pixman_bool_t component_alpha; |
classify_func_t classify; |
property_changed_func_t property_changed; |
fetch_scanline_t get_scanline_32; |
fetch_scanline_t get_scanline_64; |
|
pixman_image_destroy_func_t destroy_func; |
void * destroy_data; |
105,26 → 120,20 |
pixman_format_code_t extended_format_code; |
}; |
|
struct source_image |
struct solid_fill |
{ |
image_common_t common; |
}; |
|
struct solid_fill |
{ |
source_image_t common; |
pixman_color_t color; |
|
uint32_t color_32; |
uint64_t color_64; |
argb_t color_float; |
}; |
|
struct gradient |
{ |
source_image_t common; |
image_common_t common; |
int n_stops; |
pixman_gradient_stop_t *stops; |
int stop_range; |
}; |
|
struct linear_gradient |
176,9 → 185,9 |
fetch_pixel_32_t fetch_pixel_32; |
store_scanline_t store_scanline_32; |
|
fetch_scanline_t fetch_scanline_64; |
fetch_pixel_64_t fetch_pixel_64; |
store_scanline_t store_scanline_64; |
fetch_scanline_t fetch_scanline_float; |
fetch_pixel_float_t fetch_pixel_float; |
store_scanline_t store_scanline_float; |
|
/* Used for indirect access to the bits */ |
pixman_read_memory_func_t read_func; |
190,7 → 199,6 |
image_type_t type; |
image_common_t common; |
bits_image_t bits; |
source_image_t source; |
gradient_t gradient; |
linear_gradient_t linear; |
conical_gradient_t conical; |
198,59 → 206,86 |
solid_fill_t solid; |
}; |
|
typedef struct pixman_iter_t pixman_iter_t; |
typedef uint32_t *(* pixman_iter_get_scanline_t) (pixman_iter_t *iter, const uint32_t *mask); |
typedef void (* pixman_iter_write_back_t) (pixman_iter_t *iter); |
|
typedef enum |
{ |
ITER_NARROW = (1 << 0), |
|
/* "Localized alpha" is when the alpha channel is used only to compute |
* the alpha value of the destination. This means that the computation |
* of the RGB values of the result is independent of the alpha value. |
* |
* For example, the OVER operator has localized alpha for the |
* destination, because the RGB values of the result can be computed |
* without knowing the destination alpha. Similarly, ADD has localized |
* alpha for both source and destination because the RGB values of the |
* result can be computed without knowing the alpha value of source or |
* destination. |
* |
* When he destination is xRGB, this is useful knowledge, because then |
* we can treat it as if it were ARGB, which means in some cases we can |
* avoid copying it to a temporary buffer. |
*/ |
ITER_LOCALIZED_ALPHA = (1 << 1), |
ITER_IGNORE_ALPHA = (1 << 2), |
ITER_IGNORE_RGB = (1 << 3) |
} iter_flags_t; |
|
struct pixman_iter_t |
{ |
/* These are initialized by _pixman_implementation_{src,dest}_init */ |
pixman_image_t * image; |
uint32_t * buffer; |
int x, y; |
int width; |
int height; |
iter_flags_t iter_flags; |
uint32_t image_flags; |
|
/* These function pointers are initialized by the implementation */ |
pixman_iter_get_scanline_t get_scanline; |
pixman_iter_write_back_t write_back; |
|
/* These fields are scratch data that implementations can use */ |
void * data; |
uint8_t * bits; |
int stride; |
}; |
|
void |
_pixman_bits_image_setup_accessors (bits_image_t *image); |
|
void |
_pixman_image_get_scanline_generic_64 (pixman_image_t *image, |
int x, |
int y, |
int width, |
uint32_t * buffer, |
const uint32_t *mask); |
_pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter); |
|
source_image_class_t |
_pixman_image_classify (pixman_image_t *image, |
int x, |
int y, |
int width, |
int height); |
void |
_pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter); |
|
void |
_pixman_image_get_scanline_32 (pixman_image_t *image, |
int x, |
int y, |
int width, |
uint32_t * buffer, |
const uint32_t *mask); |
_pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); |
|
/* Even thought the type of buffer is uint32_t *, the function actually expects |
* a uint64_t *buffer. |
*/ |
void |
_pixman_image_get_scanline_64 (pixman_image_t *image, |
int x, |
int y, |
int width, |
uint32_t * buffer, |
const uint32_t *unused); |
_pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); |
|
void |
_pixman_image_store_scanline_32 (bits_image_t * image, |
int x, |
int y, |
int width, |
const uint32_t *buffer); |
_pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter); |
|
/* Even though the type of buffer is uint32_t *, the function |
* actually expects a uint64_t *buffer. |
*/ |
void |
_pixman_image_store_scanline_64 (bits_image_t * image, |
int x, |
int y, |
_pixman_image_init (pixman_image_t *image); |
|
pixman_bool_t |
_pixman_bits_image_init (pixman_image_t * image, |
pixman_format_code_t format, |
int width, |
const uint32_t *buffer); |
int height, |
uint32_t * bits, |
int rowstride, |
pixman_bool_t clear); |
pixman_bool_t |
_pixman_image_fini (pixman_image_t *image); |
|
pixman_image_t * |
_pixman_image_allocate (void); |
265,10 → 300,6 |
void |
_pixman_image_validate (pixman_image_t *image); |
|
uint32_t |
_pixman_image_get_solid (pixman_image_t * image, |
pixman_format_code_t format); |
|
#define PIXMAN_IMAGE_GET_LINE(image, x, y, type, out_stride, line, mul) \ |
do \ |
{ \ |
288,33 → 319,32 |
*/ |
typedef struct |
{ |
uint32_t left_ag; |
uint32_t left_rb; |
uint32_t right_ag; |
uint32_t right_rb; |
int32_t left_x; |
int32_t right_x; |
int32_t stepper; |
float a_s, a_b; |
float r_s, r_b; |
float g_s, g_b; |
float b_s, b_b; |
pixman_fixed_t left_x; |
pixman_fixed_t right_x; |
|
pixman_gradient_stop_t *stops; |
int num_stops; |
unsigned int spread; |
pixman_repeat_t repeat; |
|
int need_reset; |
pixman_bool_t need_reset; |
} pixman_gradient_walker_t; |
|
void |
_pixman_gradient_walker_init (pixman_gradient_walker_t *walker, |
gradient_t * gradient, |
unsigned int spread); |
pixman_repeat_t repeat); |
|
void |
_pixman_gradient_walker_reset (pixman_gradient_walker_t *walker, |
pixman_fixed_32_32_t pos); |
pixman_fixed_48_16_t pos); |
|
uint32_t |
_pixman_gradient_walker_pixel (pixman_gradient_walker_t *walker, |
pixman_fixed_32_32_t x); |
pixman_fixed_48_16_t x); |
|
/* |
* Edges |
352,6 → 382,40 |
*/ |
typedef struct pixman_implementation_t pixman_implementation_t; |
|
typedef struct |
{ |
pixman_op_t op; |
pixman_image_t * src_image; |
pixman_image_t * mask_image; |
pixman_image_t * dest_image; |
int32_t src_x; |
int32_t src_y; |
int32_t mask_x; |
int32_t mask_y; |
int32_t dest_x; |
int32_t dest_y; |
int32_t width; |
int32_t height; |
|
uint32_t src_flags; |
uint32_t mask_flags; |
uint32_t dest_flags; |
} pixman_composite_info_t; |
|
#define PIXMAN_COMPOSITE_ARGS(info) \ |
MAYBE_UNUSED pixman_op_t op = info->op; \ |
MAYBE_UNUSED pixman_image_t * src_image = info->src_image; \ |
MAYBE_UNUSED pixman_image_t * mask_image = info->mask_image; \ |
MAYBE_UNUSED pixman_image_t * dest_image = info->dest_image; \ |
MAYBE_UNUSED int32_t src_x = info->src_x; \ |
MAYBE_UNUSED int32_t src_y = info->src_y; \ |
MAYBE_UNUSED int32_t mask_x = info->mask_x; \ |
MAYBE_UNUSED int32_t mask_y = info->mask_y; \ |
MAYBE_UNUSED int32_t dest_x = info->dest_x; \ |
MAYBE_UNUSED int32_t dest_y = info->dest_y; \ |
MAYBE_UNUSED int32_t width = info->width; \ |
MAYBE_UNUSED int32_t height = info->height |
|
typedef void (*pixman_combine_32_func_t) (pixman_implementation_t *imp, |
pixman_op_t op, |
uint32_t * dest, |
359,26 → 423,15 |
const uint32_t * mask, |
int width); |
|
typedef void (*pixman_combine_64_func_t) (pixman_implementation_t *imp, |
typedef void (*pixman_combine_float_func_t) (pixman_implementation_t *imp, |
pixman_op_t op, |
uint64_t * dest, |
const uint64_t * src, |
const uint64_t * mask, |
int width); |
float * dest, |
const float * src, |
const float * mask, |
int n_pixels); |
|
typedef void (*pixman_composite_func_t) (pixman_implementation_t *imp, |
pixman_op_t op, |
pixman_image_t * src, |
pixman_image_t * mask, |
pixman_image_t * dest, |
int32_t src_x, |
int32_t src_y, |
int32_t mask_x, |
int32_t mask_y, |
int32_t dest_x, |
int32_t dest_y, |
int32_t width, |
int32_t height); |
pixman_composite_info_t *info); |
typedef pixman_bool_t (*pixman_blt_func_t) (pixman_implementation_t *imp, |
uint32_t * src_bits, |
uint32_t * dst_bits, |
388,8 → 441,8 |
int dst_bpp, |
int src_x, |
int src_y, |
int dst_x, |
int dst_y, |
int dest_x, |
int dest_y, |
int width, |
int height); |
typedef pixman_bool_t (*pixman_fill_func_t) (pixman_implementation_t *imp, |
400,10 → 453,12 |
int y, |
int width, |
int height, |
uint32_t xor); |
uint32_t filler); |
typedef pixman_bool_t (*pixman_iter_init_func_t) (pixman_implementation_t *imp, |
pixman_iter_t *iter); |
|
void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp); |
void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp); |
void _pixman_setup_combiner_functions_float (pixman_implementation_t *imp); |
|
typedef struct |
{ |
420,50 → 475,46 |
struct pixman_implementation_t |
{ |
pixman_implementation_t * toplevel; |
pixman_implementation_t * delegate; |
pixman_implementation_t * fallback; |
const pixman_fast_path_t * fast_paths; |
|
pixman_blt_func_t blt; |
pixman_fill_func_t fill; |
pixman_iter_init_func_t src_iter_init; |
pixman_iter_init_func_t dest_iter_init; |
|
pixman_combine_32_func_t combine_32[PIXMAN_N_OPERATORS]; |
pixman_combine_32_func_t combine_32_ca[PIXMAN_N_OPERATORS]; |
pixman_combine_64_func_t combine_64[PIXMAN_N_OPERATORS]; |
pixman_combine_64_func_t combine_64_ca[PIXMAN_N_OPERATORS]; |
pixman_combine_float_func_t combine_float[PIXMAN_N_OPERATORS]; |
pixman_combine_float_func_t combine_float_ca[PIXMAN_N_OPERATORS]; |
}; |
|
uint32_t |
_pixman_image_get_solid (pixman_implementation_t *imp, |
pixman_image_t * image, |
pixman_format_code_t format); |
|
pixman_implementation_t * |
_pixman_implementation_create (pixman_implementation_t *delegate, |
_pixman_implementation_create (pixman_implementation_t *fallback, |
const pixman_fast_path_t *fast_paths); |
|
void |
_pixman_implementation_combine_32 (pixman_implementation_t *imp, |
_pixman_implementation_lookup_composite (pixman_implementation_t *toplevel, |
pixman_op_t op, |
uint32_t * dest, |
const uint32_t * src, |
const uint32_t * mask, |
int width); |
void |
_pixman_implementation_combine_64 (pixman_implementation_t *imp, |
pixman_format_code_t src_format, |
uint32_t src_flags, |
pixman_format_code_t mask_format, |
uint32_t mask_flags, |
pixman_format_code_t dest_format, |
uint32_t dest_flags, |
pixman_implementation_t **out_imp, |
pixman_composite_func_t *out_func); |
|
pixman_combine_32_func_t |
_pixman_implementation_lookup_combiner (pixman_implementation_t *imp, |
pixman_op_t op, |
uint64_t * dest, |
const uint64_t * src, |
const uint64_t * mask, |
int width); |
void |
_pixman_implementation_combine_32_ca (pixman_implementation_t *imp, |
pixman_op_t op, |
uint32_t * dest, |
const uint32_t * src, |
const uint32_t * mask, |
int width); |
void |
_pixman_implementation_combine_64_ca (pixman_implementation_t *imp, |
pixman_op_t op, |
uint64_t * dest, |
const uint64_t * src, |
const uint64_t * mask, |
int width); |
pixman_bool_t component_alpha, |
pixman_bool_t wide); |
|
pixman_bool_t |
_pixman_implementation_blt (pixman_implementation_t *imp, |
475,8 → 526,8 |
int dst_bpp, |
int src_x, |
int src_y, |
int dst_x, |
int dst_y, |
int dest_x, |
int dest_y, |
int width, |
int height); |
|
489,48 → 540,112 |
int y, |
int width, |
int height, |
uint32_t xor); |
uint32_t filler); |
|
pixman_bool_t |
_pixman_implementation_src_iter_init (pixman_implementation_t *imp, |
pixman_iter_t *iter, |
pixman_image_t *image, |
int x, |
int y, |
int width, |
int height, |
uint8_t *buffer, |
iter_flags_t flags, |
uint32_t image_flags); |
|
pixman_bool_t |
_pixman_implementation_dest_iter_init (pixman_implementation_t *imp, |
pixman_iter_t *iter, |
pixman_image_t *image, |
int x, |
int y, |
int width, |
int height, |
uint8_t *buffer, |
iter_flags_t flags, |
uint32_t image_flags); |
|
/* Specific implementations */ |
pixman_implementation_t * |
_pixman_implementation_create_general (void); |
|
pixman_implementation_t * |
_pixman_implementation_create_fast_path (void); |
_pixman_implementation_create_fast_path (pixman_implementation_t *fallback); |
|
#ifdef USE_MMX |
pixman_implementation_t * |
_pixman_implementation_create_mmx (void); |
_pixman_implementation_create_noop (pixman_implementation_t *fallback); |
|
#if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI |
pixman_implementation_t * |
_pixman_implementation_create_mmx (pixman_implementation_t *fallback); |
#endif |
|
#ifdef USE_SSE2 |
pixman_implementation_t * |
_pixman_implementation_create_sse2 (void); |
_pixman_implementation_create_sse2 (pixman_implementation_t *fallback); |
#endif |
|
#ifdef USE_ARM_SIMD |
pixman_implementation_t * |
_pixman_implementation_create_arm_simd (void); |
_pixman_implementation_create_arm_simd (pixman_implementation_t *fallback); |
#endif |
|
#ifdef USE_ARM_NEON |
pixman_implementation_t * |
_pixman_implementation_create_arm_neon (void); |
_pixman_implementation_create_arm_neon (pixman_implementation_t *fallback); |
#endif |
|
#ifdef USE_MIPS_DSPR2 |
pixman_implementation_t * |
_pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback); |
#endif |
|
#ifdef USE_VMX |
pixman_implementation_t * |
_pixman_implementation_create_vmx (void); |
_pixman_implementation_create_vmx (pixman_implementation_t *fallback); |
#endif |
|
pixman_bool_t |
_pixman_implementation_disabled (const char *name); |
|
pixman_implementation_t * |
_pixman_x86_get_implementations (pixman_implementation_t *imp); |
|
pixman_implementation_t * |
_pixman_arm_get_implementations (pixman_implementation_t *imp); |
|
pixman_implementation_t * |
_pixman_ppc_get_implementations (pixman_implementation_t *imp); |
|
pixman_implementation_t * |
_pixman_mips_get_implementations (pixman_implementation_t *imp); |
|
pixman_implementation_t * |
_pixman_choose_implementation (void); |
|
pixman_bool_t |
_pixman_disabled (const char *name); |
|
|
/* |
* Utilities |
*/ |
pixman_bool_t |
_pixman_compute_composite_region32 (pixman_region32_t * region, |
pixman_image_t * src_image, |
pixman_image_t * mask_image, |
pixman_image_t * dest_image, |
int32_t src_x, |
int32_t src_y, |
int32_t mask_x, |
int32_t mask_y, |
int32_t dest_x, |
int32_t dest_y, |
int32_t width, |
int32_t height); |
uint32_t * |
_pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask); |
|
/* These "formats" all have depth 0, so they |
* will never clash with any real ones |
558,14 → 673,19 |
#define FAST_PATH_NEAREST_FILTER (1 << 11) |
#define FAST_PATH_HAS_TRANSFORM (1 << 12) |
#define FAST_PATH_IS_OPAQUE (1 << 13) |
#define FAST_PATH_NEEDS_WORKAROUND (1 << 14) |
#define FAST_PATH_NO_NORMAL_REPEAT (1 << 14) |
#define FAST_PATH_NO_NONE_REPEAT (1 << 15) |
#define FAST_PATH_SAMPLES_COVER_CLIP (1 << 16) |
#define FAST_PATH_X_UNIT_POSITIVE (1 << 17) |
#define FAST_PATH_AFFINE_TRANSFORM (1 << 18) |
#define FAST_PATH_Y_UNIT_ZERO (1 << 19) |
#define FAST_PATH_BILINEAR_FILTER (1 << 20) |
#define FAST_PATH_NO_NORMAL_REPEAT (1 << 21) |
#define FAST_PATH_X_UNIT_POSITIVE (1 << 16) |
#define FAST_PATH_AFFINE_TRANSFORM (1 << 17) |
#define FAST_PATH_Y_UNIT_ZERO (1 << 18) |
#define FAST_PATH_BILINEAR_FILTER (1 << 19) |
#define FAST_PATH_ROTATE_90_TRANSFORM (1 << 20) |
#define FAST_PATH_ROTATE_180_TRANSFORM (1 << 21) |
#define FAST_PATH_ROTATE_270_TRANSFORM (1 << 22) |
#define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST (1 << 23) |
#define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR (1 << 24) |
#define FAST_PATH_BITS_IMAGE (1 << 25) |
#define FAST_PATH_SEPARABLE_CONVOLUTION_FILTER (1 << 26) |
|
#define FAST_PATH_PAD_REPEAT \ |
(FAST_PATH_NO_NONE_REPEAT | \ |
601,7 → 721,7 |
#define SOURCE_FLAGS(format) \ |
(FAST_PATH_STANDARD_FLAGS | \ |
((PIXMAN_ ## format == PIXMAN_solid) ? \ |
0 : (FAST_PATH_SAMPLES_COVER_CLIP | FAST_PATH_ID_TRANSFORM))) |
0 : (FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | FAST_PATH_NEAREST_FILTER | FAST_PATH_ID_TRANSFORM))) |
|
#define MASK_FLAGS(format, extra) \ |
((PIXMAN_ ## format == PIXMAN_null) ? 0 : (SOURCE_FLAGS (format) | extra)) |
632,6 → 752,24 |
dest, FAST_PATH_STD_DEST_FLAGS, \ |
func) } |
|
extern pixman_implementation_t *global_implementation; |
|
static force_inline pixman_implementation_t * |
get_implementation (void) |
{ |
#ifndef TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR |
if (!global_implementation) |
global_implementation = _pixman_choose_implementation (); |
#endif |
return global_implementation; |
} |
|
/* This function is exported for the sake of the test suite and not part |
* of the ABI. |
*/ |
PIXMAN_EXPORT pixman_implementation_t * |
_pixman_internal_only_get_implementation (void); |
|
/* Memory allocation helpers */ |
void * |
pixman_malloc_ab (unsigned int n, unsigned int b); |
640,24 → 778,26 |
pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c); |
|
pixman_bool_t |
pixman_multiply_overflows_int (unsigned int a, unsigned int b); |
_pixman_multiply_overflows_size (size_t a, size_t b); |
|
pixman_bool_t |
pixman_addition_overflows_int (unsigned int a, unsigned int b); |
_pixman_multiply_overflows_int (unsigned int a, unsigned int b); |
|
pixman_bool_t |
_pixman_addition_overflows_int (unsigned int a, unsigned int b); |
|
/* Compositing utilities */ |
void |
pixman_expand (uint64_t * dst, |
pixman_expand_to_float (argb_t *dst, |
const uint32_t * src, |
pixman_format_code_t format, |
int width); |
|
void |
pixman_contract (uint32_t * dst, |
const uint64_t *src, |
pixman_contract_from_float (uint32_t *dst, |
const argb_t *src, |
int width); |
|
|
/* Region Helpers */ |
pixman_bool_t |
pixman_region32_copy_from_region16 (pixman_region32_t *dst, |
667,7 → 807,51 |
pixman_region16_copy_from_region32 (pixman_region16_t *dst, |
pixman_region32_t *src); |
|
/* Doubly linked lists */ |
typedef struct pixman_link_t pixman_link_t; |
struct pixman_link_t |
{ |
pixman_link_t *next; |
pixman_link_t *prev; |
}; |
|
typedef struct pixman_list_t pixman_list_t; |
struct pixman_list_t |
{ |
pixman_link_t *head; |
pixman_link_t *tail; |
}; |
|
static force_inline void |
pixman_list_init (pixman_list_t *list) |
{ |
list->head = (pixman_link_t *)list; |
list->tail = (pixman_link_t *)list; |
} |
|
static force_inline void |
pixman_list_prepend (pixman_list_t *list, pixman_link_t *link) |
{ |
link->next = list->head; |
link->prev = (pixman_link_t *)list; |
list->head->prev = link; |
list->head = link; |
} |
|
static force_inline void |
pixman_list_unlink (pixman_link_t *link) |
{ |
link->prev->next = link->next; |
link->next->prev = link->prev; |
} |
|
static force_inline void |
pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link) |
{ |
pixman_list_unlink (link); |
pixman_list_prepend (list, link); |
} |
|
/* Misc macros */ |
|
#ifndef FALSE |
696,29 → 880,62 |
|
#define CLIP(v, low, high) ((v) < (low) ? (low) : ((v) > (high) ? (high) : (v))) |
|
#define FLOAT_IS_ZERO(f) (-FLT_MIN < (f) && (f) < FLT_MIN) |
|
/* Conversion between 8888 and 0565 */ |
|
#define CONVERT_8888_TO_0565(s) \ |
((((s) >> 3) & 0x001f) | \ |
(((s) >> 5) & 0x07e0) | \ |
(((s) >> 8) & 0xf800)) |
static force_inline uint16_t |
convert_8888_to_0565 (uint32_t s) |
{ |
/* The following code can be compiled into just 4 instructions on ARM */ |
uint32_t a, b; |
a = (s >> 3) & 0x1F001F; |
b = s & 0xFC00; |
a |= a >> 5; |
a |= b >> 5; |
return (uint16_t)a; |
} |
|
#define CONVERT_0565_TO_0888(s) \ |
(((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ |
((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ |
((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))) |
static force_inline uint32_t |
convert_0565_to_0888 (uint16_t s) |
{ |
return (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | |
((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | |
((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))); |
} |
|
#define CONVERT_0565_TO_8888(s) (CONVERT_0565_TO_0888(s) | 0xff000000) |
static force_inline uint32_t |
convert_0565_to_8888 (uint16_t s) |
{ |
return convert_0565_to_0888 (s) | 0xff000000; |
} |
|
/* Trivial versions that are useful in macros */ |
#define CONVERT_8888_TO_8888(s) (s) |
#define CONVERT_0565_TO_0565(s) (s) |
|
static force_inline uint32_t |
convert_8888_to_8888 (uint32_t s) |
{ |
return s; |
} |
|
static force_inline uint32_t |
convert_x888_to_8888 (uint32_t s) |
{ |
return s | 0xff000000; |
} |
|
static force_inline uint16_t |
convert_0565_to_0565 (uint16_t s) |
{ |
return s; |
} |
|
#define PIXMAN_FORMAT_IS_WIDE(f) \ |
(PIXMAN_FORMAT_A (f) > 8 || \ |
PIXMAN_FORMAT_R (f) > 8 || \ |
PIXMAN_FORMAT_G (f) > 8 || \ |
PIXMAN_FORMAT_B (f) > 8) |
PIXMAN_FORMAT_B (f) > 8 || \ |
PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB) |
|
#ifdef WORDS_BIGENDIAN |
# define SCREEN_SHIFT_LEFT(x,n) ((x) << (n)) |
728,6 → 945,52 |
# define SCREEN_SHIFT_RIGHT(x,n) ((x) << (n)) |
#endif |
|
static force_inline uint32_t |
unorm_to_unorm (uint32_t val, int from_bits, int to_bits) |
{ |
uint32_t result; |
|
if (from_bits == 0) |
return 0; |
|
/* Delete any extra bits */ |
val &= ((1 << from_bits) - 1); |
|
if (from_bits >= to_bits) |
return val >> (from_bits - to_bits); |
|
/* Start out with the high bit of val in the high bit of result. */ |
result = val << (to_bits - from_bits); |
|
/* Copy the bits in result, doubling the number of bits each time, until |
* we fill all to_bits. Unrolled manually because from_bits and to_bits |
* are usually known statically, so the compiler can turn all of this |
* into a few shifts. |
*/ |
#define REPLICATE() \ |
do \ |
{ \ |
if (from_bits < to_bits) \ |
{ \ |
result |= result >> from_bits; \ |
\ |
from_bits *= 2; \ |
} \ |
} \ |
while (0) |
|
REPLICATE(); |
REPLICATE(); |
REPLICATE(); |
REPLICATE(); |
REPLICATE(); |
|
return result; |
} |
|
uint16_t pixman_float_to_unorm (float f, int n_bits); |
float pixman_unorm_to_float (uint16_t u, int n_bits); |
|
/* |
* Various debugging code |
*/ |
754,8 → 1017,6 |
|
#endif |
|
#ifdef DEBUG |
|
void |
_pixman_log_error (const char *function, const char *message); |
|
762,7 → 1023,7 |
#define return_if_fail(expr) \ |
do \ |
{ \ |
if (!(expr)) \ |
if (unlikely (!(expr))) \ |
{ \ |
_pixman_log_error (FUNC, "The expression " # expr " was false"); \ |
return; \ |
773,7 → 1034,7 |
#define return_val_if_fail(expr, retval) \ |
do \ |
{ \ |
if (!(expr)) \ |
if (unlikely (!(expr))) \ |
{ \ |
_pixman_log_error (FUNC, "The expression " # expr " was false"); \ |
return (retval); \ |
784,39 → 1045,32 |
#define critical_if_fail(expr) \ |
do \ |
{ \ |
if (!(expr)) \ |
if (unlikely (!(expr))) \ |
_pixman_log_error (FUNC, "The expression " # expr " was false"); \ |
} \ |
while (0) |
|
/* |
* Matrix |
*/ |
|
#else |
typedef struct { pixman_fixed_48_16_t v[3]; } pixman_vector_48_16_t; |
|
#define _pixman_log_error(f,m) do { } while (0) \ |
pixman_bool_t |
pixman_transform_point_31_16 (const pixman_transform_t *t, |
const pixman_vector_48_16_t *v, |
pixman_vector_48_16_t *result); |
|
#define return_if_fail(expr) \ |
do \ |
{ \ |
if (!(expr)) \ |
return; \ |
} \ |
while (0) |
void |
pixman_transform_point_31_16_3d (const pixman_transform_t *t, |
const pixman_vector_48_16_t *v, |
pixman_vector_48_16_t *result); |
|
#define return_val_if_fail(expr, retval) \ |
do \ |
{ \ |
if (!(expr)) \ |
return (retval); \ |
} \ |
while (0) |
void |
pixman_transform_point_31_16_affine (const pixman_transform_t *t, |
const pixman_vector_48_16_t *v, |
pixman_vector_48_16_t *result); |
|
#define critical_if_fail(expr) \ |
do \ |
{ \ |
} \ |
while (0) |
#endif |
|
/* |
* Timers |
*/ |
826,10 → 1080,11 |
static inline uint64_t |
oil_profile_stamp_rdtsc (void) |
{ |
uint64_t ts; |
uint32_t hi, lo; |
|
__asm__ __volatile__ ("rdtsc\n" : "=A" (ts)); |
return ts; |
__asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi)); |
|
return lo | (((uint64_t)hi) << 32); |
} |
|
#define OIL_STAMP oil_profile_stamp_rdtsc |
868,6 → 1123,13 |
timer ## tname.total += OIL_STAMP () - begin ## tname; \ |
} |
|
#else |
|
#define TIMER_BEGIN(tname) |
#define TIMER_END(tname) |
|
#endif /* PIXMAN_TIMERS */ |
|
#endif /* __ASSEMBLER__ */ |
|
#endif /* PIXMAN_PRIVATE_H */ |