Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/opts/Sk4px_NEON.h

Issue 1502843002: better NEON div255 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 namespace { // See Sk4px.h 8 namespace { // See Sk4px.h
9 9
10 inline Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b((uint8x16_t)vdupq_n_ u32(px)); } 10 inline Sk4px Sk4px::DupPMColor(SkPMColor px) { return Sk16b((uint8x16_t)vdupq_n_ u32(px)); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 vmull_u8(vget_high_u8(this->fVec), vget_high_u8(other.fVec))); 51 vmull_u8(vget_high_u8(this->fVec), vget_high_u8(other.fVec)));
52 } 52 }
53 53
54 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const { 54 inline Sk4px Sk4px::Wide::addNarrowHi(const Sk16h& other) const {
55 const Sk4px::Wide o(other); // Should be no code, but allows us to access f Lo, fHi. 55 const Sk4px::Wide o(other); // Should be no code, but allows us to access f Lo, fHi.
56 return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec), 56 return Sk16b(vcombine_u8(vaddhn_u16(this->fLo.fVec, o.fLo.fVec),
57 vaddhn_u16(this->fHi.fVec, o.fHi.fVec))); 57 vaddhn_u16(this->fHi.fVec, o.fHi.fVec)));
58 } 58 }
59 59
60 inline Sk4px Sk4px::Wide::div255() const { 60 inline Sk4px Sk4px::Wide::div255() const {
61 // Calculated as ((x+128) + ((x+128)>>8)) >> 8. 61 // Calculated as (x + (x+128)>>8 +128) >> 8. The 'r' in each instruction pr ovides each +128.
62 auto v = *this + Sk16h(128); 62 return Sk16b(vcombine_u8(vraddhn_u16(this->fLo.fVec, vrshrq_n_u16(this->fLo. fVec, 8)),
63 return v.addNarrowHi(v>>8); 63 vraddhn_u16(this->fHi.fVec, vrshrq_n_u16(this->fHi. fVec, 8))));
64 } 64 }
65 65
66 inline Sk4px Sk4px::alphas() const { 66 inline Sk4px Sk4px::alphas() const {
67 auto as = vshrq_n_u32((uint32x4_t)fVec, SK_A32_SHIFT); // ___3 ___2 ___1 __ _0 67 auto as = vshrq_n_u32((uint32x4_t)fVec, SK_A32_SHIFT); // ___3 ___2 ___1 __ _0
68 return Sk16b((uint8x16_t)vmulq_n_u32(as, 0x01010101)); // 3333 2222 1111 00 00 68 return Sk16b((uint8x16_t)vmulq_n_u32(as, 0x01010101)); // 3333 2222 1111 00 00
69 } 69 }
70 70
71 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { 71 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
72 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ _ ___ 72 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ _ ___
73 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ _ __0 73 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ _ __0
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 auto v = narrow_to_565(this->fVec); 161 auto v = narrow_to_565(this->fVec);
162 dst[0] = vget_lane_u16(v, 0); 162 dst[0] = vget_lane_u16(v, 0);
163 dst[1] = vget_lane_u16(v, 1); 163 dst[1] = vget_lane_u16(v, 1);
164 } 164 }
165 inline void Sk4px::store1(SkPMColor16 dst[1]) const { 165 inline void Sk4px::store1(SkPMColor16 dst[1]) const {
166 dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0); 166 dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0);
167 } 167 }
168 168
169 } // namespace 169 } // namespace
170 170
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698