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 ( \
122 imp, src_image, dst_image->bits.format); \
124 if ((flags & SKIP_ZERO_SRC) && src == 0) \
127 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
128 dst_stride, dst_line, dst_cnt); \
130 pixman_composite_##name##_asm_##cputype (width, height, \
131 dst_line, dst_stride, \
135 #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name, \
136 mask_type, mask_cnt, \
139 pixman_composite_##name##_asm_##cputype (int32_t w, \
142 int32_t dst_stride, \
146 int32_t mask_stride); \
149 cputype##_composite_##name (pixman_implementation_t *imp, \
151 pixman_image_t * src_image, \
152 pixman_image_t * mask_image, \
153 pixman_image_t * dst_image, \
163 dst_type *dst_line; \
164 mask_type *mask_line; \
165 int32_t dst_stride, mask_stride; \
168 src = _pixman_image_get_solid ( \
169 imp, src_image, dst_image->bits.format); \
171 if ((flags & SKIP_ZERO_SRC) && src == 0) \
174 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
175 dst_stride, dst_line, dst_cnt); \
176 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
177 mask_stride, mask_line, mask_cnt); \
179 pixman_composite_##name##_asm_##cputype (width, height, \
180 dst_line, dst_stride, \
182 mask_line, mask_stride); \
185 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name, \
189 pixman_composite_##name##_asm_##cputype (int32_t w, \
192 int32_t dst_stride, \
194 int32_t src_stride, \
198 cputype##_composite_##name (pixman_implementation_t *imp, \
200 pixman_image_t * src_image, \
201 pixman_image_t * mask_image, \
202 pixman_image_t * dst_image, \
212 dst_type *dst_line; \
213 src_type *src_line; \
214 int32_t dst_stride, src_stride; \
217 mask = _pixman_image_get_solid ( \
218 imp, mask_image, dst_image->bits.format); \
220 if ((flags & SKIP_ZERO_MASK) && mask == 0) \
223 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
224 dst_stride, dst_line, dst_cnt); \
225 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
226 src_stride, src_line, src_cnt); \
228 pixman_composite_##name##_asm_##cputype (width, height, \
229 dst_line, dst_stride, \
230 src_line, src_stride, \
234 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name, \
236 mask_type, mask_cnt, \
239 pixman_composite_##name##_asm_##cputype (int32_t w, \
242 int32_t dst_stride, \
244 int32_t src_stride, \
246 int32_t mask_stride); \
249 cputype##_composite_##name (pixman_implementation_t *imp, \
251 pixman_image_t * src_image, \
252 pixman_image_t * mask_image, \
253 pixman_image_t * dst_image, \
263 dst_type *dst_line; \
264 src_type *src_line; \
265 mask_type *mask_line; \
266 int32_t dst_stride, src_stride, mask_stride; \
268 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type, \
269 dst_stride, dst_line, dst_cnt); \
270 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
271 src_stride, src_line, src_cnt); \
272 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
273 mask_stride, mask_line, mask_cnt); \
275 pixman_composite_##name##_asm_##cputype (width, height, \
276 dst_line, dst_stride, \
277 src_line, src_stride, \
278 mask_line, mask_stride); \
281 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op, \
282 src_type, dst_type) \
284 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
289 pixman_fixed_t unit_x);\
291 static force_inline void \
292 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \
296 pixman_fixed_t unit_x, \
297 pixman_fixed_t max_vx) \
299 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
303 FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \
304 scaled_nearest_scanline_##cputype##_##name##_##op, \
305 src_type, dst_type, COVER) \
306 FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \
307 scaled_nearest_scanline_##cputype##_##name##_##op, \
308 src_type, dst_type, NONE) \
309 FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \
310 scaled_nearest_scanline_##cputype##_##name##_##op, \
311 src_type, dst_type, PAD)
313 /* Provide entries for the fast path table */
314 #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \
315 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \
316 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \
317 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func)