2 * Copyright © 2010 Nokia Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Author: Siarhei Siamashka (siarhei.siamashka@nokia.com)
26 #ifndef PIXMAN_ARM_COMMON_H
27 #define PIXMAN_ARM_COMMON_H
29 #include "pixman-fast-path.h"
31 /* Define some macros which can expand into proxy functions between
32 * ARM assembly optimized functions and the rest of pixman fast path API.
34 * All the low level ARM assembly functions have to use ARM EABI
35 * calling convention and take up to 8 arguments:
36 * width, height, dst, dst_stride, src, src_stride, mask, mask_stride
38 * The arguments are ordered with the most important coming first (the
39 * first 4 arguments are passed to function in registers, the rest are
40 * on stack). The last arguments are optional, for example if the
41 * function is not using mask, then 'mask' and 'mask_stride' can be
42 * omitted when doing a function call.
44 * Arguments 'src' and 'mask' contain either a pointer to the top left
45 * pixel of the composited rectangle or a pixel color value depending
46 * on the function type. In the case of just a color value (solid source
47 * or mask), the corresponding stride argument is unused.
50 #define SKIP_ZERO_SRC 1
51 #define SKIP_ZERO_MASK 2
53 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_DST(cputype, name, \
57 pixman_composite_##name##_asm_##cputype (int32_t w, \
62 int32_t src_stride); \
65 cputype##_composite_##name (pixman_implementation_t *imp, \
67 pixman_image_t * src_image, \
68 pixman_image_t * mask_image, \
69 pixman_image_t * dst_image, \
81 int32_t dst_stride, src_stride; \
83 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
84 src_stride, src_line, src_cnt); \
85 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
86 dst_stride, dst_line, dst_cnt); \
88 pixman_composite_##name##_asm_##cputype (width, height, \
89 dst_line, dst_stride, \
90 src_line, src_stride); \
93 #define PIXMAN_ARM_BIND_FAST_PATH_N_DST(flags, cputype, name, \
96 pixman_composite_##name##_asm_##cputype (int32_t w, \
103 cputype##_composite_##name (pixman_implementation_t *imp, \
105 pixman_image_t * src_image, \
106 pixman_image_t * mask_image, \
107 pixman_image_t * dst_image, \
117 dst_type *dst_line; \
118 int32_t dst_stride; \
121 src = _pixman_image_get_solid (src_image, dst_image->bits.format); \
123 if ((flags & SKIP_ZERO_SRC) && src == 0) \
126 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
127 dst_stride, dst_line, dst_cnt); \
129 pixman_composite_##name##_asm_##cputype (width, height, \
130 dst_line, dst_stride, \
134 #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name, \
135 mask_type, mask_cnt, \
138 pixman_composite_##name##_asm_##cputype (int32_t w, \
141 int32_t dst_stride, \
145 int32_t mask_stride); \
148 cputype##_composite_##name (pixman_implementation_t *imp, \
150 pixman_image_t * src_image, \
151 pixman_image_t * mask_image, \
152 pixman_image_t * dst_image, \
162 dst_type *dst_line; \
163 mask_type *mask_line; \
164 int32_t dst_stride, mask_stride; \
167 src = _pixman_image_get_solid (src_image, dst_image->bits.format); \
169 if ((flags & SKIP_ZERO_SRC) && src == 0) \
172 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
173 dst_stride, dst_line, dst_cnt); \
174 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
175 mask_stride, mask_line, mask_cnt); \
177 pixman_composite_##name##_asm_##cputype (width, height, \
178 dst_line, dst_stride, \
180 mask_line, mask_stride); \
183 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name, \
187 pixman_composite_##name##_asm_##cputype (int32_t w, \
190 int32_t dst_stride, \
192 int32_t src_stride, \
196 cputype##_composite_##name (pixman_implementation_t *imp, \
198 pixman_image_t * src_image, \
199 pixman_image_t * mask_image, \
200 pixman_image_t * dst_image, \
210 dst_type *dst_line; \
211 src_type *src_line; \
212 int32_t dst_stride, src_stride; \
215 mask = _pixman_image_get_solid (mask_image, dst_image->bits.format);\
217 if ((flags & SKIP_ZERO_MASK) && mask == 0) \
220 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
221 dst_stride, dst_line, dst_cnt); \
222 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
223 src_stride, src_line, src_cnt); \
225 pixman_composite_##name##_asm_##cputype (width, height, \
226 dst_line, dst_stride, \
227 src_line, src_stride, \
231 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name, \
233 mask_type, mask_cnt, \
236 pixman_composite_##name##_asm_##cputype (int32_t w, \
239 int32_t dst_stride, \
241 int32_t src_stride, \
243 int32_t mask_stride); \
246 cputype##_composite_##name (pixman_implementation_t *imp, \
248 pixman_image_t * src_image, \
249 pixman_image_t * mask_image, \
250 pixman_image_t * dst_image, \
260 dst_type *dst_line; \
261 src_type *src_line; \
262 mask_type *mask_line; \
263 int32_t dst_stride, src_stride, mask_stride; \
265 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
266 dst_stride, dst_line, dst_cnt); \
267 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
268 src_stride, src_line, src_cnt); \
269 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
270 mask_stride, mask_line, mask_cnt); \
272 pixman_composite_##name##_asm_##cputype (width, height, \
273 dst_line, dst_stride, \
274 src_line, src_stride, \
275 mask_line, mask_stride); \
278 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op, \
279 src_type, dst_type) \
281 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
286 pixman_fixed_t unit_x);\
288 static force_inline void \
289 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \
293 pixman_fixed_t unit_x, \
294 pixman_fixed_t max_vx) \
296 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
300 FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \
301 scaled_nearest_scanline_##cputype##_##name##_##op, \
302 src_type, dst_type, COVER) \
303 FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \
304 scaled_nearest_scanline_##cputype##_##name##_##op, \
305 src_type, dst_type, NONE) \
306 FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \
307 scaled_nearest_scanline_##cputype##_##name##_##op, \
308 src_type, dst_type, PAD)
310 /* Provide entries for the fast path table */
311 #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \
312 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \
313 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \
314 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func)