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, \
66 pixman_composite_info_t *info) \
68 PIXMAN_COMPOSITE_ARGS (info); \
71 int32_t dst_stride, src_stride; \
73 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
74 src_stride, src_line, src_cnt); \
75 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
76 dst_stride, dst_line, dst_cnt); \
78 pixman_composite_##name##_asm_##cputype (width, height, \
79 dst_line, dst_stride, \
80 src_line, src_stride); \
83 #define PIXMAN_ARM_BIND_FAST_PATH_N_DST(flags, cputype, name, \
86 pixman_composite_##name##_asm_##cputype (int32_t w, \
93 cputype##_composite_##name (pixman_implementation_t *imp, \
94 pixman_composite_info_t *info) \
96 PIXMAN_COMPOSITE_ARGS (info); \
101 src = _pixman_image_get_solid ( \
102 imp, src_image, dest_image->bits.format); \
104 if ((flags & SKIP_ZERO_SRC) && src == 0) \
107 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
108 dst_stride, dst_line, dst_cnt); \
110 pixman_composite_##name##_asm_##cputype (width, height, \
111 dst_line, dst_stride, \
115 #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name, \
116 mask_type, mask_cnt, \
119 pixman_composite_##name##_asm_##cputype (int32_t w, \
122 int32_t dst_stride, \
126 int32_t mask_stride); \
129 cputype##_composite_##name (pixman_implementation_t *imp, \
130 pixman_composite_info_t *info) \
132 PIXMAN_COMPOSITE_ARGS (info); \
133 dst_type *dst_line; \
134 mask_type *mask_line; \
135 int32_t dst_stride, mask_stride; \
138 src = _pixman_image_get_solid ( \
139 imp, src_image, dest_image->bits.format); \
141 if ((flags & SKIP_ZERO_SRC) && src == 0) \
144 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
145 dst_stride, dst_line, dst_cnt); \
146 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
147 mask_stride, mask_line, mask_cnt); \
149 pixman_composite_##name##_asm_##cputype (width, height, \
150 dst_line, dst_stride, \
152 mask_line, mask_stride); \
155 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name, \
159 pixman_composite_##name##_asm_##cputype (int32_t w, \
162 int32_t dst_stride, \
164 int32_t src_stride, \
168 cputype##_composite_##name (pixman_implementation_t *imp, \
169 pixman_composite_info_t *info) \
171 PIXMAN_COMPOSITE_ARGS (info); \
172 dst_type *dst_line; \
173 src_type *src_line; \
174 int32_t dst_stride, src_stride; \
177 mask = _pixman_image_get_solid ( \
178 imp, mask_image, dest_image->bits.format); \
180 if ((flags & SKIP_ZERO_MASK) && mask == 0) \
183 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
184 dst_stride, dst_line, dst_cnt); \
185 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
186 src_stride, src_line, src_cnt); \
188 pixman_composite_##name##_asm_##cputype (width, height, \
189 dst_line, dst_stride, \
190 src_line, src_stride, \
194 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name, \
196 mask_type, mask_cnt, \
199 pixman_composite_##name##_asm_##cputype (int32_t w, \
202 int32_t dst_stride, \
204 int32_t src_stride, \
206 int32_t mask_stride); \
209 cputype##_composite_##name (pixman_implementation_t *imp, \
210 pixman_composite_info_t *info) \
212 PIXMAN_COMPOSITE_ARGS (info); \
213 dst_type *dst_line; \
214 src_type *src_line; \
215 mask_type *mask_line; \
216 int32_t dst_stride, src_stride, mask_stride; \
218 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
219 dst_stride, dst_line, dst_cnt); \
220 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \
221 src_stride, src_line, src_cnt); \
222 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \
223 mask_stride, mask_line, mask_cnt); \
225 pixman_composite_##name##_asm_##cputype (width, height, \
226 dst_line, dst_stride, \
227 src_line, src_stride, \
228 mask_line, mask_stride); \
231 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op, \
232 src_type, dst_type) \
234 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
237 const src_type * src, \
239 pixman_fixed_t unit_x); \
241 static force_inline void \
242 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \
243 const src_type * ps, \
246 pixman_fixed_t unit_x, \
247 pixman_fixed_t max_vx, \
248 pixman_bool_t zero_src) \
250 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
254 FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \
255 scaled_nearest_scanline_##cputype##_##name##_##op, \
256 src_type, dst_type, COVER) \
257 FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \
258 scaled_nearest_scanline_##cputype##_##name##_##op, \
259 src_type, dst_type, NONE) \
260 FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \
261 scaled_nearest_scanline_##cputype##_##name##_##op, \
262 src_type, dst_type, PAD)
264 /* Provide entries for the fast path table */
265 #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \
266 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \
267 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \
268 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func)
270 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op, \
271 src_type, dst_type) \
273 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
276 const src_type * src, \
278 pixman_fixed_t unit_x, \
279 const uint8_t * mask); \
281 static force_inline void \
282 scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t * mask, \
284 const src_type * ps, \
287 pixman_fixed_t unit_x, \
288 pixman_fixed_t max_vx, \
289 pixman_bool_t zero_src) \
291 if ((flags & SKIP_ZERO_SRC) && zero_src) \
293 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
298 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
299 scaled_nearest_scanline_##cputype##_##name##_##op,\
300 src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\
301 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
302 scaled_nearest_scanline_##cputype##_##name##_##op,\
303 src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
304 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
305 scaled_nearest_scanline_##cputype##_##name##_##op,\
306 src_type, uint8_t, dst_type, PAD, TRUE, FALSE)
308 /* Provide entries for the fast path table */
309 #define PIXMAN_ARM_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \
310 SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \
311 SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \
312 SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func)
314 /*****************************************************************************/
316 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op, \
317 src_type, dst_type) \
319 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
321 const src_type * top, \
322 const src_type * bottom, \
329 static force_inline void \
330 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
332 const uint32_t * mask, \
333 const src_type * src_top, \
334 const src_type * src_bottom, \
339 pixman_fixed_t unit_x, \
340 pixman_fixed_t max_vx, \
341 pixman_bool_t zero_src) \
343 if ((flags & SKIP_ZERO_SRC) && zero_src) \
345 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
346 dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \
349 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
350 scaled_bilinear_scanline_##cputype##_##name##_##op, \
351 src_type, uint32_t, dst_type, COVER, FLAG_NONE) \
352 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
353 scaled_bilinear_scanline_##cputype##_##name##_##op, \
354 src_type, uint32_t, dst_type, NONE, FLAG_NONE) \
355 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
356 scaled_bilinear_scanline_##cputype##_##name##_##op, \
357 src_type, uint32_t, dst_type, PAD, FLAG_NONE)
360 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \
361 src_type, dst_type) \
363 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
365 const uint8_t * mask, \
366 const src_type * top, \
367 const src_type * bottom, \
374 static force_inline void \
375 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
377 const uint8_t * mask, \
378 const src_type * src_top, \
379 const src_type * src_bottom, \
384 pixman_fixed_t unit_x, \
385 pixman_fixed_t max_vx, \
386 pixman_bool_t zero_src) \
388 if ((flags & SKIP_ZERO_SRC) && zero_src) \
390 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
391 dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
394 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
395 scaled_bilinear_scanline_##cputype##_##name##_##op, \
396 src_type, uint8_t, dst_type, COVER, \
397 FLAG_HAVE_NON_SOLID_MASK) \
398 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
399 scaled_bilinear_scanline_##cputype##_##name##_##op, \
400 src_type, uint8_t, dst_type, NONE, \
401 FLAG_HAVE_NON_SOLID_MASK) \
402 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
403 scaled_bilinear_scanline_##cputype##_##name##_##op, \
404 src_type, uint8_t, dst_type, PAD, \
405 FLAG_HAVE_NON_SOLID_MASK)