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

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

Issue 1679343004: Revert of Sk4f: add floor() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « bench/Sk4fBench.cpp ('k') | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 fHi.store(vals+N/2); 43 fHi.store(vals+N/2);
44 } 44 }
45 45
46 #define OP(op) SkNx operator op(const SkNx& o) const { return {fLo op o.fLo, fHi op o.fHi}; } 46 #define OP(op) SkNx operator op(const SkNx& o) const { return {fLo op o.fLo, fHi op o.fHi}; }
47 OP(+) OP(-) OP(*) OP(/) 47 OP(+) OP(-) OP(*) OP(/)
48 OP(&) OP(|) OP(^) 48 OP(&) OP(|) OP(^)
49 OP(==) OP(!=) OP(<) OP(>) OP(<=) OP(>=) 49 OP(==) OP(!=) OP(<) OP(>) OP(<=) OP(>=)
50 #undef OP 50 #undef OP
51 51
52 #define OP(op) SkNx op() const { return {fLo.op(), fHi.op()}; } 52 #define OP(op) SkNx op() const { return {fLo.op(), fHi.op()}; }
53 OP(abs) OP(floor) 53 OP(abs)
54 OP(sqrt) OP(rsqrt0) OP(rsqrt1) OP(rsqrt2) 54 OP(sqrt) OP(rsqrt0) OP(rsqrt1) OP(rsqrt2)
55 OP(invert) OP(approxInvert) 55 OP(invert) OP(approxInvert)
56 #undef OP 56 #undef OP
57 57
58 SkNx operator << (int bits) const { return SkNx(fLo << bits, fHi << bits); } 58 SkNx operator << (int bits) const { return SkNx(fLo << bits, fHi << bits); }
59 SkNx operator >> (int bits) const { return SkNx(fLo >> bits, fHi >> bits); } 59 SkNx operator >> (int bits) const { return SkNx(fLo >> bits, fHi >> bits); }
60 60
61 SkNx saturatedAdd(const SkNx& o) const { 61 SkNx saturatedAdd(const SkNx& o) const {
62 return {fLo.saturatedAdd(o.fLo), fHi.saturatedAdd(o.fHi)}; 62 return {fLo.saturatedAdd(o.fLo), fHi.saturatedAdd(o.fHi)};
63 } 63 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SkNx saturatedAdd(const SkNx& o) const { 117 SkNx saturatedAdd(const SkNx& o) const {
118 SkASSERT((T)(~0) > 0); // TODO: support signed T? 118 SkASSERT((T)(~0) > 0); // TODO: support signed T?
119 T sum = fVal + o.fVal; 119 T sum = fVal + o.fVal;
120 return sum < fVal ? (T)(~0) : sum; 120 return sum < fVal ? (T)(~0) : sum;
121 } 121 }
122 122
123 static SkNx Min(const SkNx& a, const SkNx& b) { return SkTMin(a.fVal, b.fVal ); } 123 static SkNx Min(const SkNx& a, const SkNx& b) { return SkTMin(a.fVal, b.fVal ); }
124 static SkNx Max(const SkNx& a, const SkNx& b) { return SkTMax(a.fVal, b.fVal ); } 124 static SkNx Max(const SkNx& a, const SkNx& b) { return SkTMax(a.fVal, b.fVal ); }
125 125
126 SkNx abs() const { return SkTAbs(fVal); } 126 SkNx abs() const { return SkTAbs(fVal); }
127 SkNx floor() const { return Floor(fVal); }
128 127
129 SkNx sqrt () const { return Sqrt(fVal); } 128 SkNx sqrt () const { return Sqrt(fVal); }
130 SkNx rsqrt0() const { return this->sqrt().invert(); } 129 SkNx rsqrt0() const { return this->sqrt().invert(); }
131 SkNx rsqrt1() const { return this->rsqrt0(); } 130 SkNx rsqrt1() const { return this->rsqrt0(); }
132 SkNx rsqrt2() const { return this->rsqrt1(); } 131 SkNx rsqrt2() const { return this->rsqrt1(); }
133 132
134 SkNx invert() const { return 1 / fVal; } 133 SkNx invert() const { return 1 / fVal; }
135 SkNx approxInvert() const { return this->invert(); } 134 SkNx approxInvert() const { return this->invert(); }
136 135
137 T operator[](int k) const { 136 T operator[](int k) const {
138 SkASSERT(0 == k); 137 SkASSERT(0 == k);
139 return fVal; 138 return fVal;
140 } 139 }
141 140
142 template <int k> T kth() const { return (*this)[k]; } 141 template <int k> T kth() const { return (*this)[k]; }
143 142
144 bool allTrue() const { return fVal != 0; } 143 bool allTrue() const { return fVal != 0; }
145 bool anyTrue() const { return fVal != 0; } 144 bool anyTrue() const { return fVal != 0; }
146 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e ; } 145 SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e ; }
147 146
148 protected: 147 protected:
149 static double Floor(double val) { return ::floor (val); }
150 static float Floor(float val) { return ::floorf(val); }
151 static double Sqrt(double val) { return ::sqrt (val); } 148 static double Sqrt(double val) { return ::sqrt (val); }
152 static float Sqrt(float val) { return ::sqrtf(val); } 149 static float Sqrt(float val) { return ::sqrtf(val); }
153 150
154 T fVal; 151 T fVal;
155 }; 152 };
156 153
157 // This generic shuffle can be called to create any valid SkNx<N,T>. 154 // This generic shuffle can be called to create any valid SkNx<N,T>.
158 // Sk4f f(a,b,c,d); 155 // Sk4f f(a,b,c,d);
159 // Sk2f t = SkNx_shuffle<2,1>(f); // ~~~> Sk2f(c,b) 156 // Sk2f t = SkNx_shuffle<2,1>(f); // ~~~> Sk2f(c,b)
160 // f = SkNx_shuffle<0,1,1,0>(t); // ~~~> Sk4f(c,b,b,c) 157 // f = SkNx_shuffle<0,1,1,0>(t); // ~~~> Sk4f(c,b,b,c)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 static inline 205 static inline
209 void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c , const Sk4f& d) { 206 void Sk4f_ToBytes(uint8_t p[16], const Sk4f& a, const Sk4f& b, const Sk4f& c , const Sk4f& d) {
210 SkNx_cast<uint8_t>(a).store(p+ 0); 207 SkNx_cast<uint8_t>(a).store(p+ 0);
211 SkNx_cast<uint8_t>(b).store(p+ 4); 208 SkNx_cast<uint8_t>(b).store(p+ 4);
212 SkNx_cast<uint8_t>(c).store(p+ 8); 209 SkNx_cast<uint8_t>(c).store(p+ 8);
213 SkNx_cast<uint8_t>(d).store(p+12); 210 SkNx_cast<uint8_t>(d).store(p+12);
214 } 211 }
215 #endif 212 #endif
216 213
217 #endif//SkNx_DEFINED 214 #endif//SkNx_DEFINED
OLDNEW
« no previous file with comments | « bench/Sk4fBench.cpp ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698