OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBlitRow_opts_arm.h" | 8 #include "SkBlitRow_opts_arm.h" |
9 | 9 |
10 #include "SkBlitMask.h" | 10 #include "SkBlitMask.h" |
11 #include "SkBlitRow.h" | 11 #include "SkBlitRow.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkDither.h" | 13 #include "SkDither.h" |
14 #include "SkMathPriv.h" | 14 #include "SkMathPriv.h" |
15 #include "SkUtils.h" | 15 #include "SkUtils.h" |
16 | 16 |
17 #include "SkCachePreload_arm.h" | 17 #include "SkCachePreload_arm.h" |
18 #include "SkColor_opts_neon.h" | |
19 #include <arm_neon.h> | |
18 | 20 |
19 #include <arm_neon.h> | 21 void S32_D565_Opaque_neon(uint16_t* SK_RESTRICT dst, |
22 const SkPMColor* SK_RESTRICT src, int count, | |
23 U8CPU alpha, int /*x*/, int /*y*/) { | |
24 SkASSERT(255 == alpha); | |
25 | |
26 while (count >= 8) { | |
27 uint8x8x4_t vsrc; | |
28 uint16x8_t vdst; | |
29 | |
30 // Load | |
31 vsrc = vld4_u8((uint8_t*)src); | |
32 | |
33 // Convert src to 565 | |
34 vdst = vshll_n_u8(vsrc.val[NEON_R], 8); | |
35 vdst = vsriq_n_u16(vdst, vshll_n_u8(vsrc.val[NEON_G], 8), 5); | |
36 vdst = vsriq_n_u16(vdst, vshll_n_u8(vsrc.val[NEON_B], 8), 5+6); | |
37 | |
38 // Store | |
39 vst1q_u16(dst, vdst); | |
40 | |
41 // Prepare next iteration | |
42 dst += 8; | |
43 src += 8; | |
44 count -= 8; | |
45 }; | |
46 | |
47 // Leftovers | |
48 while (count > 0) { | |
49 SkPMColor c = *src++; | |
50 SkPMColorAssert(c); | |
51 *dst = SkPixel32ToPixel16_ToU16(c); | |
52 dst += 1; | |
mtklein
2013/09/20 13:36:08
For symmetry I'd go with a ++ here.
kevin.petit.not.used.account
2013/09/20 14:41:56
Done.
| |
53 count--; | |
54 }; | |
55 } | |
20 | 56 |
21 void S32A_D565_Opaque_neon(uint16_t* SK_RESTRICT dst, | 57 void S32A_D565_Opaque_neon(uint16_t* SK_RESTRICT dst, |
22 const SkPMColor* SK_RESTRICT src, int count, | 58 const SkPMColor* SK_RESTRICT src, int count, |
23 U8CPU alpha, int /*x*/, int /*y*/) { | 59 U8CPU alpha, int /*x*/, int /*y*/) { |
24 SkASSERT(255 == alpha); | 60 SkASSERT(255 == alpha); |
25 | 61 |
26 if (count >= 8) { | 62 if (count >= 8) { |
27 uint16_t* SK_RESTRICT keep_dst = 0; | 63 uint16_t* SK_RESTRICT keep_dst = 0; |
28 | 64 |
29 asm volatile ( | 65 asm volatile ( |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1233 dst += 1; | 1269 dst += 1; |
1234 count--; | 1270 count--; |
1235 } | 1271 } |
1236 } | 1272 } |
1237 } | 1273 } |
1238 | 1274 |
1239 /////////////////////////////////////////////////////////////////////////////// | 1275 /////////////////////////////////////////////////////////////////////////////// |
1240 | 1276 |
1241 const SkBlitRow::Proc sk_blitrow_platform_565_procs_arm_neon[] = { | 1277 const SkBlitRow::Proc sk_blitrow_platform_565_procs_arm_neon[] = { |
1242 // no dither | 1278 // no dither |
1243 // NOTE: For the two functions below, we don't have a special version | 1279 // NOTE: For the S32_D565_Blend function below, we don't have a special |
1244 // that assumes that each source pixel is opaque. But our S32A is | 1280 // version that assumes that each source pixel is opaque. But our |
1245 // still faster than the default, so use it. | 1281 // S32A is still faster than the default, so use it. |
1246 S32A_D565_Opaque_neon, // really S32_D565_Opaque | 1282 S32_D565_Opaque_neon, |
1247 S32A_D565_Blend_neon, // really S32_D565_Blend | 1283 S32A_D565_Blend_neon, // really S32_D565_Blend |
1248 S32A_D565_Opaque_neon, | 1284 S32A_D565_Opaque_neon, |
1249 S32A_D565_Blend_neon, | 1285 S32A_D565_Blend_neon, |
1250 | 1286 |
1251 // dither | 1287 // dither |
1252 S32_D565_Opaque_Dither_neon, | 1288 S32_D565_Opaque_Dither_neon, |
1253 S32_D565_Blend_Dither_neon, | 1289 S32_D565_Blend_Dither_neon, |
1254 S32A_D565_Opaque_Dither_neon, | 1290 S32A_D565_Opaque_Dither_neon, |
1255 NULL, // S32A_D565_Blend_Dither | 1291 NULL, // S32A_D565_Blend_Dither |
1256 }; | 1292 }; |
(...skipping 11 matching lines...) Expand all Loading... | |
1268 * case where we do not inspect the src alpha. | 1304 * case where we do not inspect the src alpha. |
1269 */ | 1305 */ |
1270 #if SK_A32_SHIFT == 24 | 1306 #if SK_A32_SHIFT == 24 |
1271 // This proc assumes the alpha value occupies bits 24-32 of each SkPMColor | 1307 // This proc assumes the alpha value occupies bits 24-32 of each SkPMColor |
1272 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque, | 1308 S32A_Opaque_BlitRow32_neon_src_alpha, // S32A_Opaque, |
1273 #else | 1309 #else |
1274 S32A_Opaque_BlitRow32_neon, // S32A_Opaque, | 1310 S32A_Opaque_BlitRow32_neon, // S32A_Opaque, |
1275 #endif | 1311 #endif |
1276 S32A_Blend_BlitRow32_arm // S32A_Blend | 1312 S32A_Blend_BlitRow32_arm // S32A_Blend |
1277 }; | 1313 }; |
OLD | NEW |