ARM: Helper ARM NEON assembly binding macros moved into a separate header
[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 /* Define some macros which can expand into proxy functions between
30  * ARM assembly optimized functions and the rest of pixman fast path API.
31  *
32  * All the low level ARM assembly functions have to use ARM EABI
33  * calling convention and take up to 8 arguments:
34  *    width, height, dst, dst_stride, src, src_stride, mask, mask_stride
35  *
36  * The arguments are ordered with the most important coming first (the
37  * first 4 arguments are passed to function in registers, the rest are
38  * on stack). The last arguments are optional, for example if the
39  * function is not using mask, then 'mask' and 'mask_stride' can be
40  * omitted when doing a function call.
41  *
42  * Arguments 'src' and 'mask' contain either a pointer to the top left
43  * pixel of the composited rectangle or a pixel color value depending
44  * on the function type. In the case of just a color value (solid source
45  * or mask), the corresponding stride argument is unused.
46  */
47
48 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_DST(cputype, name,                \
49                                           src_type, src_cnt,            \
50                                           dst_type, dst_cnt)            \
51 void                                                                    \
52 pixman_composite_##name##_asm_##cputype (int32_t   w,                   \
53                                          int32_t   h,                   \
54                                          dst_type *dst,                 \
55                                          int32_t   dst_stride,          \
56                                          src_type *src,                 \
57                                          int32_t   src_stride);         \
58                                                                         \
59 static void                                                             \
60 cputype##_composite_##name (pixman_implementation_t *imp,               \
61                             pixman_op_t              op,                \
62                             pixman_image_t *         src_image,         \
63                             pixman_image_t *         mask_image,        \
64                             pixman_image_t *         dst_image,         \
65                             int32_t                  src_x,             \
66                             int32_t                  src_y,             \
67                             int32_t                  mask_x,            \
68                             int32_t                  mask_y,            \
69                             int32_t                  dest_x,            \
70                             int32_t                  dest_y,            \
71                             int32_t                  width,             \
72                             int32_t                  height)            \
73 {                                                                       \
74     dst_type *dst_line;                                                 \
75     src_type *src_line;                                                 \
76     int32_t dst_stride, src_stride;                                     \
77                                                                         \
78     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,           \
79                            src_stride, src_line, src_cnt);              \
80     PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type,         \
81                            dst_stride, dst_line, dst_cnt);              \
82                                                                         \
83     pixman_composite_##name##_asm_##cputype (width, height,             \
84                                              dst_line, dst_stride,      \
85                                              src_line, src_stride);     \
86 }
87
88 #define PIXMAN_ARM_BIND_FAST_PATH_N_DST(cputype, name,                  \
89                                         dst_type, dst_cnt)              \
90 void                                                                    \
91 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
92                                          int32_t    h,                  \
93                                          dst_type  *dst,                \
94                                          int32_t    dst_stride,         \
95                                          uint32_t   src);               \
96                                                                         \
97 static void                                                             \
98 cputype##_composite_##name (pixman_implementation_t *imp,               \
99                             pixman_op_t              op,                \
100                             pixman_image_t *         src_image,         \
101                             pixman_image_t *         mask_image,        \
102                             pixman_image_t *         dst_image,         \
103                             int32_t                  src_x,             \
104                             int32_t                  src_y,             \
105                             int32_t                  mask_x,            \
106                             int32_t                  mask_y,            \
107                             int32_t                  dest_x,            \
108                             int32_t                  dest_y,            \
109                             int32_t                  width,             \
110                             int32_t                  height)            \
111 {                                                                       \
112     dst_type  *dst_line;                                                \
113     int32_t    dst_stride;                                              \
114     uint32_t   src;                                                     \
115                                                                         \
116     src = _pixman_image_get_solid (src_image, dst_image->bits.format);  \
117                                                                         \
118     if (src == 0)                                                       \
119         return;                                                         \
120                                                                         \
121     PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type,         \
122                            dst_stride, dst_line, dst_cnt);              \
123                                                                         \
124     pixman_composite_##name##_asm_##cputype (width, height,             \
125                                              dst_line, dst_stride,      \
126                                              src);                      \
127 }
128
129 #define PIXMAN_ARM_BIND_FAST_PATH_N_MASK_DST(cputype, name,             \
130                                              mask_type, mask_cnt,       \
131                                              dst_type, dst_cnt)         \
132 void                                                                    \
133 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
134                                          int32_t    h,                  \
135                                          dst_type  *dst,                \
136                                          int32_t    dst_stride,         \
137                                          uint32_t   src,                \
138                                          int32_t    unused,             \
139                                          mask_type *mask,               \
140                                          int32_t    mask_stride);       \
141                                                                         \
142 static void                                                             \
143 cputype##_composite_##name (pixman_implementation_t *imp,               \
144                             pixman_op_t              op,                \
145                             pixman_image_t *         src_image,         \
146                             pixman_image_t *         mask_image,        \
147                             pixman_image_t *         dst_image,         \
148                             int32_t                  src_x,             \
149                             int32_t                  src_y,             \
150                             int32_t                  mask_x,            \
151                             int32_t                  mask_y,            \
152                             int32_t                  dest_x,            \
153                             int32_t                  dest_y,            \
154                             int32_t                  width,             \
155                             int32_t                  height)            \
156 {                                                                       \
157     dst_type  *dst_line;                                                \
158     mask_type *mask_line;                                               \
159     int32_t    dst_stride, mask_stride;                                 \
160     uint32_t   src;                                                     \
161                                                                         \
162     src = _pixman_image_get_solid (src_image, dst_image->bits.format);  \
163                                                                         \
164     if (src == 0)                                                       \
165         return;                                                         \
166                                                                         \
167     PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type,         \
168                            dst_stride, dst_line, dst_cnt);              \
169     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type,       \
170                            mask_stride, mask_line, mask_cnt);           \
171                                                                         \
172     pixman_composite_##name##_asm_##cputype (width, height,             \
173                                              dst_line, dst_stride,      \
174                                              src, 0,                    \
175                                              mask_line, mask_stride);   \
176 }
177
178 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_N_DST(cputype, name,              \
179                                             src_type, src_cnt,          \
180                                             dst_type, dst_cnt)          \
181 void                                                                    \
182 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
183                                          int32_t    h,                  \
184                                          dst_type  *dst,                \
185                                          int32_t    dst_stride,         \
186                                          src_type  *src,                \
187                                          int32_t    src_stride,         \
188                                          uint32_t   mask);              \
189                                                                         \
190 static void                                                             \
191 cputype##_composite_##name (pixman_implementation_t *imp,               \
192                             pixman_op_t              op,                \
193                             pixman_image_t *         src_image,         \
194                             pixman_image_t *         mask_image,        \
195                             pixman_image_t *         dst_image,         \
196                             int32_t                  src_x,             \
197                             int32_t                  src_y,             \
198                             int32_t                  mask_x,            \
199                             int32_t                  mask_y,            \
200                             int32_t                  dest_x,            \
201                             int32_t                  dest_y,            \
202                             int32_t                  width,             \
203                             int32_t                  height)            \
204 {                                                                       \
205     dst_type  *dst_line;                                                \
206     src_type  *src_line;                                                \
207     int32_t    dst_stride, src_stride;                                  \
208     uint32_t   mask;                                                    \
209                                                                         \
210     mask = _pixman_image_get_solid (mask_image, dst_image->bits.format);\
211                                                                         \
212     if (mask == 0)                                                      \
213         return;                                                         \
214                                                                         \
215     PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type,         \
216                            dst_stride, dst_line, dst_cnt);              \
217     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,           \
218                            src_stride, src_line, src_cnt);              \
219                                                                         \
220     pixman_composite_##name##_asm_##cputype (width, height,             \
221                                              dst_line, dst_stride,      \
222                                              src_line, src_stride,      \
223                                              mask);                     \
224 }
225
226 #define PIXMAN_ARM_BIND_FAST_PATH_SRC_MASK_DST(cputype, name,           \
227                                                src_type, src_cnt,       \
228                                                mask_type, mask_cnt,     \
229                                                dst_type, dst_cnt)       \
230 void                                                                    \
231 pixman_composite_##name##_asm_##cputype (int32_t    w,                  \
232                                          int32_t    h,                  \
233                                          dst_type  *dst,                \
234                                          int32_t    dst_stride,         \
235                                          src_type  *src,                \
236                                          int32_t    src_stride,         \
237                                          mask_type *mask,               \
238                                          int32_t    mask_stride);       \
239                                                                         \
240 static void                                                             \
241 cputype##_composite_##name (pixman_implementation_t *imp,               \
242                             pixman_op_t              op,                \
243                             pixman_image_t *         src_image,         \
244                             pixman_image_t *         mask_image,        \
245                             pixman_image_t *         dst_image,         \
246                             int32_t                  src_x,             \
247                             int32_t                  src_y,             \
248                             int32_t                  mask_x,            \
249                             int32_t                  mask_y,            \
250                             int32_t                  dest_x,            \
251                             int32_t                  dest_y,            \
252                             int32_t                  width,             \
253                             int32_t                  height)            \
254 {                                                                       \
255     dst_type  *dst_line;                                                \
256     src_type  *src_line;                                                \
257     mask_type *mask_line;                                               \
258     int32_t    dst_stride, src_stride, mask_stride;                     \
259                                                                         \
260     PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, dst_type,         \
261                            dst_stride, dst_line, dst_cnt);              \
262     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,           \
263                            src_stride, src_line, src_cnt);              \
264     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type,       \
265                            mask_stride, mask_line, mask_cnt);           \
266                                                                         \
267     pixman_composite_##name##_asm_##cputype (width, height,             \
268                                              dst_line, dst_stride,      \
269                                              src_line, src_stride,      \
270                                              mask_line, mask_stride);   \
271 }
272
273 #endif