2 * Copyright © 2008 Mozilla Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Mozilla Corporation not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Mozilla Corporation makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
19 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
20 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23 * Author: Jeff Muizelaar (jeff@infidigm.net)
30 #include "pixman-arm-simd.h"
33 fbCompositeSrcAdd_8000x8000arm (pixman_op_t op,
34 pixman_image_t * pSrc,
35 pixman_image_t * pMask,
36 pixman_image_t * pDst,
46 uint8_t *dstLine, *dst;
47 uint8_t *srcLine, *src;
48 int dstStride, srcStride;
52 fbComposeGetStart (pSrc, xSrc, ySrc, uint8_t, srcStride, srcLine, 1);
53 fbComposeGetStart (pDst, xDst, yDst, uint8_t, dstStride, dstLine, 1);
63 while (w && (((unsigned long)dst & 3) || ((unsigned long)src & 3)))
67 asm("uqadd8 %0, %1, %2" : "+r"(d) : "r"(s));
77 asm("uqadd8 %0, %1, %2" : "=r"(*(uint32_t*)dst) : "r"(*(uint32_t*)src), "r"(*(uint32_t*)dst));
87 asm("uqadd8 %0, %1, %2" : "+r"(d) : "r"(s));
99 fbCompositeSrc_8888x8888arm (pixman_op_t op,
100 pixman_image_t * pSrc,
101 pixman_image_t * pMask,
102 pixman_image_t * pDst,
112 uint32_t *dstLine, *dst;
113 uint32_t *srcLine, *src;
114 int dstStride, srcStride;
116 uint32_t component_half = 0x800080;
117 uint32_t upper_component_mask = 0xff00ff00;
118 uint32_t alpha_mask = 0xff;
120 fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1);
121 fbComposeGetStart (pSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1);
126 dstLine += dstStride;
128 srcLine += srcStride;
131 //#define inner_branch
137 "ldr r5, [%[src]], #4\n\t"
139 /* We can avoid doing the multiplication in two cases: 0x0 or 0xff.
140 * The 0x0 case also allows us to avoid doing an unecessary data
141 * write which is more valuable so we only check for that */
146 "sub r8, %[alpha_mask], r5, lsr #24\n\t"
148 "ldr r4, [%[dest]] \n\t"
151 "ldr r4, [%[dest]] \n\t"
154 "sub r8, %[alpha_mask], r5, lsr #24\n\t"
157 "uxtb16 r7, r4, ror #8\n\t"
159 /* multiply by 257 and divide by 65536 */
160 "mla r6, r6, r8, %[component_half]\n\t"
161 "mla r7, r7, r8, %[component_half]\n\t"
163 "uxtab16 r6, r6, r6, ror #8\n\t"
164 "uxtab16 r7, r7, r7, ror #8\n\t"
166 /* recombine the 0xff00ff00 bytes of r6 and r7 */
167 "and r7, r7, %[upper_component_mask]\n\t"
168 "uxtab16 r6, r7, r6, ror #8\n\t"
170 "uqadd8 r5, r6, r5\n\t"
176 "str r5, [%[dest]], #4\n\t"
177 /* increment counter and jmp to top */
178 "subs %[w], %[w], #1\n\t"
181 : [w] "+r" (w), [dest] "+r" (dst), [src] "+r" (src)
182 : [component_half] "r" (component_half), [upper_component_mask] "r" (upper_component_mask),
183 [alpha_mask] "r" (alpha_mask)
184 : "r4", "r5", "r6", "r7", "r8", "cc", "memory"
190 fbCompositeSrc_8888x8x8888arm (pixman_op_t op,
191 pixman_image_t * pSrc,
192 pixman_image_t * pMask,
193 pixman_image_t * pDst,
203 uint32_t *dstLine, *dst;
204 uint32_t *srcLine, *src;
206 int dstStride, srcStride;
208 uint32_t component_half = 0x800080;
209 uint32_t alpha_mask = 0xff;
211 fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1);
212 fbComposeGetStart (pSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1);
214 fbComposeGetSolid (pMask, mask, pDst->bits.format);
220 dstLine += dstStride;
222 srcLine += srcStride;
225 //#define inner_branch
231 "ldr r5, [%[src]], #4\n\t"
233 /* We can avoid doing the multiplication in two cases: 0x0 or 0xff.
234 * The 0x0 case also allows us to avoid doing an unecessary data
235 * write which is more valuable so we only check for that */
240 "ldr r4, [%[dest]] \n\t"
243 "uxtb16 r7, r5, ror #8\n\t"
245 /* multiply by alpha (r8) then by 257 and divide by 65536 */
246 "mla r6, r6, %[mask_alpha], %[component_half]\n\t"
247 "mla r7, r7, %[mask_alpha], %[component_half]\n\t"
249 "uxtab16 r6, r6, r6, ror #8\n\t"
250 "uxtab16 r7, r7, r7, ror #8\n\t"
252 "uxtb16 r6, r6, ror #8\n\t"
253 "uxtb16 r7, r7, ror #8\n\t"
256 "orr r5, r6, r7, lsl #8\n\t"
259 "uxtb16 r7, r4, ror #8\n\t"
262 "sub r8, %[alpha_mask], r5, lsr #24\n\t"
264 /* multiply by alpha (r8) then by 257 and divide by 65536 */
265 "mla r6, r6, r8, %[component_half]\n\t"
266 "mla r7, r7, r8, %[component_half]\n\t"
268 "uxtab16 r6, r6, r6, ror #8\n\t"
269 "uxtab16 r7, r7, r7, ror #8\n\t"
271 "uxtb16 r6, r6, ror #8\n\t"
272 "uxtb16 r7, r7, ror #8\n\t"
275 "orr r6, r6, r7, lsl #8\n\t"
277 "uqadd8 r5, r6, r5\n\t"
283 "str r5, [%[dest]], #4\n\t"
284 /* increment counter and jmp to top */
285 "subs %[w], %[w], #1\n\t"
288 : [w] "+r" (w), [dest] "+r" (dst), [src] "+r" (src)
289 : [component_half] "r" (component_half), [mask_alpha] "r" (mask),
290 [alpha_mask] "r" (alpha_mask)
291 : "r4", "r5", "r6", "r7", "r8", "r9", "cc", "memory"
297 fbCompositeSolidMask_nx8x8888arm (pixman_op_t op,
298 pixman_image_t * pSrc,
299 pixman_image_t * pMask,
300 pixman_image_t * pDst,
311 uint32_t *dstLine, *dst;
312 uint8_t *maskLine, *mask;
313 int dstStride, maskStride;
316 fbComposeGetSolid(pSrc, src, pDst->bits.format);
322 uint32_t component_mask = 0xff00ff;
323 uint32_t component_half = 0x800080;
325 uint32_t src_hi = (src >> 8) & component_mask;
326 uint32_t src_lo = src & component_mask;
328 fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1);
329 fbComposeGetStart (pMask, xMask, yMask, uint8_t, maskStride, maskLine, 1);
334 dstLine += dstStride;
336 maskLine += maskStride;
339 //#define inner_branch
345 "ldrb r5, [%[mask]], #1\n\t"
347 /* We can avoid doing the multiplication in two cases: 0x0 or 0xff.
348 * The 0x0 case also allows us to avoid doing an unecessary data
349 * write which is more valuable so we only check for that */
354 "ldr r4, [%[dest]] \n\t"
356 /* multiply by alpha (r8) then by 257 and divide by 65536 */
357 "mla r6, %[src_lo], r5, %[component_half]\n\t"
358 "mla r7, %[src_hi], r5, %[component_half]\n\t"
360 "uxtab16 r6, r6, r6, ror #8\n\t"
361 "uxtab16 r7, r7, r7, ror #8\n\t"
363 "uxtb16 r6, r6, ror #8\n\t"
364 "uxtb16 r7, r7, ror #8\n\t"
367 "orr r5, r6, r7, lsl #8\n\t"
370 "uxtb16 r7, r4, ror #8\n\t"
372 /* we could simplify this to use 'sub' if we were
373 * willing to give up a register for alpha_mask */
375 "mov r8, r8, lsr #24\n\t"
377 /* multiply by alpha (r8) then by 257 and divide by 65536 */
378 "mla r6, r6, r8, %[component_half]\n\t"
379 "mla r7, r7, r8, %[component_half]\n\t"
381 "uxtab16 r6, r6, r6, ror #8\n\t"
382 "uxtab16 r7, r7, r7, ror #8\n\t"
384 "uxtb16 r6, r6, ror #8\n\t"
385 "uxtb16 r7, r7, ror #8\n\t"
388 "orr r6, r6, r7, lsl #8\n\t"
390 "uqadd8 r5, r6, r5\n\t"
396 "str r5, [%[dest]], #4\n\t"
397 /* increment counter and jmp to top */
398 "subs %[w], %[w], #1\n\t"
401 : [w] "+r" (w), [dest] "+r" (dst), [src] "+r" (src), [mask] "+r" (mask)
402 : [component_half] "r" (component_half),
403 [src_hi] "r" (src_hi), [src_lo] "r" (src_lo)
404 : "r4", "r5", "r6", "r7", "r8", "cc", "memory"