1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/libpixman/src/pixman-arm-common.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,428 @@ 1.4 +/* 1.5 + * Copyright © 2010 Nokia Corporation 1.6 + * 1.7 + * Permission is hereby granted, free of charge, to any person obtaining a 1.8 + * copy of this software and associated documentation files (the "Software"), 1.9 + * to deal in the Software without restriction, including without limitation 1.10 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1.11 + * and/or sell copies of the Software, and to permit persons to whom the 1.12 + * Software is furnished to do so, subject to the following conditions: 1.13 + * 1.14 + * The above copyright notice and this permission notice (including the next 1.15 + * paragraph) shall be included in all copies or substantial portions of the 1.16 + * Software. 1.17 + * 1.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1.19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1.20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1.21 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1.22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1.23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 1.24 + * DEALINGS IN THE SOFTWARE. 1.25 + * 1.26 + * Author: Siarhei Siamashka (siarhei.siamashka@nokia.com) 1.27 + */ 1.28 + 1.29 +#ifndef PIXMAN_ARM_COMMON_H 1.30 +#define PIXMAN_ARM_COMMON_H 1.31 + 1.32 +#include "pixman-inlines.h" 1.33 + 1.34 +/* Define some macros which can expand into proxy functions between 1.35 + * ARM assembly optimized functions and the rest of pixman fast path API. 1.36 + * 1.37 + * All the low level ARM assembly functions have to use ARM EABI 1.38 + * calling convention and take up to 8 arguments: 1.39 + * width, height, dst, dst_stride, src, src_stride, mask, mask_stride 1.40 + * 1.41 + * The arguments are ordered with the most important coming first (the 1.42 + * first 4 arguments are passed to function in registers, the rest are 1.43 + * on stack). The last arguments are optional, for example if the 1.44 + * function is not using mask, then 'mask' and 'mask_stride' can be 1.45 + * omitted when doing a function call. 1.46 + * 1.47 + * Arguments 'src' and 'mask' contain either a pointer to the top left 1.48 + * pixel of the composited rectangle or a pixel color value depending 1.49 + * on the function type. In the case of just a color value (solid source 1.50 + * or mask), the corresponding stride argument is unused. 1.51 + */ 1.52 + 1.53 +#define SKIP_ZERO_SRC 1 1.54 +#define SKIP_ZERO_MASK 2 1.55 + 1.56 +#define PIXMAN_ARM_BIND_FAST_PATH_SRC_DST(cputype, name, \ 1.57 + src_type, src_cnt, \ 1.58 + dst_type, dst_cnt) \ 1.59 +void \ 1.60 +pixman_composite_##name##_asm_##cputype (int32_t w, \ 1.61 + int32_t h, \ 1.62 + dst_type *dst, \ 1.63 + int32_t dst_stride, \ 1.64 + src_type *src, \ 1.65 + int32_t src_stride); \ 1.66 + \ 1.67 +static void \ 1.68 +cputype##_composite_##name (pixman_implementation_t *imp, \ 1.69 + pixman_composite_info_t *info) \ 1.70 +{ \ 1.71 + PIXMAN_COMPOSITE_ARGS (info); \ 1.72 + dst_type *dst_line; \ 1.73 + src_type *src_line; \ 1.74 + int32_t dst_stride, src_stride; \ 1.75 + \ 1.76 + PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 1.77 + src_stride, src_line, src_cnt); \ 1.78 + PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 1.79 + dst_stride, dst_line, dst_cnt); \ 1.80 + \ 1.81 + pixman_composite_##name##_asm_##cputype (width, height, \ 1.82 + dst_line, dst_stride, \ 1.83 + src_line, src_stride); \ 1.84 +} 1.85 + 1.86 +#define PIXMAN_ARM_BIND_FAST_PATH_N_DST(flags, cputype, name, \ 1.87 + dst_type, dst_cnt) \ 1.88 +void \ 1.89 +pixman_composite_##name##_asm_##cputype (int32_t w, \ 1.90 + int32_t h, \ 1.91 + dst_type *dst, \ 1.92 + int32_t dst_stride, \ 1.93 + uint32_t src); \ 1.94 + \ 1.95 +static void \ 1.96 +cputype##_composite_##name (pixman_implementation_t *imp, \ 1.97 + pixman_composite_info_t *info) \ 1.98 +{ \ 1.99 + PIXMAN_COMPOSITE_ARGS (info); \ 1.100 + dst_type *dst_line; \ 1.101 + int32_t dst_stride; \ 1.102 + uint32_t src; \ 1.103 + \ 1.104 + src = _pixman_image_get_solid ( \ 1.105 + imp, src_image, dest_image->bits.format); \ 1.106 + \ 1.107 + if ((flags & SKIP_ZERO_SRC) && src == 0) \ 1.108 + return; \ 1.109 + \ 1.110 + PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 1.111 + dst_stride, dst_line, dst_cnt); \ 1.112 + \ 1.113 + pixman_composite_##name##_asm_##cputype (width, height, \ 1.114 + dst_line, dst_stride, \ 1.115 + src); \ 1.116 +} 1.117 + 1.118 +#define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name, \ 1.119 + mask_type, mask_cnt, \ 1.120 + dst_type, dst_cnt) \ 1.121 +void \ 1.122 +pixman_composite_##name##_asm_##cputype (int32_t w, \ 1.123 + int32_t h, \ 1.124 + dst_type *dst, \ 1.125 + int32_t dst_stride, \ 1.126 + uint32_t src, \ 1.127 + int32_t unused, \ 1.128 + mask_type *mask, \ 1.129 + int32_t mask_stride); \ 1.130 + \ 1.131 +static void \ 1.132 +cputype##_composite_##name (pixman_implementation_t *imp, \ 1.133 + pixman_composite_info_t *info) \ 1.134 +{ \ 1.135 + PIXMAN_COMPOSITE_ARGS (info); \ 1.136 + dst_type *dst_line; \ 1.137 + mask_type *mask_line; \ 1.138 + int32_t dst_stride, mask_stride; \ 1.139 + uint32_t src; \ 1.140 + \ 1.141 + src = _pixman_image_get_solid ( \ 1.142 + imp, src_image, dest_image->bits.format); \ 1.143 + \ 1.144 + if ((flags & SKIP_ZERO_SRC) && src == 0) \ 1.145 + return; \ 1.146 + \ 1.147 + PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 1.148 + dst_stride, dst_line, dst_cnt); \ 1.149 + PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ 1.150 + mask_stride, mask_line, mask_cnt); \ 1.151 + \ 1.152 + pixman_composite_##name##_asm_##cputype (width, height, \ 1.153 + dst_line, dst_stride, \ 1.154 + src, 0, \ 1.155 + mask_line, mask_stride); \ 1.156 +} 1.157 + 1.158 +#define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name, \ 1.159 + src_type, src_cnt, \ 1.160 + dst_type, dst_cnt) \ 1.161 +void \ 1.162 +pixman_composite_##name##_asm_##cputype (int32_t w, \ 1.163 + int32_t h, \ 1.164 + dst_type *dst, \ 1.165 + int32_t dst_stride, \ 1.166 + src_type *src, \ 1.167 + int32_t src_stride, \ 1.168 + uint32_t mask); \ 1.169 + \ 1.170 +static void \ 1.171 +cputype##_composite_##name (pixman_implementation_t *imp, \ 1.172 + pixman_composite_info_t *info) \ 1.173 +{ \ 1.174 + PIXMAN_COMPOSITE_ARGS (info); \ 1.175 + dst_type *dst_line; \ 1.176 + src_type *src_line; \ 1.177 + int32_t dst_stride, src_stride; \ 1.178 + uint32_t mask; \ 1.179 + \ 1.180 + mask = _pixman_image_get_solid ( \ 1.181 + imp, mask_image, dest_image->bits.format); \ 1.182 + \ 1.183 + if ((flags & SKIP_ZERO_MASK) && mask == 0) \ 1.184 + return; \ 1.185 + \ 1.186 + PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 1.187 + dst_stride, dst_line, dst_cnt); \ 1.188 + PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 1.189 + src_stride, src_line, src_cnt); \ 1.190 + \ 1.191 + pixman_composite_##name##_asm_##cputype (width, height, \ 1.192 + dst_line, dst_stride, \ 1.193 + src_line, src_stride, \ 1.194 + mask); \ 1.195 +} 1.196 + 1.197 +#define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name, \ 1.198 + src_type, src_cnt, \ 1.199 + mask_type, mask_cnt, \ 1.200 + dst_type, dst_cnt) \ 1.201 +void \ 1.202 +pixman_composite_##name##_asm_##cputype (int32_t w, \ 1.203 + int32_t h, \ 1.204 + dst_type *dst, \ 1.205 + int32_t dst_stride, \ 1.206 + src_type *src, \ 1.207 + int32_t src_stride, \ 1.208 + mask_type *mask, \ 1.209 + int32_t mask_stride); \ 1.210 + \ 1.211 +static void \ 1.212 +cputype##_composite_##name (pixman_implementation_t *imp, \ 1.213 + pixman_composite_info_t *info) \ 1.214 +{ \ 1.215 + PIXMAN_COMPOSITE_ARGS (info); \ 1.216 + dst_type *dst_line; \ 1.217 + src_type *src_line; \ 1.218 + mask_type *mask_line; \ 1.219 + int32_t dst_stride, src_stride, mask_stride; \ 1.220 + \ 1.221 + PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 1.222 + dst_stride, dst_line, dst_cnt); \ 1.223 + PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 1.224 + src_stride, src_line, src_cnt); \ 1.225 + PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ 1.226 + mask_stride, mask_line, mask_cnt); \ 1.227 + \ 1.228 + pixman_composite_##name##_asm_##cputype (width, height, \ 1.229 + dst_line, dst_stride, \ 1.230 + src_line, src_stride, \ 1.231 + mask_line, mask_stride); \ 1.232 +} 1.233 + 1.234 +#define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op, \ 1.235 + src_type, dst_type) \ 1.236 +void \ 1.237 +pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \ 1.238 + int32_t w, \ 1.239 + dst_type * dst, \ 1.240 + const src_type * src, \ 1.241 + pixman_fixed_t vx, \ 1.242 + pixman_fixed_t unit_x, \ 1.243 + pixman_fixed_t max_vx); \ 1.244 + \ 1.245 +static force_inline void \ 1.246 +scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \ 1.247 + const src_type * ps, \ 1.248 + int32_t w, \ 1.249 + pixman_fixed_t vx, \ 1.250 + pixman_fixed_t unit_x, \ 1.251 + pixman_fixed_t max_vx, \ 1.252 + pixman_bool_t zero_src) \ 1.253 +{ \ 1.254 + pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \ 1.255 + vx, unit_x, \ 1.256 + max_vx); \ 1.257 +} \ 1.258 + \ 1.259 +FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \ 1.260 + scaled_nearest_scanline_##cputype##_##name##_##op, \ 1.261 + src_type, dst_type, COVER) \ 1.262 +FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \ 1.263 + scaled_nearest_scanline_##cputype##_##name##_##op, \ 1.264 + src_type, dst_type, NONE) \ 1.265 +FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \ 1.266 + scaled_nearest_scanline_##cputype##_##name##_##op, \ 1.267 + src_type, dst_type, PAD) \ 1.268 +FAST_NEAREST_MAINLOOP (cputype##_##name##_normal_##op, \ 1.269 + scaled_nearest_scanline_##cputype##_##name##_##op, \ 1.270 + src_type, dst_type, NORMAL) 1.271 + 1.272 +/* Provide entries for the fast path table */ 1.273 +#define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \ 1.274 + SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \ 1.275 + SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \ 1.276 + SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func), \ 1.277 + SIMPLE_NEAREST_FAST_PATH_NORMAL (op,s,d,func) 1.278 + 1.279 +#define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op, \ 1.280 + src_type, dst_type) \ 1.281 +void \ 1.282 +pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \ 1.283 + int32_t w, \ 1.284 + dst_type * dst, \ 1.285 + const src_type * src, \ 1.286 + pixman_fixed_t vx, \ 1.287 + pixman_fixed_t unit_x, \ 1.288 + pixman_fixed_t max_vx, \ 1.289 + const uint8_t * mask); \ 1.290 + \ 1.291 +static force_inline void \ 1.292 +scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t * mask, \ 1.293 + dst_type * pd, \ 1.294 + const src_type * ps, \ 1.295 + int32_t w, \ 1.296 + pixman_fixed_t vx, \ 1.297 + pixman_fixed_t unit_x, \ 1.298 + pixman_fixed_t max_vx, \ 1.299 + pixman_bool_t zero_src) \ 1.300 +{ \ 1.301 + if ((flags & SKIP_ZERO_SRC) && zero_src) \ 1.302 + return; \ 1.303 + pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \ 1.304 + vx, unit_x, \ 1.305 + max_vx, \ 1.306 + mask); \ 1.307 +} \ 1.308 + \ 1.309 +FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ 1.310 + scaled_nearest_scanline_##cputype##_##name##_##op,\ 1.311 + src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\ 1.312 +FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ 1.313 + scaled_nearest_scanline_##cputype##_##name##_##op,\ 1.314 + src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \ 1.315 +FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ 1.316 + scaled_nearest_scanline_##cputype##_##name##_##op,\ 1.317 + src_type, uint8_t, dst_type, PAD, TRUE, FALSE) \ 1.318 +FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ 1.319 + scaled_nearest_scanline_##cputype##_##name##_##op,\ 1.320 + src_type, uint8_t, dst_type, NORMAL, TRUE, FALSE) 1.321 + 1.322 +/* Provide entries for the fast path table */ 1.323 +#define PIXMAN_ARM_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \ 1.324 + SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \ 1.325 + SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \ 1.326 + SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func), \ 1.327 + SIMPLE_NEAREST_A8_MASK_FAST_PATH_NORMAL (op,s,d,func) 1.328 + 1.329 +/*****************************************************************************/ 1.330 + 1.331 +#define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op, \ 1.332 + src_type, dst_type) \ 1.333 +void \ 1.334 +pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ 1.335 + dst_type * dst, \ 1.336 + const src_type * top, \ 1.337 + const src_type * bottom, \ 1.338 + int wt, \ 1.339 + int wb, \ 1.340 + pixman_fixed_t x, \ 1.341 + pixman_fixed_t ux, \ 1.342 + int width); \ 1.343 + \ 1.344 +static force_inline void \ 1.345 +scaled_bilinear_scanline_##cputype##_##name##_##op ( \ 1.346 + dst_type * dst, \ 1.347 + const uint32_t * mask, \ 1.348 + const src_type * src_top, \ 1.349 + const src_type * src_bottom, \ 1.350 + int32_t w, \ 1.351 + int wt, \ 1.352 + int wb, \ 1.353 + pixman_fixed_t vx, \ 1.354 + pixman_fixed_t unit_x, \ 1.355 + pixman_fixed_t max_vx, \ 1.356 + pixman_bool_t zero_src) \ 1.357 +{ \ 1.358 + if ((flags & SKIP_ZERO_SRC) && zero_src) \ 1.359 + return; \ 1.360 + pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ 1.361 + dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \ 1.362 +} \ 1.363 + \ 1.364 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ 1.365 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.366 + NULL, src_type, uint32_t, dst_type, COVER, FLAG_NONE) \ 1.367 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ 1.368 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.369 + NULL, src_type, uint32_t, dst_type, NONE, FLAG_NONE) \ 1.370 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ 1.371 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.372 + NULL, src_type, uint32_t, dst_type, PAD, FLAG_NONE) \ 1.373 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ 1.374 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.375 + NULL, src_type, uint32_t, dst_type, NORMAL, \ 1.376 + FLAG_NONE) 1.377 + 1.378 + 1.379 +#define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \ 1.380 + src_type, dst_type) \ 1.381 +void \ 1.382 +pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ 1.383 + dst_type * dst, \ 1.384 + const uint8_t * mask, \ 1.385 + const src_type * top, \ 1.386 + const src_type * bottom, \ 1.387 + int wt, \ 1.388 + int wb, \ 1.389 + pixman_fixed_t x, \ 1.390 + pixman_fixed_t ux, \ 1.391 + int width); \ 1.392 + \ 1.393 +static force_inline void \ 1.394 +scaled_bilinear_scanline_##cputype##_##name##_##op ( \ 1.395 + dst_type * dst, \ 1.396 + const uint8_t * mask, \ 1.397 + const src_type * src_top, \ 1.398 + const src_type * src_bottom, \ 1.399 + int32_t w, \ 1.400 + int wt, \ 1.401 + int wb, \ 1.402 + pixman_fixed_t vx, \ 1.403 + pixman_fixed_t unit_x, \ 1.404 + pixman_fixed_t max_vx, \ 1.405 + pixman_bool_t zero_src) \ 1.406 +{ \ 1.407 + if ((flags & SKIP_ZERO_SRC) && zero_src) \ 1.408 + return; \ 1.409 + pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \ 1.410 + dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \ 1.411 +} \ 1.412 + \ 1.413 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \ 1.414 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.415 + NULL, src_type, uint8_t, dst_type, COVER, \ 1.416 + FLAG_HAVE_NON_SOLID_MASK) \ 1.417 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \ 1.418 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.419 + NULL, src_type, uint8_t, dst_type, NONE, \ 1.420 + FLAG_HAVE_NON_SOLID_MASK) \ 1.421 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \ 1.422 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.423 + NULL, src_type, uint8_t, dst_type, PAD, \ 1.424 + FLAG_HAVE_NON_SOLID_MASK) \ 1.425 +FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \ 1.426 + scaled_bilinear_scanline_##cputype##_##name##_##op, \ 1.427 + NULL, src_type, uint8_t, dst_type, NORMAL, \ 1.428 + FLAG_HAVE_NON_SOLID_MASK) 1.429 + 1.430 + 1.431 +#endif