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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 public: | 177 public: |
178 SkNi() {} | 178 SkNi() {} |
179 explicit SkNi(T val) : fVal(val) {} | 179 explicit SkNi(T val) : fVal(val) {} |
180 static SkNi Load(const T vals[1]) { return SkNi(vals[0]); } | 180 static SkNi Load(const T vals[1]) { return SkNi(vals[0]); } |
181 | 181 |
182 void store(T vals[1]) const { vals[0] = fVal; } | 182 void store(T vals[1]) const { vals[0] = fVal; } |
183 | 183 |
184 SkNi saturatedAdd(const SkNi& o) const { | 184 SkNi saturatedAdd(const SkNi& o) const { |
185 SkASSERT((T)(~0) > 0); // TODO: support signed T | 185 SkASSERT((T)(~0) > 0); // TODO: support signed T |
186 T sum = fVal + o.fVal; | 186 T sum = fVal + o.fVal; |
187 return SkNi(sum > fVal ? sum : (T)(~0)); | 187 return SkNi(sum < fVal ? (T)(~0) : sum); |
188 } | 188 } |
189 | 189 |
190 SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); } | 190 SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); } |
191 SkNi operator - (const SkNi& o) const { return SkNi(fVal - o.fVal); } | 191 SkNi operator - (const SkNi& o) const { return SkNi(fVal - o.fVal); } |
192 SkNi operator * (const SkNi& o) const { return SkNi(fVal * o.fVal); } | 192 SkNi operator * (const SkNi& o) const { return SkNi(fVal * o.fVal); } |
193 | 193 |
194 SkNi operator << (int bits) const { return SkNi(fVal << bits); } | 194 SkNi operator << (int bits) const { return SkNi(fVal << bits); } |
195 SkNi operator >> (int bits) const { return SkNi(fVal >> bits); } | 195 SkNi operator >> (int bits) const { return SkNi(fVal >> bits); } |
196 | 196 |
197 static SkNi Min(const SkNi& a, const SkNi& b) { return SkNi(SkTMin(a.fVal, b
.fVal)); } | 197 static SkNi Min(const SkNi& a, const SkNi& b) { return SkNi(SkTMin(a.fVal, b
.fVal)); } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 typedef SkNi<4, uint16_t> Sk4h; | 282 typedef SkNi<4, uint16_t> Sk4h; |
283 typedef SkNi<8, uint16_t> Sk8h; | 283 typedef SkNi<8, uint16_t> Sk8h; |
284 typedef SkNi<16, uint16_t> Sk16h; | 284 typedef SkNi<16, uint16_t> Sk16h; |
285 | 285 |
286 typedef SkNi<16, uint8_t> Sk16b; | 286 typedef SkNi<16, uint8_t> Sk16b; |
287 | 287 |
288 typedef SkNi<4, int32_t> Sk4i; | 288 typedef SkNi<4, int32_t> Sk4i; |
289 typedef SkNi<4, uint32_t> Sk4u; | 289 typedef SkNi<4, uint32_t> Sk4u; |
290 | 290 |
291 #endif//SkNx_DEFINED | 291 #endif//SkNx_DEFINED |
OLD | NEW |