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

Side by Side Diff: src/core/SkNx.h

Issue 1133933004: add Min to SkNi, specialized for u8 and u16 on SSE and NEON (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixes Created 5 years, 7 months 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 | src/opts/SkNx_neon.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 #ifndef SkNx_DEFINED 8 #ifndef SkNx_DEFINED
9 #define SkNx_DEFINED 9 #define SkNx_DEFINED
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return SkNi(fLo.saturatedAdd(o.fLo), fHi.saturatedAdd(o.fHi)); 61 return SkNi(fLo.saturatedAdd(o.fLo), fHi.saturatedAdd(o.fHi));
62 } 62 }
63 63
64 SkNi operator + (const SkNi& o) const { return SkNi(fLo + o.fLo, fHi + o.fHi ); } 64 SkNi operator + (const SkNi& o) const { return SkNi(fLo + o.fLo, fHi + o.fHi ); }
65 SkNi operator - (const SkNi& o) const { return SkNi(fLo - o.fLo, fHi - o.fHi ); } 65 SkNi operator - (const SkNi& o) const { return SkNi(fLo - o.fLo, fHi - o.fHi ); }
66 SkNi operator * (const SkNi& o) const { return SkNi(fLo * o.fLo, fHi * o.fHi ); } 66 SkNi operator * (const SkNi& o) const { return SkNi(fLo * o.fLo, fHi * o.fHi ); }
67 67
68 SkNi operator << (int bits) const { return SkNi(fLo << bits, fHi << bits); } 68 SkNi operator << (int bits) const { return SkNi(fLo << bits, fHi << bits); }
69 SkNi operator >> (int bits) const { return SkNi(fLo >> bits, fHi >> bits); } 69 SkNi operator >> (int bits) const { return SkNi(fLo >> bits, fHi >> bits); }
70 70
71 // TODO: comparisons, min, max? 71 static SkNi Min(const SkNi& a, const SkNi& b) {
72 return SkNi(SkNi<N/2, T>::Min(a.fLo, b.fLo), SkNi<N/2, T>::Min(a.fHi, b. fHi));
73 }
74
75 // TODO: comparisons, max?
72 76
73 template <int k> T kth() const { 77 template <int k> T kth() const {
74 SkASSERT(0 <= k && k < N); 78 SkASSERT(0 <= k && k < N);
75 return k < N/2 ? fLo.template kth<k>() : fHi.template kth<k-N/2>(); 79 return k < N/2 ? fLo.template kth<k>() : fHi.template kth<k-N/2>();
76 } 80 }
77 81
78 protected: 82 protected:
79 REQUIRE(0 == (N & (N-1))); 83 REQUIRE(0 == (N & (N-1)));
80 84
81 SkNi<N/2, T> fLo, fHi; 85 SkNi<N/2, T> fLo, fHi;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return SkNi(sum > fVal ? sum : (T)(~0)); 180 return SkNi(sum > fVal ? sum : (T)(~0));
177 } 181 }
178 182
179 SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); } 183 SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); }
180 SkNi operator - (const SkNi& o) const { return SkNi(fVal - o.fVal); } 184 SkNi operator - (const SkNi& o) const { return SkNi(fVal - o.fVal); }
181 SkNi operator * (const SkNi& o) const { return SkNi(fVal * o.fVal); } 185 SkNi operator * (const SkNi& o) const { return SkNi(fVal * o.fVal); }
182 186
183 SkNi operator << (int bits) const { return SkNi(fVal << bits); } 187 SkNi operator << (int bits) const { return SkNi(fVal << bits); }
184 SkNi operator >> (int bits) const { return SkNi(fVal >> bits); } 188 SkNi operator >> (int bits) const { return SkNi(fVal >> bits); }
185 189
190 static SkNi Min(const SkNi& a, const SkNi& b) { return SkNi(SkTMin(a.fVal, b .fVal)); }
191
186 template <int k> T kth() const { 192 template <int k> T kth() const {
187 SkASSERT(0 == k); 193 SkASSERT(0 == k);
188 return fVal; 194 return fVal;
189 } 195 }
190 196
191 protected: 197 protected:
192 T fVal; 198 T fVal;
193 }; 199 };
194 200
195 template <typename T> 201 template <typename T>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 typedef SkNi<4, uint16_t> Sk4h; 285 typedef SkNi<4, uint16_t> Sk4h;
280 typedef SkNi<8, uint16_t> Sk8h; 286 typedef SkNi<8, uint16_t> Sk8h;
281 typedef SkNi<16, uint16_t> Sk16h; 287 typedef SkNi<16, uint16_t> Sk16h;
282 288
283 typedef SkNi<16, uint8_t> Sk16b; 289 typedef SkNi<16, uint8_t> Sk16b;
284 290
285 typedef SkNi<4, int32_t> Sk4i; 291 typedef SkNi<4, int32_t> Sk4i;
286 typedef SkNi<4, uint32_t> Sk4u; 292 typedef SkNi<4, uint32_t> Sk4u;
287 293
288 #endif//SkNx_DEFINED 294 #endif//SkNx_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698