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 * dest_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 (dest_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 * dest_image, \
117 dst_type *dst_line; \
118 int32_t dst_stride; \
121 src = _pixman_image_get_solid ( \
122 imp, src_image, dest_image->bits.format); \
124 if ((flags & SKIP_ZERO_SRC) && src == 0) \
127 PIXMAN_IMAGE_GET_LINE (dest_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 * dest_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, dest_image->bits.format); \
171 if ((flags & SKIP_ZERO_SRC) && src == 0) \
174 PIXMAN_IMAGE_GET_LINE (dest_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 * dest_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, dest_image->bits.format); \
220 if ((flags & SKIP_ZERO_MASK) && mask == 0) \
223 PIXMAN_IMAGE_GET_LINE (dest_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 * dest_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 (dest_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 ( \
287 const src_type * src, \
289 pixman_fixed_t unit_x); \
291 static force_inline void \
292 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \
293 const src_type * ps, \
296 pixman_fixed_t unit_x, \
297 pixman_fixed_t max_vx, \
298 pixman_bool_t zero_src) \
300 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
304 FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \
305 scaled_nearest_scanline_##cputype##_##name##_##op, \
306 src_type, dst_type, COVER) \
307 FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \
308 scaled_nearest_scanline_##cputype##_##name##_##op, \
309 src_type, dst_type, NONE) \
310 FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \
311 scaled_nearest_scanline_##cputype##_##name##_##op, \
312 src_type, dst_type, PAD)
314 /* Provide entries for the fast path table */
315 #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \
316 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \
317 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \
318 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func)
320 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op, \
321 src_type, dst_type) \
323 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
326 const src_type * src, \
328 pixman_fixed_t unit_x, \
329 const uint8_t * mask); \
331 static force_inline void \
332 scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t * mask, \
334 const src_type * ps, \
337 pixman_fixed_t unit_x, \
338 pixman_fixed_t max_vx, \
339 pixman_bool_t zero_src) \
341 if ((flags & SKIP_ZERO_SRC) && zero_src) \
343 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
348 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
349 scaled_nearest_scanline_##cputype##_##name##_##op,\
350 src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\
351 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
352 scaled_nearest_scanline_##cputype##_##name##_##op,\
353 src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
354 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
355 scaled_nearest_scanline_##cputype##_##name##_##op,\
356 src_type, uint8_t, dst_type, PAD, TRUE, FALSE)
358 /* Provide entries for the fast path table */
359 #define PIXMAN_ARM_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \
360 SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \
361 SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \
362 SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func)
364 /*****************************************************************************/
366 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op, \
367 src_type, dst_type) \
369 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
371 const src_type * top, \
372 const src_type * bottom, \
379 static force_inline void \
380 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
382 const uint32_t * mask, \
383 const src_type * src_top, \
384 const src_type * src_bottom, \
389 pixman_fixed_t unit_x, \
390 pixman_fixed_t max_vx, \
391 pixman_bool_t zero_src) \
393 if ((flags & SKIP_ZERO_SRC) && zero_src) \
395 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
396 dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \
399 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
400 scaled_bilinear_scanline_##cputype##_##name##_##op, \
401 src_type, uint32_t, dst_type, COVER, FALSE, FALSE) \
402 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
403 scaled_bilinear_scanline_##cputype##_##name##_##op, \
404 src_type, uint32_t, dst_type, NONE, FALSE, FALSE) \
405 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
406 scaled_bilinear_scanline_##cputype##_##name##_##op, \
407 src_type, uint32_t, dst_type, PAD, FALSE, FALSE)
410 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \
411 src_type, dst_type) \
413 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
415 const uint8_t * mask, \
416 const src_type * top, \
417 const src_type * bottom, \
424 static force_inline void \
425 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
427 const uint8_t * mask, \
428 const src_type * src_top, \
429 const src_type * src_bottom, \
434 pixman_fixed_t unit_x, \
435 pixman_fixed_t max_vx, \
436 pixman_bool_t zero_src) \
438 if ((flags & SKIP_ZERO_SRC) && zero_src) \
440 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
441 dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
444 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
445 scaled_bilinear_scanline_##cputype##_##name##_##op, \
446 src_type, uint8_t, dst_type, COVER, TRUE, FALSE) \
447 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
448 scaled_bilinear_scanline_##cputype##_##name##_##op, \
449 src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
450 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
451 scaled_bilinear_scanline_##cputype##_##name##_##op, \
452 src_type, uint8_t, dst_type, PAD, TRUE, FALSE)