Packaging: version up to 0.38.4
[platform/upstream/pixman.git] / pixman / pixman-mips-dspr2.h
1 /*
2  * Copyright (c) 2012
3  *      MIPS Technologies, Inc., California.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14  *    contributors may be used to endorse or promote products derived from
15  *    this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * Author:  Nemanja Lukic (nemanja.lukic@rt-rk.com)
30  */
31
32 #ifndef PIXMAN_MIPS_DSPR2_H
33 #define PIXMAN_MIPS_DSPR2_H
34
35 #include "pixman-private.h"
36 #include "pixman-inlines.h"
37
38 #define SKIP_ZERO_SRC  1
39 #define SKIP_ZERO_MASK 2
40 #define DO_FAST_MEMCPY 3
41
42 void
43 pixman_mips_fast_memcpy (void *dst, void *src, uint32_t n_bytes);
44 void
45 pixman_fill_buff16_mips (void *dst, uint32_t n_bytes, uint16_t value);
46 void
47 pixman_fill_buff32_mips (void *dst, uint32_t n_bytes, uint32_t value);
48
49 /****************************************************************/
50
51 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST(flags, name,          \
52                                            src_type, src_cnt,    \
53                                            dst_type, dst_cnt)    \
54 void                                                             \
55 pixman_composite_##name##_asm_mips (dst_type *dst,               \
56                                     src_type *src,               \
57                                     int32_t   w);                \
58                                                                  \
59 static void                                                      \
60 mips_composite_##name (pixman_implementation_t *imp,             \
61                        pixman_composite_info_t *info)            \
62 {                                                                \
63     PIXMAN_COMPOSITE_ARGS (info);                                \
64     dst_type *dst_line, *dst;                                    \
65     src_type *src_line, *src;                                    \
66     int32_t dst_stride, src_stride;                              \
67     int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8;   \
68                                                                  \
69     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,    \
70                            src_stride, src_line, src_cnt);       \
71     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
72                            dst_stride, dst_line, dst_cnt);       \
73                                                                  \
74     while (height--)                                             \
75     {                                                            \
76       dst = dst_line;                                            \
77       dst_line += dst_stride;                                    \
78       src = src_line;                                            \
79       src_line += src_stride;                                    \
80                                                                  \
81       if (flags == DO_FAST_MEMCPY)                               \
82         pixman_mips_fast_memcpy (dst, src, width * bpp);         \
83       else                                                       \
84         pixman_composite_##name##_asm_mips (dst, src, width);    \
85     }                                                            \
86 }
87
88 /****************************************************************/
89
90 #define PIXMAN_MIPS_BIND_FAST_PATH_N_DST(flags, name,            \
91                                          dst_type, dst_cnt)      \
92 void                                                             \
93 pixman_composite_##name##_asm_mips (dst_type *dst,               \
94                                     uint32_t  src,               \
95                                     int32_t   w);                \
96                                                                  \
97 static void                                                      \
98 mips_composite_##name (pixman_implementation_t *imp,             \
99                        pixman_composite_info_t *info)            \
100 {                                                                \
101     PIXMAN_COMPOSITE_ARGS (info);                                \
102     dst_type  *dst_line, *dst;                                   \
103     int32_t    dst_stride;                                       \
104     uint32_t   src;                                              \
105                                                                  \
106     src = _pixman_image_get_solid (                              \
107     imp, src_image, dest_image->bits.format);                    \
108                                                                  \
109     if ((flags & SKIP_ZERO_SRC) && src == 0)                     \
110         return;                                                  \
111                                                                  \
112     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \
113                            dst_stride, dst_line, dst_cnt);       \
114                                                                  \
115     while (height--)                                             \
116     {                                                            \
117         dst = dst_line;                                          \
118         dst_line += dst_stride;                                  \
119                                                                  \
120         pixman_composite_##name##_asm_mips (dst, src, width);    \
121     }                                                            \
122 }
123
124 /*******************************************************************/
125
126 #define PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST(flags, name,          \
127                                               mask_type, mask_cnt,  \
128                                               dst_type, dst_cnt)    \
129 void                                                                \
130 pixman_composite_##name##_asm_mips (dst_type  *dst,                 \
131                                     uint32_t  src,                  \
132                                     mask_type *mask,                \
133                                     int32_t   w);                   \
134                                                                     \
135 static void                                                         \
136 mips_composite_##name (pixman_implementation_t *imp,                \
137                        pixman_composite_info_t *info)               \
138 {                                                                   \
139     PIXMAN_COMPOSITE_ARGS (info);                                   \
140     dst_type  *dst_line, *dst;                                      \
141     mask_type *mask_line, *mask;                                    \
142     int32_t    dst_stride, mask_stride;                             \
143     uint32_t   src;                                                 \
144                                                                     \
145     src = _pixman_image_get_solid (                                 \
146         imp, src_image, dest_image->bits.format);                   \
147                                                                     \
148     if ((flags & SKIP_ZERO_SRC) && src == 0)                        \
149         return;                                                     \
150                                                                     \
151     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type,    \
152                            dst_stride, dst_line, dst_cnt);          \
153     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type,   \
154                            mask_stride, mask_line, mask_cnt);       \
155                                                                     \
156     while (height--)                                                \
157     {                                                               \
158         dst = dst_line;                                             \
159         dst_line += dst_stride;                                     \
160         mask = mask_line;                                           \
161         mask_line += mask_stride;                                   \
162         pixman_composite_##name##_asm_mips (dst, src, mask, width); \
163     }                                                               \
164 }
165
166 /*******************************************************************/
167
168 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_N_DST(flags, name,           \
169                                             src_type, src_cnt,      \
170                                             dst_type, dst_cnt)      \
171 void                                                                \
172 pixman_composite_##name##_asm_mips (dst_type  *dst,                 \
173                                     src_type  *src,                 \
174                                     uint32_t   mask,                \
175                                     int32_t    w);                  \
176                                                                     \
177 static void                                                         \
178 mips_composite_##name (pixman_implementation_t *imp,                \
179                        pixman_composite_info_t *info)               \
180 {                                                                   \
181     PIXMAN_COMPOSITE_ARGS (info);                                   \
182     dst_type  *dst_line, *dst;                                      \
183     src_type  *src_line, *src;                                      \
184     int32_t    dst_stride, src_stride;                              \
185     uint32_t   mask;                                                \
186                                                                     \
187     mask = _pixman_image_get_solid (                                \
188         imp, mask_image, dest_image->bits.format);                  \
189                                                                     \
190     if ((flags & SKIP_ZERO_MASK) && mask == 0)                      \
191         return;                                                     \
192                                                                     \
193     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type,    \
194                            dst_stride, dst_line, dst_cnt);          \
195     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,       \
196                            src_stride, src_line, src_cnt);          \
197                                                                     \
198     while (height--)                                                \
199     {                                                               \
200         dst = dst_line;                                             \
201         dst_line += dst_stride;                                     \
202         src = src_line;                                             \
203         src_line += src_stride;                                     \
204                                                                     \
205         pixman_composite_##name##_asm_mips (dst, src, mask, width); \
206     }                                                               \
207 }
208
209 /************************************************************************/
210
211 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_MASK_DST(name, src_type, src_cnt, \
212                                                 mask_type, mask_cnt,     \
213                                                 dst_type, dst_cnt)       \
214 void                                                                     \
215 pixman_composite_##name##_asm_mips (dst_type  *dst,                      \
216                                     src_type  *src,                      \
217                                     mask_type *mask,                     \
218                                     int32_t   w);                        \
219                                                                          \
220 static void                                                              \
221 mips_composite_##name (pixman_implementation_t *imp,                     \
222                        pixman_composite_info_t *info)                    \
223 {                                                                        \
224     PIXMAN_COMPOSITE_ARGS (info);                                        \
225     dst_type  *dst_line, *dst;                                           \
226     src_type  *src_line, *src;                                           \
227     mask_type *mask_line, *mask;                                         \
228     int32_t    dst_stride, src_stride, mask_stride;                      \
229                                                                          \
230     PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type,         \
231                            dst_stride, dst_line, dst_cnt);               \
232     PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type,            \
233                            src_stride, src_line, src_cnt);               \
234     PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type,        \
235                            mask_stride, mask_line, mask_cnt);            \
236                                                                          \
237     while (height--)                                                     \
238     {                                                                    \
239         dst = dst_line;                                                  \
240         dst_line += dst_stride;                                          \
241         mask = mask_line;                                                \
242         mask_line += mask_stride;                                        \
243         src = src_line;                                                  \
244         src_line += src_stride;                                          \
245         pixman_composite_##name##_asm_mips (dst, src, mask, width);      \
246     }                                                                    \
247 }
248
249 /****************************************************************************/
250
251 #define PIXMAN_MIPS_BIND_SCALED_NEAREST_SRC_DST(name, op,                    \
252                                                 src_type, dst_type)          \
253 void                                                                         \
254 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (                    \
255                                                    dst_type *       dst,     \
256                                                    const src_type * src,     \
257                                                    int32_t          w,       \
258                                                    pixman_fixed_t   vx,      \
259                                                    pixman_fixed_t   unit_x); \
260                                                                              \
261 static force_inline void                                                     \
262 scaled_nearest_scanline_mips_##name##_##op (dst_type *       pd,             \
263                                             const src_type * ps,             \
264                                             int32_t          w,              \
265                                             pixman_fixed_t   vx,             \
266                                             pixman_fixed_t   unit_x,         \
267                                             pixman_fixed_t   max_vx,         \
268                                             pixman_bool_t    zero_src)       \
269 {                                                                            \
270     pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (pd, ps, w,      \
271                                                              vx, unit_x);    \
272 }                                                                            \
273                                                                              \
274 FAST_NEAREST_MAINLOOP (mips_##name##_cover_##op,                             \
275                        scaled_nearest_scanline_mips_##name##_##op,           \
276                        src_type, dst_type, COVER)                            \
277 FAST_NEAREST_MAINLOOP (mips_##name##_none_##op,                              \
278                        scaled_nearest_scanline_mips_##name##_##op,           \
279                        src_type, dst_type, NONE)                             \
280 FAST_NEAREST_MAINLOOP (mips_##name##_pad_##op,                               \
281                        scaled_nearest_scanline_mips_##name##_##op,           \
282                        src_type, dst_type, PAD)
283
284 /* Provide entries for the fast path table */
285 #define PIXMAN_MIPS_SIMPLE_NEAREST_FAST_PATH(op,s,d,func)                    \
286     SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func),                            \
287     SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func),                             \
288     SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func)
289
290
291 /*****************************************************************************/
292
293 #define PIXMAN_MIPS_BIND_SCALED_NEAREST_SRC_A8_DST(flags, name, op,           \
294                                                   src_type, dst_type)         \
295 void                                                                          \
296 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (                     \
297                                                    dst_type *       dst,      \
298                                                    const src_type * src,      \
299                                                    const uint8_t *  mask,     \
300                                                    int32_t          w,        \
301                                                    pixman_fixed_t   vx,       \
302                                                    pixman_fixed_t   unit_x);  \
303                                                                               \
304 static force_inline void                                                      \
305 scaled_nearest_scanline_mips_##name##_##op (const uint8_t *  mask,            \
306                                             dst_type *       pd,              \
307                                             const src_type * ps,              \
308                                             int32_t          w,               \
309                                             pixman_fixed_t   vx,              \
310                                             pixman_fixed_t   unit_x,          \
311                                             pixman_fixed_t   max_vx,          \
312                                             pixman_bool_t    zero_src)        \
313 {                                                                             \
314     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
315         return;                                                               \
316     pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (pd, ps,          \
317                                                              mask, w,         \
318                                                              vx, unit_x);     \
319 }                                                                             \
320                                                                               \
321 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_cover_##op,                       \
322                               scaled_nearest_scanline_mips_##name##_##op,     \
323                               src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\
324 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_none_##op,                        \
325                               scaled_nearest_scanline_mips_##name##_##op,     \
326                               src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
327 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_pad_##op,                         \
328                               scaled_nearest_scanline_mips_##name##_##op,     \
329                               src_type, uint8_t, dst_type, PAD, TRUE, FALSE)
330
331 /****************************************************************************/
332
333 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_DST(flags, name, op,            \
334                                                  src_type, dst_type)         \
335 void                                                                         \
336 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips(                    \
337                                              dst_type *       dst,           \
338                                              const src_type * src_top,       \
339                                              const src_type * src_bottom,    \
340                                              int32_t          w,             \
341                                              int              wt,            \
342                                              int              wb,            \
343                                              pixman_fixed_t   vx,            \
344                                              pixman_fixed_t   unit_x);       \
345 static force_inline void                                                     \
346 scaled_bilinear_scanline_mips_##name##_##op (dst_type *       dst,           \
347                                              const uint32_t * mask,          \
348                                              const src_type * src_top,       \
349                                              const src_type * src_bottom,    \
350                                              int32_t          w,             \
351                                              int              wt,            \
352                                              int              wb,            \
353                                              pixman_fixed_t   vx,            \
354                                              pixman_fixed_t   unit_x,        \
355                                              pixman_fixed_t   max_vx,        \
356                                              pixman_bool_t    zero_src)      \
357 {                                                                            \
358     if ((flags & SKIP_ZERO_SRC) && zero_src)                                 \
359         return;                                                              \
360     pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (dst, src_top,  \
361                                                               src_bottom, w, \
362                                                               wt, wb,        \
363                                                               vx, unit_x);   \
364 }                                                                            \
365                                                                              \
366 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op,                     \
367                        scaled_bilinear_scanline_mips_##name##_##op,          \
368                        src_type, uint32_t, dst_type, COVER, FLAG_NONE)       \
369 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op,                      \
370                        scaled_bilinear_scanline_mips_##name##_##op,          \
371                        src_type, uint32_t, dst_type, NONE, FLAG_NONE)        \
372 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op,                       \
373                        scaled_bilinear_scanline_mips_##name##_##op,          \
374                        src_type, uint32_t, dst_type, PAD, FLAG_NONE)         \
375 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op,                    \
376                        scaled_bilinear_scanline_mips_##name##_##op,          \
377                        src_type, uint32_t, dst_type, NORMAL,                 \
378                        FLAG_NONE)
379
380 /*****************************************************************************/
381
382 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, name, op,          \
383                                                 src_type, dst_type)           \
384 void                                                                          \
385 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                    \
386                                              dst_type *       dst,            \
387                                              const uint8_t *  mask,           \
388                                              const src_type * top,            \
389                                              const src_type * bottom,         \
390                                              int              wt,             \
391                                              int              wb,             \
392                                              pixman_fixed_t   x,              \
393                                              pixman_fixed_t   ux,             \
394                                              int              width);         \
395                                                                               \
396 static force_inline void                                                      \
397 scaled_bilinear_scanline_mips_##name##_##op (dst_type *       dst,            \
398                                              const uint8_t *  mask,           \
399                                              const src_type * src_top,        \
400                                              const src_type * src_bottom,     \
401                                              int32_t          w,              \
402                                              int              wt,             \
403                                              int              wb,             \
404                                              pixman_fixed_t   vx,             \
405                                              pixman_fixed_t   unit_x,         \
406                                              pixman_fixed_t   max_vx,         \
407                                              pixman_bool_t    zero_src)       \
408 {                                                                             \
409     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
410         return;                                                               \
411     pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                \
412                       dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
413 }                                                                             \
414                                                                               \
415 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op,                      \
416                        scaled_bilinear_scanline_mips_##name##_##op,           \
417                        src_type, uint8_t, dst_type, COVER,                    \
418                        FLAG_HAVE_NON_SOLID_MASK)                              \
419 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op,                       \
420                        scaled_bilinear_scanline_mips_##name##_##op,           \
421                        src_type, uint8_t, dst_type, NONE,                     \
422                        FLAG_HAVE_NON_SOLID_MASK)                              \
423 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op,                        \
424                        scaled_bilinear_scanline_mips_##name##_##op,           \
425                        src_type, uint8_t, dst_type, PAD,                      \
426                        FLAG_HAVE_NON_SOLID_MASK)                              \
427 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op,                     \
428                        scaled_bilinear_scanline_mips_##name##_##op,           \
429                        src_type, uint8_t, dst_type, NORMAL,                   \
430                        FLAG_HAVE_NON_SOLID_MASK)
431
432 #endif //PIXMAN_MIPS_DSPR2_H