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

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

Issue 1452903004: div255(x) as ((x+128)*257)>>16 with SSE (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: notes Created 5 years, 1 month 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 | « src/core/Sk4px.h ('k') | src/opts/Sk4px_SSE2.h » ('j') | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return Sk16h(vmull_u8(vget_low_u8 (this->fVec), vget_low_u8 (other.fVec)), 50 return Sk16h(vmull_u8(vget_low_u8 (this->fVec), vget_low_u8 (other.fVec)),
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 {
61 // Calculated as ((x+128) + ((x+128)>>8)) >> 8.
62 auto v = *this + Sk16h(128);
63 return v.addNarrowHi(v>>8);
64 }
65
60 inline Sk4px Sk4px::alphas() const { 66 inline Sk4px Sk4px::alphas() const {
61 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
62 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
63 } 69 }
64 70
65 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) { 71 inline Sk4px Sk4px::Load4Alphas(const SkAlpha a[4]) {
66 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ _ ___ 72 uint8x16_t a8 = vdupq_n_u8(0); // ____ ____ ____ _ ___
67 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ _ __0 73 a8 = vld1q_lane_u8(a+0, a8, 0); // ____ ____ ____ _ __0
68 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 _ __0 74 a8 = vld1q_lane_u8(a+1, a8, 4); // ____ ____ ___1 _ __0
69 a8 = vld1q_lane_u8(a+2, a8, 8); // ____ ___2 ___1 _ __0 75 a8 = vld1q_lane_u8(a+2, a8, 8); // ____ ___2 ___1 _ __0
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 auto v = narrow_to_565(this->fVec); 161 auto v = narrow_to_565(this->fVec);
156 dst[0] = vget_lane_u16(v, 0); 162 dst[0] = vget_lane_u16(v, 0);
157 dst[1] = vget_lane_u16(v, 1); 163 dst[1] = vget_lane_u16(v, 1);
158 } 164 }
159 inline void Sk4px::store1(SkPMColor16 dst[1]) const { 165 inline void Sk4px::store1(SkPMColor16 dst[1]) const {
160 dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0); 166 dst[0] = vget_lane_u16(narrow_to_565(this->fVec), 0);
161 } 167 }
162 168
163 } // namespace 169 } // namespace
164 170
OLDNEW
« no previous file with comments | « src/core/Sk4px.h ('k') | src/opts/Sk4px_SSE2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698