michael@0: /* michael@0: * Copyright © 2010 Nokia Corporation michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice (including the next michael@0: * paragraph) shall be included in all copies or substantial portions of the michael@0: * Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: * michael@0: * Author: Siarhei Siamashka (siarhei.siamashka@nokia.com) michael@0: */ michael@0: michael@0: #ifndef PIXMAN_ARM_COMMON_H michael@0: #define PIXMAN_ARM_COMMON_H michael@0: michael@0: #include "pixman-inlines.h" michael@0: michael@0: /* Define some macros which can expand into proxy functions between michael@0: * ARM assembly optimized functions and the rest of pixman fast path API. michael@0: * michael@0: * All the low level ARM assembly functions have to use ARM EABI michael@0: * calling convention and take up to 8 arguments: michael@0: * width, height, dst, dst_stride, src, src_stride, mask, mask_stride michael@0: * michael@0: * The arguments are ordered with the most important coming first (the michael@0: * first 4 arguments are passed to function in registers, the rest are michael@0: * on stack). The last arguments are optional, for example if the michael@0: * function is not using mask, then 'mask' and 'mask_stride' can be michael@0: * omitted when doing a function call. michael@0: * michael@0: * Arguments 'src' and 'mask' contain either a pointer to the top left michael@0: * pixel of the composited rectangle or a pixel color value depending michael@0: * on the function type. In the case of just a color value (solid source michael@0: * or mask), the corresponding stride argument is unused. michael@0: */ michael@0: michael@0: #define SKIP_ZERO_SRC 1 michael@0: #define SKIP_ZERO_MASK 2 michael@0: michael@0: #define PIXMAN_ARM_BIND_FAST_PATH_SRC_DST(cputype, name, \ michael@0: src_type, src_cnt, \ michael@0: dst_type, dst_cnt) \ michael@0: void \ michael@0: pixman_composite_##name##_asm_##cputype (int32_t w, \ michael@0: int32_t h, \ michael@0: dst_type *dst, \ michael@0: int32_t dst_stride, \ michael@0: src_type *src, \ michael@0: int32_t src_stride); \ michael@0: \ michael@0: static void \ michael@0: cputype##_composite_##name (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: dst_type *dst_line; \ michael@0: src_type *src_line; \ michael@0: int32_t dst_stride, src_stride; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ michael@0: src_stride, src_line, src_cnt); \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ michael@0: dst_stride, dst_line, dst_cnt); \ michael@0: \ michael@0: pixman_composite_##name##_asm_##cputype (width, height, \ michael@0: dst_line, dst_stride, \ michael@0: src_line, src_stride); \ michael@0: } michael@0: michael@0: #define PIXMAN_ARM_BIND_FAST_PATH_N_DST(flags, cputype, name, \ michael@0: dst_type, dst_cnt) \ michael@0: void \ michael@0: pixman_composite_##name##_asm_##cputype (int32_t w, \ michael@0: int32_t h, \ michael@0: dst_type *dst, \ michael@0: int32_t dst_stride, \ michael@0: uint32_t src); \ michael@0: \ michael@0: static void \ michael@0: cputype##_composite_##name (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: dst_type *dst_line; \ michael@0: int32_t dst_stride; \ michael@0: uint32_t src; \ michael@0: \ michael@0: src = _pixman_image_get_solid ( \ michael@0: imp, src_image, dest_image->bits.format); \ michael@0: \ michael@0: if ((flags & SKIP_ZERO_SRC) && src == 0) \ michael@0: return; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ michael@0: dst_stride, dst_line, dst_cnt); \ michael@0: \ michael@0: pixman_composite_##name##_asm_##cputype (width, height, \ michael@0: dst_line, dst_stride, \ michael@0: src); \ michael@0: } michael@0: michael@0: #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name, \ michael@0: mask_type, mask_cnt, \ michael@0: dst_type, dst_cnt) \ michael@0: void \ michael@0: pixman_composite_##name##_asm_##cputype (int32_t w, \ michael@0: int32_t h, \ michael@0: dst_type *dst, \ michael@0: int32_t dst_stride, \ michael@0: uint32_t src, \ michael@0: int32_t unused, \ michael@0: mask_type *mask, \ michael@0: int32_t mask_stride); \ michael@0: \ michael@0: static void \ michael@0: cputype##_composite_##name (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: dst_type *dst_line; \ michael@0: mask_type *mask_line; \ michael@0: int32_t dst_stride, mask_stride; \ michael@0: uint32_t src; \ michael@0: \ michael@0: src = _pixman_image_get_solid ( \ michael@0: imp, src_image, dest_image->bits.format); \ michael@0: \ michael@0: if ((flags & SKIP_ZERO_SRC) && src == 0) \ michael@0: return; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ michael@0: dst_stride, dst_line, dst_cnt); \ michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ michael@0: mask_stride, mask_line, mask_cnt); \ michael@0: \ michael@0: pixman_composite_##name##_asm_##cputype (width, height, \ michael@0: dst_line, dst_stride, \ michael@0: src, 0, \ michael@0: mask_line, mask_stride); \ michael@0: } michael@0: michael@0: #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name, \ michael@0: src_type, src_cnt, \ michael@0: dst_type, dst_cnt) \ michael@0: void \ michael@0: pixman_composite_##name##_asm_##cputype (int32_t w, \ michael@0: int32_t h, \ michael@0: dst_type *dst, \ michael@0: int32_t dst_stride, \ michael@0: src_type *src, \ michael@0: int32_t src_stride, \ michael@0: uint32_t mask); \ michael@0: \ michael@0: static void \ michael@0: cputype##_composite_##name (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: dst_type *dst_line; \ michael@0: src_type *src_line; \ michael@0: int32_t dst_stride, src_stride; \ michael@0: uint32_t mask; \ michael@0: \ michael@0: mask = _pixman_image_get_solid ( \ michael@0: imp, mask_image, dest_image->bits.format); \ michael@0: \ michael@0: if ((flags & SKIP_ZERO_MASK) && mask == 0) \ michael@0: return; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ michael@0: dst_stride, dst_line, dst_cnt); \ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ michael@0: src_stride, src_line, src_cnt); \ michael@0: \ michael@0: pixman_composite_##name##_asm_##cputype (width, height, \ michael@0: dst_line, dst_stride, \ michael@0: src_line, src_stride, \ michael@0: mask); \ michael@0: } michael@0: michael@0: #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name, \ michael@0: src_type, src_cnt, \ michael@0: mask_type, mask_cnt, \ michael@0: dst_type, dst_cnt) \ michael@0: void \ michael@0: pixman_composite_##name##_asm_##cputype (int32_t w, \ michael@0: int32_t h, \ michael@0: dst_type *dst, \ michael@0: int32_t dst_stride, \ michael@0: src_type *src, \ michael@0: int32_t src_stride, \ michael@0: mask_type *mask, \ michael@0: int32_t mask_stride); \ michael@0: \ michael@0: static void \ michael@0: cputype##_composite_##name (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: dst_type *dst_line; \ michael@0: src_type *src_line; \ michael@0: mask_type *mask_line; \ michael@0: int32_t dst_stride, src_stride, mask_stride; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ michael@0: dst_stride, dst_line, dst_cnt); \ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ michael@0: src_stride, src_line, src_cnt); \ michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ michael@0: mask_stride, mask_line, mask_cnt); \ michael@0: \ michael@0: pixman_composite_##name##_asm_##cputype (width, height, \ michael@0: dst_line, dst_stride, \ michael@0: src_line, src_stride, \ michael@0: mask_line, mask_stride); \ michael@0: } michael@0: michael@0: #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op, \ michael@0: src_type, dst_type) \ michael@0: void \ michael@0: pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \ michael@0: int32_t w, \ michael@0: dst_type * dst, \ michael@0: const src_type * src, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx); \ michael@0: \ michael@0: static force_inline void \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \ michael@0: const src_type * ps, \ michael@0: int32_t w, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx, \ michael@0: pixman_bool_t zero_src) \ michael@0: { \ michael@0: pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \ michael@0: vx, unit_x, \ michael@0: max_vx); \ michael@0: } \ michael@0: \ michael@0: FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op, \ michael@0: src_type, dst_type, COVER) \ michael@0: FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op, \ michael@0: src_type, dst_type, NONE) \ michael@0: FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op, \ michael@0: src_type, dst_type, PAD) \ michael@0: FAST_NEAREST_MAINLOOP (cputype##_##name##_normal_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op, \ michael@0: src_type, dst_type, NORMAL) michael@0: michael@0: /* Provide entries for the fast path table */ michael@0: #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_NORMAL (op,s,d,func) michael@0: michael@0: #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op, \ michael@0: src_type, dst_type) \ michael@0: void \ michael@0: pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \ michael@0: int32_t w, \ michael@0: dst_type * dst, \ michael@0: const src_type * src, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx, \ michael@0: const uint8_t * mask); \ michael@0: \ michael@0: static force_inline void \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t * mask, \ michael@0: dst_type * pd, \ michael@0: const src_type * ps, \ michael@0: int32_t w, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx, \ michael@0: pixman_bool_t zero_src) \ michael@0: { \ michael@0: if ((flags & SKIP_ZERO_SRC) && zero_src) \ michael@0: return; \ michael@0: pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \ michael@0: vx, unit_x, \ michael@0: max_vx, \ michael@0: mask); \ michael@0: } \ michael@0: \ michael@0: FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op,\ michael@0: src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\ michael@0: FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op,\ michael@0: src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \ michael@0: FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op,\ michael@0: src_type, uint8_t, dst_type, PAD, TRUE, FALSE) \ michael@0: FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ michael@0: scaled_nearest_scanline_##cputype##_##name##_##op,\ michael@0: src_type, uint8_t, dst_type, NORMAL, TRUE, FALSE) michael@0: michael@0: /* Provide entries for the fast path table */ michael@0: #define PIXMAN_ARM_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func), \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_NORMAL (op,s,d,func) michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op, \ michael@0: src_type, dst_type) \ michael@0: void \ michael@0: pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ michael@0: dst_type * dst, \ michael@0: const src_type * top, \ michael@0: const src_type * bottom, \ michael@0: int wt, \ michael@0: int wb, \ michael@0: pixman_fixed_t x, \ michael@0: pixman_fixed_t ux, \ michael@0: int width); \ michael@0: \ michael@0: static force_inline void \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op ( \ michael@0: dst_type * dst, \ michael@0: const uint32_t * mask, \ michael@0: const src_type * src_top, \ michael@0: const src_type * src_bottom, \ michael@0: int32_t w, \ michael@0: int wt, \ michael@0: int wb, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx, \ michael@0: pixman_bool_t zero_src) \ michael@0: { \ michael@0: if ((flags & SKIP_ZERO_SRC) && zero_src) \ michael@0: return; \ michael@0: pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ michael@0: dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \ michael@0: } \ michael@0: \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint32_t, dst_type, COVER, FLAG_NONE) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint32_t, dst_type, NONE, FLAG_NONE) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint32_t, dst_type, PAD, FLAG_NONE) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint32_t, dst_type, NORMAL, \ michael@0: FLAG_NONE) michael@0: michael@0: michael@0: #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \ michael@0: src_type, dst_type) \ michael@0: void \ michael@0: pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ michael@0: dst_type * dst, \ michael@0: const uint8_t * mask, \ michael@0: const src_type * top, \ michael@0: const src_type * bottom, \ michael@0: int wt, \ michael@0: int wb, \ michael@0: pixman_fixed_t x, \ michael@0: pixman_fixed_t ux, \ michael@0: int width); \ michael@0: \ michael@0: static force_inline void \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op ( \ michael@0: dst_type * dst, \ michael@0: const uint8_t * mask, \ michael@0: const src_type * src_top, \ michael@0: const src_type * src_bottom, \ michael@0: int32_t w, \ michael@0: int wt, \ michael@0: int wb, \ michael@0: pixman_fixed_t vx, \ michael@0: pixman_fixed_t unit_x, \ michael@0: pixman_fixed_t max_vx, \ michael@0: pixman_bool_t zero_src) \ michael@0: { \ michael@0: if ((flags & SKIP_ZERO_SRC) && zero_src) \ michael@0: return; \ michael@0: pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ michael@0: dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \ michael@0: } \ michael@0: \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint8_t, dst_type, COVER, \ michael@0: FLAG_HAVE_NON_SOLID_MASK) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint8_t, dst_type, NONE, \ michael@0: FLAG_HAVE_NON_SOLID_MASK) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint8_t, dst_type, PAD, \ michael@0: FLAG_HAVE_NON_SOLID_MASK) \ michael@0: FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ michael@0: scaled_bilinear_scanline_##cputype##_##name##_##op, \ michael@0: NULL, src_type, uint8_t, dst_type, NORMAL, \ michael@0: FLAG_HAVE_NON_SOLID_MASK) michael@0: michael@0: michael@0: #endif