Use MAKE_ACCESSORS() to generate accessors for the a1 format.
[profile/ivi/pixman.git] / pixman / pixman-arm-common.h
1 /*
2  * Copyright © 2010 Nokia Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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.
22  *
23  * Author:  Siarhei Siamashka (siarhei.siamashka@nokia.com)
24  */
25
26 #ifndef PIXMAN_ARM_COMMON_H
27 #define PIXMAN_ARM_COMMON_H
28
29 #include "pixman-inlines.h"
30
31 /* Define some macros which can expand into proxy functions between
32  * ARM assembly optimized functions and the rest of pixman fast path API.
33  *
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
37  *
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.
43  *
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.
48  */
49
50 #define SKIP_ZERO_SRC  1
51 #define SKIP_ZERO_MASK 2
52
53 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_DST(cputype, name,                \
54                                           src_type, src_cnt,            \
55                                           dst_type, dst_cnt)            \
56 void                                                                    \
57 pixman_composite_##name##_asm_##cputype (int32_t   w,                   \
58                                          int32_t   h,                   \
59                                          dst_type *dst,                 \
60                                          int32_t   dst_stride,          \
61                                          src_type *src,                 \
62                                          int32_t   src_stride);         \
63                                                                         \
64 static void                                                             \
65 cputype##_composite_##name (pixman_implementation_t *imp,               \
66                             pixman_composite_info_t *info)              \
67 {                                                                       \
68     PIXMAN_COMPOSITE_ARGS (info);                                       \
69     dst_type *dst_line;                                                 \
70     src_type *src_line;                                                 \
71     int32_t dst_stride, src_stride;                                     \
72                                                                         \
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);              \
77                                                                         \
78     pixman_composite_##name##_asm_##cputype (width, height,             \
79                                              dst_line, dst_stride,      \
80                                              src_line, src_stride);     \
81 }
82
83 #define PIXMAN_ARM_BIND_FAST_PATH_N_DST(flags, cputype, name,           \
84                                         dst_type, dst_cnt)              \
85 void                                                                    \
86 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
87                                          int32_t    h,                  \
88                                          dst_type  *dst,                \
89                                          int32_t    dst_stride,         \
90                                          uint32_t   src);               \
91                                                                         \
92 static void                                                             \
93 cputype##_composite_##name (pixman_implementation_t *imp,               \
94                             pixman_composite_info_t *info)              \
95 {                                                                       \
96     PIXMAN_COMPOSITE_ARGS (info);                                       \
97     dst_type  *dst_line;                                                \
98     int32_t    dst_stride;                                              \
99     uint32_t   src;                                                     \
100                                                                         \
101     src = _pixman_image_get_solid (                                     \
102         imp, src_image, dest_image->bits.format);                       \
103                                                                         \
104     if ((flags & SKIP_ZERO_SRC) && src == 0)                            \
105         return;                                                         \
106                                                                         \
107     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type,        \
108                            dst_stride, dst_line, dst_cnt);              \
109                                                                         \
110     pixman_composite_##name##_asm_##cputype (width, height,             \
111                                              dst_line, dst_stride,      \
112                                              src);                      \
113 }
114
115 #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(flags, cputype, name,      \
116                                              mask_type, mask_cnt,       \
117                                              dst_type, dst_cnt)         \
118 void                                                                    \
119 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
120                                          int32_t    h,                  \
121                                          dst_type  *dst,                \
122                                          int32_t    dst_stride,         \
123                                          uint32_t   src,                \
124                                          int32_t    unused,             \
125                                          mask_type *mask,               \
126                                          int32_t    mask_stride);       \
127                                                                         \
128 static void                                                             \
129 cputype##_composite_##name (pixman_implementation_t *imp,               \
130                             pixman_composite_info_t *info)              \
131 {                                                                       \
132     PIXMAN_COMPOSITE_ARGS (info);                                       \
133     dst_type  *dst_line;                                                \
134     mask_type *mask_line;                                               \
135     int32_t    dst_stride, mask_stride;                                 \
136     uint32_t   src;                                                     \
137                                                                         \
138     src = _pixman_image_get_solid (                                     \
139         imp, src_image, dest_image->bits.format);                       \
140                                                                         \
141     if ((flags & SKIP_ZERO_SRC) && src == 0)                            \
142         return;                                                         \
143                                                                         \
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);           \
148                                                                         \
149     pixman_composite_##name##_asm_##cputype (width, height,             \
150                                              dst_line, dst_stride,      \
151                                              src, 0,                    \
152                                              mask_line, mask_stride);   \
153 }
154
155 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(flags, cputype, name,       \
156                                             src_type, src_cnt,          \
157                                             dst_type, dst_cnt)          \
158 void                                                                    \
159 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
160                                          int32_t    h,                  \
161                                          dst_type  *dst,                \
162                                          int32_t    dst_stride,         \
163                                          src_type  *src,                \
164                                          int32_t    src_stride,         \
165                                          uint32_t   mask);              \
166                                                                         \
167 static void                                                             \
168 cputype##_composite_##name (pixman_implementation_t *imp,               \
169                             pixman_composite_info_t *info)              \
170 {                                                                       \
171     PIXMAN_COMPOSITE_ARGS (info);                                       \
172     dst_type  *dst_line;                                                \
173     src_type  *src_line;                                                \
174     int32_t    dst_stride, src_stride;                                  \
175     uint32_t   mask;                                                    \
176                                                                         \
177     mask = _pixman_image_get_solid (                                    \
178         imp, mask_image, dest_image->bits.format);                      \
179                                                                         \
180     if ((flags & SKIP_ZERO_MASK) && mask == 0)                          \
181         return;                                                         \
182                                                                         \
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);              \
187                                                                         \
188     pixman_composite_##name##_asm_##cputype (width, height,             \
189                                              dst_line, dst_stride,      \
190                                              src_line, src_stride,      \
191                                              mask);                     \
192 }
193
194 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name,           \
195                                                src_type, src_cnt,       \
196                                                mask_type, mask_cnt,     \
197                                                dst_type, dst_cnt)       \
198 void                                                                    \
199 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
200                                          int32_t    h,                  \
201                                          dst_type  *dst,                \
202                                          int32_t    dst_stride,         \
203                                          src_type  *src,                \
204                                          int32_t    src_stride,         \
205                                          mask_type *mask,               \
206                                          int32_t    mask_stride);       \
207                                                                         \
208 static void                                                             \
209 cputype##_composite_##name (pixman_implementation_t *imp,               \
210                             pixman_composite_info_t *info)              \
211 {                                                                       \
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;                     \
217                                                                         \
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);           \
224                                                                         \
225     pixman_composite_##name##_asm_##cputype (width, height,             \
226                                              dst_line, dst_stride,      \
227                                              src_line, src_stride,      \
228                                              mask_line, mask_stride);   \
229 }
230
231 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_DST(cputype, name, op,             \
232                                                src_type, dst_type)            \
233 void                                                                          \
234 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (                \
235                                                    int32_t          w,        \
236                                                    dst_type *       dst,      \
237                                                    const src_type * src,      \
238                                                    pixman_fixed_t   vx,       \
239                                                    pixman_fixed_t   unit_x);  \
240                                                                               \
241 static force_inline void                                                      \
242 scaled_nearest_scanline_##cputype##_##name##_##op (dst_type *       pd,       \
243                                                    const src_type * ps,       \
244                                                    int32_t          w,        \
245                                                    pixman_fixed_t   vx,       \
246                                                    pixman_fixed_t   unit_x,   \
247                                                    pixman_fixed_t   max_vx,   \
248                                                    pixman_bool_t    zero_src) \
249 {                                                                             \
250     pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps,  \
251                                                                   vx, unit_x);\
252 }                                                                             \
253                                                                               \
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)
263
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)
269
270 #define PIXMAN_ARM_BIND_SCALED_NEAREST_SRC_A8_DST(flags, cputype, name, op,   \
271                                                   src_type, dst_type)         \
272 void                                                                          \
273 pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (                \
274                                                    int32_t          w,        \
275                                                    dst_type *       dst,      \
276                                                    const src_type * src,      \
277                                                    pixman_fixed_t   vx,       \
278                                                    pixman_fixed_t   unit_x,   \
279                                                    const uint8_t *  mask);    \
280                                                                               \
281 static force_inline void                                                      \
282 scaled_nearest_scanline_##cputype##_##name##_##op (const uint8_t *  mask,     \
283                                                    dst_type *       pd,       \
284                                                    const src_type * ps,       \
285                                                    int32_t          w,        \
286                                                    pixman_fixed_t   vx,       \
287                                                    pixman_fixed_t   unit_x,   \
288                                                    pixman_fixed_t   max_vx,   \
289                                                    pixman_bool_t    zero_src) \
290 {                                                                             \
291     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
292         return;                                                               \
293     pixman_scaled_nearest_scanline_##name##_##op##_asm_##cputype (w, pd, ps,  \
294                                                                   vx, unit_x, \
295                                                                   mask);      \
296 }                                                                             \
297                                                                               \
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)
307
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)
313
314 /*****************************************************************************/
315
316 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST(flags, cputype, name, op,     \
317                                                 src_type, dst_type)           \
318 void                                                                          \
319 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype (               \
320                                                 dst_type *       dst,         \
321                                                 const src_type * top,         \
322                                                 const src_type * bottom,      \
323                                                 int              wt,          \
324                                                 int              wb,          \
325                                                 pixman_fixed_t   x,           \
326                                                 pixman_fixed_t   ux,          \
327                                                 int              width);      \
328                                                                               \
329 static force_inline void                                                      \
330 scaled_bilinear_scanline_##cputype##_##name##_##op (                          \
331                                                 dst_type *       dst,         \
332                                                 const uint32_t * mask,        \
333                                                 const src_type * src_top,     \
334                                                 const src_type * src_bottom,  \
335                                                 int32_t          w,           \
336                                                 int              wt,          \
337                                                 int              wb,          \
338                                                 pixman_fixed_t   vx,          \
339                                                 pixman_fixed_t   unit_x,      \
340                                                 pixman_fixed_t   max_vx,      \
341                                                 pixman_bool_t    zero_src)    \
342 {                                                                             \
343     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
344         return;                                                               \
345     pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype (           \
346                             dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \
347 }                                                                             \
348                                                                               \
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)          \
358 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op,                \
359                        scaled_bilinear_scanline_##cputype##_##name##_##op,    \
360                        src_type, uint32_t, dst_type, NORMAL,                  \
361                        FLAG_NONE)
362
363
364 #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op,  \
365                                                 src_type, dst_type)           \
366 void                                                                          \
367 pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype (               \
368                                                 dst_type *       dst,         \
369                                                 const uint8_t *  mask,        \
370                                                 const src_type * top,         \
371                                                 const src_type * bottom,      \
372                                                 int              wt,          \
373                                                 int              wb,          \
374                                                 pixman_fixed_t   x,           \
375                                                 pixman_fixed_t   ux,          \
376                                                 int              width);      \
377                                                                               \
378 static force_inline void                                                      \
379 scaled_bilinear_scanline_##cputype##_##name##_##op (                          \
380                                                 dst_type *       dst,         \
381                                                 const uint8_t *  mask,        \
382                                                 const src_type * src_top,     \
383                                                 const src_type * src_bottom,  \
384                                                 int32_t          w,           \
385                                                 int              wt,          \
386                                                 int              wb,          \
387                                                 pixman_fixed_t   vx,          \
388                                                 pixman_fixed_t   unit_x,      \
389                                                 pixman_fixed_t   max_vx,      \
390                                                 pixman_bool_t    zero_src)    \
391 {                                                                             \
392     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
393         return;                                                                   \
394     pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype (           \
395                       dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
396 }                                                                             \
397                                                                               \
398 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op,                 \
399                        scaled_bilinear_scanline_##cputype##_##name##_##op,    \
400                        src_type, uint8_t, dst_type, COVER,                    \
401                        FLAG_HAVE_NON_SOLID_MASK)                              \
402 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op,                  \
403                        scaled_bilinear_scanline_##cputype##_##name##_##op,    \
404                        src_type, uint8_t, dst_type, NONE,                     \
405                        FLAG_HAVE_NON_SOLID_MASK)                              \
406 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op,                   \
407                        scaled_bilinear_scanline_##cputype##_##name##_##op,    \
408                        src_type, uint8_t, dst_type, PAD,                      \
409                        FLAG_HAVE_NON_SOLID_MASK)                              \
410 FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op,                \
411                        scaled_bilinear_scanline_##cputype##_##name##_##op,    \
412                        src_type, uint8_t, dst_type, NORMAL,                   \
413                        FLAG_HAVE_NON_SOLID_MASK)
414
415
416 #endif