OLD | NEW |
1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola | 1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola |
2 * | 2 * |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "SkBitmapProcState.h" | 7 #include "SkBitmapProcState.h" |
8 #include "SkPerspIter.h" | 8 #include "SkPerspIter.h" |
9 #include "SkShader.h" | 9 #include "SkShader.h" |
10 #include "SkUtilsArm.h" | 10 #include "SkUtilsArm.h" |
11 #include "SkBitmapProcState_utils.h" | 11 #include "SkBitmapProcState_utils.h" |
12 | 12 |
| 13 #include <arm_neon.h> |
| 14 |
13 extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[]; | 15 extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[]; |
14 extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[]; | 16 extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[]; |
15 | 17 |
16 static void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, in
t count); | 18 static void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, in
t count); |
17 static void decal_filter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int
count); | 19 static void decal_filter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int
count); |
18 | 20 |
19 #define MAKENAME(suffix) ClampX_ClampY ## suffix ## _neon | 21 // TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
20 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) | 22 static inline int16x8_t sbpsm_clamp_tile8(int32x4_t low, int32x4_t high, unsigne
d max) { |
21 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) | 23 int16x8_t res; |
22 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) | 24 |
23 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) | 25 // get the hi 16s of all those 32s |
| 26 res = vuzpq_s16(vreinterpretq_s16_s32(low), vreinterpretq_s16_s32(high)).val
[1]; |
| 27 |
| 28 // clamp |
| 29 res = vmaxq_s16(res, vdupq_n_s16(0)); |
| 30 res = vminq_s16(res, vdupq_n_s16(max)); |
| 31 |
| 32 return res; |
| 33 } |
| 34 |
| 35 // TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
| 36 static inline int32x4_t sbpsm_clamp_tile4(int32x4_t f, unsigned max) { |
| 37 int32x4_t res; |
| 38 |
| 39 // get the hi 16s of all those 32s |
| 40 res = vshrq_n_s32(f, 16); |
| 41 |
| 42 // clamp |
| 43 res = vmaxq_s32(res, vdupq_n_s32(0)); |
| 44 res = vminq_s32(res, vdupq_n_s32(max)); |
| 45 |
| 46 return res; |
| 47 } |
| 48 |
| 49 // TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
| 50 static inline int32x4_t sbpsm_clamp_tile4_low_bits(int32x4_t fx) { |
| 51 int32x4_t ret; |
| 52 |
| 53 ret = vshrq_n_s32(fx, 12); |
| 54 |
| 55 /* We don't need the mask below because the caller will |
| 56 * overwrite the non-masked bits |
| 57 */ |
| 58 //ret = vandq_s32(ret, vdupq_n_s32(0xF)); |
| 59 |
| 60 return ret; |
| 61 } |
| 62 |
| 63 // TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) |
| 64 static inline int16x8_t sbpsm_repeat_tile8(int32x4_t low, int32x4_t high, unsign
ed max) { |
| 65 uint16x8_t res; |
| 66 uint32x4_t tmpl, tmph; |
| 67 |
| 68 // get the lower 16 bits |
| 69 res = vuzpq_u16(vreinterpretq_u16_s32(low), vreinterpretq_u16_s32(high)).val
[0]; |
| 70 |
| 71 // bare multiplication, not SkFixedMul |
| 72 tmpl = vmull_u16(vget_low_u16(res), vdup_n_u16(max+1)); |
| 73 tmph = vmull_u16(vget_high_u16(res), vdup_n_u16(max+1)); |
| 74 |
| 75 // extraction of the 16 upper bits |
| 76 res = vuzpq_u16(vreinterpretq_u16_u32(tmpl), vreinterpretq_u16_u32(tmph)).va
l[1]; |
| 77 |
| 78 return vreinterpretq_s16_u16(res); |
| 79 } |
| 80 |
| 81 // TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) |
| 82 static inline int32x4_t sbpsm_repeat_tile4(int32x4_t f, unsigned max) { |
| 83 uint16x4_t res; |
| 84 uint32x4_t tmp; |
| 85 |
| 86 // get the lower 16 bits |
| 87 res = vmovn_u32(vreinterpretq_u32_s32(f)); |
| 88 |
| 89 // bare multiplication, not SkFixedMul |
| 90 tmp = vmull_u16(res, vdup_n_u16(max+1)); |
| 91 |
| 92 // extraction of the 16 upper bits |
| 93 tmp = vshrq_n_u32(tmp, 16); |
| 94 |
| 95 return vreinterpretq_s32_u32(tmp); |
| 96 } |
| 97 |
| 98 // TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
| 99 static inline int32x4_t sbpsm_repeat_tile4_low_bits(int32x4_t fx, unsigned max)
{ |
| 100 uint16x4_t res; |
| 101 uint32x4_t tmp; |
| 102 int32x4_t ret; |
| 103 |
| 104 // get the lower 16 bits |
| 105 res = vmovn_u32(vreinterpretq_u32_s32(fx)); |
| 106 |
| 107 // bare multiplication, not SkFixedMul |
| 108 tmp = vmull_u16(res, vdup_n_u16(max + 1)); |
| 109 |
| 110 // shift and mask |
| 111 ret = vshrq_n_s32(vreinterpretq_s32_u32(tmp), 12); |
| 112 |
| 113 /* We don't need the mask below because the caller will |
| 114 * overwrite the non-masked bits |
| 115 */ |
| 116 //ret = vandq_s32(ret, vdupq_n_s32(0xF)); |
| 117 |
| 118 return ret; |
| 119 } |
| 120 |
| 121 #define MAKENAME(suffix) ClampX_ClampY ## suffix ## _neon |
| 122 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
| 123 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) |
| 124 #define TILEX_PROCF_NEON8(l, h, max) sbpsm_clamp_tile8(l, h, max) |
| 125 #define TILEY_PROCF_NEON8(l, h, max) sbpsm_clamp_tile8(l, h, max) |
| 126 #define TILEX_PROCF_NEON4(fx, max) sbpsm_clamp_tile4(fx, max) |
| 127 #define TILEY_PROCF_NEON4(fy, max) sbpsm_clamp_tile4(fy, max) |
| 128 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) |
| 129 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
| 130 #define TILEX_LOW_BITS_NEON4(fx, max) sbpsm_clamp_tile4_low_bits(fx) |
| 131 #define TILEY_LOW_BITS_NEON4(fy, max) sbpsm_clamp_tile4_low_bits(fy) |
24 #define CHECK_FOR_DECAL | 132 #define CHECK_FOR_DECAL |
25 #include "SkBitmapProcState_matrix_clamp_neon.h" | 133 #include "SkBitmapProcState_matrix_neon.h" |
26 | 134 |
27 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix ## _neon | 135 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix ## _neon |
28 #define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1)) | 136 #define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1
)) |
29 #define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1)) | 137 #define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1
)) |
30 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) | 138 #define TILEX_PROCF_NEON8(l, h, max) sbpsm_repeat_tile8(l, h, max) |
31 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) | 139 #define TILEY_PROCF_NEON8(l, h, max) sbpsm_repeat_tile8(l, h, max) |
32 #include "SkBitmapProcState_matrix_repeat_neon.h" | 140 #define TILEX_PROCF_NEON4(fx, max) sbpsm_repeat_tile4(fx, max) |
| 141 #define TILEY_PROCF_NEON4(fy, max) sbpsm_repeat_tile4(fy, max) |
| 142 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) &
0xF) |
| 143 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) &
0xF) |
| 144 #define TILEX_LOW_BITS_NEON4(fx, max) sbpsm_repeat_tile4_low_bits(fx, max) |
| 145 #define TILEY_LOW_BITS_NEON4(fy, max) sbpsm_repeat_tile4_low_bits(fy, max) |
| 146 #include "SkBitmapProcState_matrix_neon.h" |
33 | 147 |
34 | 148 |
35 | 149 |
36 void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count
) { | 150 void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count
) { |
37 if (count >= 8) { | 151 if (count >= 8) { |
38 // SkFixed is 16.16 fixed point | 152 // SkFixed is 16.16 fixed point |
39 SkFixed dx8 = dx * 8; | 153 SkFixed dx8 = dx * 8; |
40 int32x4_t vdx8 = vdupq_n_s32(dx8); | 154 int32x4_t vdx8 = vdupq_n_s32(dx8); |
41 | 155 |
42 // setup lbase and hbase | 156 // setup lbase and hbase |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 while ((count -= 2) >= 0) | 225 while ((count -= 2) >= 0) |
112 { | 226 { |
113 SkASSERT((fx >> (16 + 14)) == 0); | 227 SkASSERT((fx >> (16 + 14)) == 0); |
114 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); | 228 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
115 fx += dx; | 229 fx += dx; |
116 | 230 |
117 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); | 231 *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
118 fx += dx; | 232 fx += dx; |
119 } | 233 } |
120 } | 234 } |
OLD | NEW |