OLD | NEW |
(Empty) | |
| 1 #include <arm_neon.h> |
| 2 |
| 3 #include "SkColorPriv.h" |
| 4 |
| 5 void SkPackARGB32_neon(const uint32_t* src, SkPMColor* dst, int height, int widt
h, |
| 6 size_t dstRowBytes, size_t srcRowBytes) |
| 7 { |
| 8 asm volatile ( |
| 9 |
| 10 // if (height == 0) exit |
| 11 "cmp %[height], #0 \n\t" |
| 12 "beq End \n\t" |
| 13 |
| 14 "RowLoop:" |
| 15 |
| 16 // reset r1 = width for each new line |
| 17 "mov r1, %[width] \n\t" |
| 18 "mov r2, %[src] \n\t" |
| 19 "mov r3, %[dst] \n\t" |
| 20 |
| 21 "ColumnBatchLoop:" |
| 22 |
| 23 // while (r1 >= 8) |
| 24 "cmp r1, #8 \n\t" |
| 25 "blt PixelLoopStart \n\t" |
| 26 |
| 27 // load src, 8 pixels at a time, each pixel taking 32bit value |
| 28 // d0: B0B1B2B3...B7 d1: G0G1G2G3...G7 d2: R0R1R2R3...G7 d3: A0A
1A2A3...A7 |
| 29 "vld4.8 {d0, d1, d2, d3}, [r2]! \n\t" |
| 30 //swap d0 and d2 so we have RGBA format if SkPMColor is RGBA, ot
herwise keep BGRA |
| 31 #ifdef SK_PMCOLOR_IS_RGBA |
| 32 "vswp d0, d2 \n\t" |
| 33 #endif |
| 34 "vst4.8 {d0, d1, d2, d3}, [r3]! \n\t" |
| 35 //r1 -= 8 because we are processing 8 pixels at a time |
| 36 "sub r1, r1, #8 \n\t" |
| 37 "b ColumnBatchLoop \n\t" |
| 38 |
| 39 "PixelLoopStart: \n\t" |
| 40 // while (r1 > 0) |
| 41 "cmp r1, #0 \n\t" |
| 42 "beq PixelLoopEnd \n\t" |
| 43 |
| 44 "PixelLoop:" |
| 45 //load 1 32bits pixel at a time and swap again if needed |
| 46 "vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r2]! \n\t" |
| 47 #ifdef SK_PMCOLOR_IS_RGBA |
| 48 "vswp d0, d2 \n\t" |
| 49 #endif |
| 50 "vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r3]! \n\t" |
| 51 // pixel counter decrement |
| 52 "subs r1, r1, #1 \n\t" |
| 53 "bne PixelLoop \n\t" |
| 54 |
| 55 "PixelLoopEnd: \n\t" |
| 56 |
| 57 "add %[src], %[src], %[srcRowBytes] \n\t" |
| 58 "add %[dst], %[dst], %[dstRowBytes] \n\t" |
| 59 // while (height) process next line |
| 60 "subs %[height], %[height], #1 \n\t" |
| 61 "bne RowLoop \n\t" |
| 62 |
| 63 "End: \n\t" |
| 64 |
| 65 : [height] "+r" (height), [dst] "+r" (dst), [src] "+r" (src) |
| 66 : [width] "r" (width), [srcRowBytes] "r" (srcRowBytes), [dstRowBytes
] "r" (dstRowBytes) |
| 67 : "cc", "memory", |
| 68 "r1", "r2", "r3", |
| 69 "d0", "d1", "d2", "d3"); |
| 70 } |
| 71 |
| 72 |
OLD | NEW |