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 #ifndef SkNx_DEFINED | 8 #ifndef SkNx_DEFINED |
9 #define SkNx_DEFINED | 9 #define SkNx_DEFINED |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 Nb operator >= (const SkNf& o) const { return Nb(fLo >= o.fLo, fHi >= o.fHi)
; } | 112 Nb operator >= (const SkNf& o) const { return Nb(fLo >= o.fLo, fHi >= o.fHi)
; } |
113 | 113 |
114 static SkNf Min(const SkNf& l, const SkNf& r) { | 114 static SkNf Min(const SkNf& l, const SkNf& r) { |
115 return SkNf(SkNf<N/2,T>::Min(l.fLo, r.fLo), SkNf<N/2,T>::Min(l.fHi, r.fH
i)); | 115 return SkNf(SkNf<N/2,T>::Min(l.fLo, r.fLo), SkNf<N/2,T>::Min(l.fHi, r.fH
i)); |
116 } | 116 } |
117 static SkNf Max(const SkNf& l, const SkNf& r) { | 117 static SkNf Max(const SkNf& l, const SkNf& r) { |
118 return SkNf(SkNf<N/2,T>::Max(l.fLo, r.fLo), SkNf<N/2,T>::Max(l.fHi, r.fH
i)); | 118 return SkNf(SkNf<N/2,T>::Max(l.fLo, r.fLo), SkNf<N/2,T>::Max(l.fHi, r.fH
i)); |
119 } | 119 } |
120 | 120 |
121 SkNf sqrt() const { return SkNf(fLo. sqrt(), fHi. sqrt()); } | 121 SkNf sqrt() const { return SkNf(fLo. sqrt(), fHi. sqrt()); } |
122 SkNf rsqrt() const { return SkNf(fLo.rsqrt(), fHi.rsqrt()); } | 122 |
| 123 // Generally, increasing precision, increasing cost. |
| 124 SkNf rsqrt0() const { return SkNf(fLo.rsqrt0(), fHi.rsqrt0()); } |
| 125 SkNf rsqrt1() const { return SkNf(fLo.rsqrt1(), fHi.rsqrt1()); } |
| 126 SkNf rsqrt2() const { return SkNf(fLo.rsqrt2(), fHi.rsqrt2()); } |
123 | 127 |
124 SkNf invert() const { return SkNf(fLo. invert(), fHi. invert
()); } | 128 SkNf invert() const { return SkNf(fLo. invert(), fHi. invert
()); } |
125 SkNf approxInvert() const { return SkNf(fLo.approxInvert(), fHi.approxInvert
()); } | 129 SkNf approxInvert() const { return SkNf(fLo.approxInvert(), fHi.approxInvert
()); } |
126 | 130 |
127 template <int k> T kth() const { | 131 template <int k> T kth() const { |
128 SkASSERT(0 <= k && k < N); | 132 SkASSERT(0 <= k && k < N); |
129 return k < N/2 ? fLo.template kth<k>() : fHi.template kth<k-N/2>(); | 133 return k < N/2 ? fLo.template kth<k>() : fHi.template kth<k-N/2>(); |
130 } | 134 } |
131 | 135 |
132 private: | 136 private: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 Nb operator != (const SkNf& o) const { return Nb(fVal != o.fVal); } | 204 Nb operator != (const SkNf& o) const { return Nb(fVal != o.fVal); } |
201 Nb operator < (const SkNf& o) const { return Nb(fVal < o.fVal); } | 205 Nb operator < (const SkNf& o) const { return Nb(fVal < o.fVal); } |
202 Nb operator > (const SkNf& o) const { return Nb(fVal > o.fVal); } | 206 Nb operator > (const SkNf& o) const { return Nb(fVal > o.fVal); } |
203 Nb operator <= (const SkNf& o) const { return Nb(fVal <= o.fVal); } | 207 Nb operator <= (const SkNf& o) const { return Nb(fVal <= o.fVal); } |
204 Nb operator >= (const SkNf& o) const { return Nb(fVal >= o.fVal); } | 208 Nb operator >= (const SkNf& o) const { return Nb(fVal >= o.fVal); } |
205 | 209 |
206 static SkNf Min(const SkNf& l, const SkNf& r) { return SkNf(SkTMin(l.fVal, r
.fVal)); } | 210 static SkNf Min(const SkNf& l, const SkNf& r) { return SkNf(SkTMin(l.fVal, r
.fVal)); } |
207 static SkNf Max(const SkNf& l, const SkNf& r) { return SkNf(SkTMax(l.fVal, r
.fVal)); } | 211 static SkNf Max(const SkNf& l, const SkNf& r) { return SkNf(SkTMax(l.fVal, r
.fVal)); } |
208 | 212 |
209 SkNf sqrt() const { return SkNf(Sqrt(fVal)); } | 213 SkNf sqrt() const { return SkNf(Sqrt(fVal)); } |
210 SkNf rsqrt() const { return SkNf((T)1 / Sqrt(fVal)); } | 214 SkNf rsqrt0() const { return SkNf((T)1 / Sqrt(fVal)); } |
| 215 SkNf rsqrt1() const { return this->rsqrt0(); } |
| 216 SkNf rsqrt2() const { return this->rsqrt1(); } |
211 | 217 |
212 SkNf invert() const { return SkNf((T)1 / fVal); } | 218 SkNf invert() const { return SkNf((T)1 / fVal); } |
213 SkNf approxInvert() const { return this->invert(); } | 219 SkNf approxInvert() const { return this->invert(); } |
214 | 220 |
215 template <int k> T kth() const { | 221 template <int k> T kth() const { |
216 SkASSERT(k == 0); | 222 SkASSERT(k == 0); |
217 return fVal; | 223 return fVal; |
218 } | 224 } |
219 | 225 |
220 private: | 226 private: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 typedef SkNf<4, float> Sk4f; | 262 typedef SkNf<4, float> Sk4f; |
257 typedef SkNf<4, double> Sk4d; | 263 typedef SkNf<4, double> Sk4d; |
258 typedef SkNf<4, SkScalar> Sk4s; | 264 typedef SkNf<4, SkScalar> Sk4s; |
259 | 265 |
260 typedef SkNi<4, uint16_t> Sk4h; | 266 typedef SkNi<4, uint16_t> Sk4h; |
261 typedef SkNi<8, uint16_t> Sk8h; | 267 typedef SkNi<8, uint16_t> Sk8h; |
262 | 268 |
263 typedef SkNi<4, int> Sk4i; | 269 typedef SkNi<4, int> Sk4i; |
264 | 270 |
265 #endif//SkNx_DEFINED | 271 #endif//SkNx_DEFINED |
OLD | NEW |