OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 inline Sk4px::Sk4px(SkPMColor px) : INHERITED((uint8x16_t)vdupq_n_u32(px)) {} | 8 inline Sk4px::Sk4px(SkPMColor px) : INHERITED((uint8x16_t)vdupq_n_u32(px)) {} |
9 | 9 |
10 inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { | 10 inline Sk4px Sk4px::Load4(const SkPMColor px[4]) { |
(...skipping 30 matching lines...) Expand all Loading... |
41 inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { | 41 inline Sk4px::Wide Sk4px::mulWiden(const Sk16b& other) const { |
42 return Sk16h(vmull_u8(vget_low_u8 (this->fVec), vget_low_u8 (other.fVec)), | 42 return Sk16h(vmull_u8(vget_low_u8 (this->fVec), vget_low_u8 (other.fVec)), |
43 vmull_u8(vget_high_u8(this->fVec), vget_high_u8(other.fVec))); | 43 vmull_u8(vget_high_u8(this->fVec), vget_high_u8(other.fVec))); |
44 } | 44 } |
45 | 45 |
46 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { | 46 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { |
47 const Sk4px::Wide o(other); // Should be no code, but allows us to access f
Lo, fHi. | 47 const Sk4px::Wide o(other); // Should be no code, but allows us to access f
Lo, fHi. |
48 return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec), | 48 return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec), |
49 vaddhn_u16(this->fHi.fVec, o.fHi.fVec))); | 49 vaddhn_u16(this->fHi.fVec, o.fHi.fVec))); |
50 } | 50 } |
| 51 |
| 52 inline Sk4px Sk4px::alphas() const { |
| 53 static_assert(SK_A32_SHIFT == 24, "This method assumes little-endian."); |
| 54 auto as = vshrq_n_u32((uint32x4_t)this->fVec, 24); // ___3 ___2 ___1 ___0 |
| 55 as = vorrq_u32(as, vshlq_n_u32(as, 8)); // __33 __22 __11 __11 |
| 56 as = vorrq_u32(as, vshlq_n_u32(as, 16)); // 3333 2222 1111 1111 |
| 57 return Sk16b((uint8x16_t)as); |
| 58 } |
| 59 |
| 60 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { |
| 61 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____ |
| 62 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0 |
| 63 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___0 |
| 64 a8 = vld1q_lane_u8(a+2, a8, 8); // ____ ___2 ___1 ___0 |
| 65 a8 = vld1q_lane_u8(a+3, a8, 12); // ___3 ___2 ___1 ___0 |
| 66 auto a32 = (uint32x4_t)a8; // |
| 67 a32 = vorrq_u32(a32, vshlq_n_u32(a32, 8)); // __33 __22 __11 __00 |
| 68 a32 = vorrq_u32(a32, vshlq_n_u32(a32, 16)); // 3333 2222 1111 0000 |
| 69 return Sk16b((uint8x16_t)a32); |
| 70 } |
| 71 |
| 72 inline Sk4px Sk4px::Load2Alphas(const SkAlpha a[2]) { |
| 73 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ ____ |
| 74 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ ___0 |
| 75 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 ___0 |
| 76 auto a32 = (uint32x4_t)a8; // |
| 77 a32 = vorrq_u32(a32, vshlq_n_u32(a32, 8)); // ____ ____ __11 __00 |
| 78 a32 = vorrq_u32(a32, vshlq_n_u32(a32, 16)); // ____ ____ 1111 0000 |
| 79 return Sk16b((uint8x16_t)a32); |
| 80 } |
OLD | NEW |