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-inlines.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, \
240 pixman_fixed_t max_vx); \
242 static force_inline void \
243 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type * pd, \
244 const src_type * ps, \
247 pixman_fixed_t unit_x, \
248 pixman_fixed_t max_vx, \
249 pixman_bool_t zero_src) \
251 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
256 FAST_NEAREST_MAINLOOP (cputype##_##name##_cover_##op, \
257 scaled_nearest_scanline_##cputype##_##name##_##op, \
258 src_type, dst_type, COVER) \
259 FAST_NEAREST_MAINLOOP (cputype##_##name##_none_##op, \
260 scaled_nearest_scanline_##cputype##_##name##_##op, \
261 src_type, dst_type, NONE) \
262 FAST_NEAREST_MAINLOOP (cputype##_##name##_pad_##op, \
263 scaled_nearest_scanline_##cputype##_##name##_##op, \
264 src_type, dst_type, PAD) \
265 FAST_NEAREST_MAINLOOP (cputype##_##name##_normal_##op, \
266 scaled_nearest_scanline_##cputype##_##name##_##op, \
267 src_type, dst_type, NORMAL)
269 /* Provide entries for the fast path table */
270 #define PIXMAN_ARM_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \
271 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \
272 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \
273 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func), \
274 SIMPLE_NEAREST_FAST_PATH_NORMAL (op,s,d,func)
276 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op, \
277 src_type, dst_type) \
279 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype ( \
282 const src_type * src, \
284 pixman_fixed_t unit_x, \
285 pixman_fixed_t max_vx, \
286 const uint8_t * mask); \
288 static force_inline void \
289 scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t * mask, \
291 const src_type * ps, \
294 pixman_fixed_t unit_x, \
295 pixman_fixed_t max_vx, \
296 pixman_bool_t zero_src) \
298 if ((flags & SKIP_ZERO_SRC) && zero_src) \
300 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps, \
306 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
307 scaled_nearest_scanline_##cputype##_##name##_##op,\
308 src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\
309 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
310 scaled_nearest_scanline_##cputype##_##name##_##op,\
311 src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
312 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
313 scaled_nearest_scanline_##cputype##_##name##_##op,\
314 src_type, uint8_t, dst_type, PAD, TRUE, FALSE) \
315 FAST_NEAREST_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \
316 scaled_nearest_scanline_##cputype##_##name##_##op,\
317 src_type, uint8_t, dst_type, NORMAL, TRUE, FALSE)
319 /* Provide entries for the fast path table */
320 #define PIXMAN_ARM_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \
321 SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \
322 SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \
323 SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func), \
324 SIMPLE_NEAREST_A8_MASK_FAST_PATH_NORMAL (op,s,d,func)
326 /*****************************************************************************/
328 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op, \
329 src_type, dst_type) \
331 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
333 const src_type * top, \
334 const src_type * bottom, \
341 static force_inline void \
342 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
344 const uint32_t * mask, \
345 const src_type * src_top, \
346 const src_type * src_bottom, \
351 pixman_fixed_t unit_x, \
352 pixman_fixed_t max_vx, \
353 pixman_bool_t zero_src) \
355 if ((flags & SKIP_ZERO_SRC) && zero_src) \
357 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
358 dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \
361 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
362 scaled_bilinear_scanline_##cputype##_##name##_##op, \
363 src_type, uint32_t, dst_type, COVER, FLAG_NONE) \
364 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
365 scaled_bilinear_scanline_##cputype##_##name##_##op, \
366 src_type, uint32_t, dst_type, NONE, FLAG_NONE) \
367 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
368 scaled_bilinear_scanline_##cputype##_##name##_##op, \
369 src_type, uint32_t, dst_type, PAD, FLAG_NONE) \
370 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \
371 scaled_bilinear_scanline_##cputype##_##name##_##op, \
372 src_type, uint32_t, dst_type, NORMAL, \
376 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \
377 src_type, dst_type) \
379 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
381 const uint8_t * mask, \
382 const src_type * top, \
383 const src_type * bottom, \
390 static force_inline void \
391 scaled_bilinear_scanline_##cputype##_##name##_##op ( \
393 const uint8_t * mask, \
394 const src_type * src_top, \
395 const src_type * src_bottom, \
400 pixman_fixed_t unit_x, \
401 pixman_fixed_t max_vx, \
402 pixman_bool_t zero_src) \
404 if ((flags & SKIP_ZERO_SRC) && zero_src) \
406 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
407 dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
410 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
411 scaled_bilinear_scanline_##cputype##_##name##_##op, \
412 src_type, uint8_t, dst_type, COVER, \
413 FLAG_HAVE_NON_SOLID_MASK) \
414 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
415 scaled_bilinear_scanline_##cputype##_##name##_##op, \
416 src_type, uint8_t, dst_type, NONE, \
417 FLAG_HAVE_NON_SOLID_MASK) \
418 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
419 scaled_bilinear_scanline_##cputype##_##name##_##op, \
420 src_type, uint8_t, dst_type, PAD, \
421 FLAG_HAVE_NON_SOLID_MASK) \
422 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \
423 scaled_bilinear_scanline_##cputype##_##name##_##op, \
424 src_type, uint8_t, dst_type, NORMAL, \
425 FLAG_HAVE_NON_SOLID_MASK)