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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 fLo.store(vals); | 106 fLo.store(vals); |
107 fHi.store(vals+N/2); | 107 fHi.store(vals+N/2); |
108 } | 108 } |
109 // Please see note on FromBytes(). | 109 // Please see note on FromBytes(). |
110 // Clamps to [0.0,255.0] floats and truncates to [0,255] bytes. | 110 // Clamps to [0.0,255.0] floats and truncates to [0,255] bytes. |
111 void toBytes(uint8_t bytes[N]) const { | 111 void toBytes(uint8_t bytes[N]) const { |
112 fLo.toBytes(bytes); | 112 fLo.toBytes(bytes); |
113 fHi.toBytes(bytes+N/2); | 113 fHi.toBytes(bytes+N/2); |
114 } | 114 } |
115 | 115 |
| 116 // Some implementations can do this faster. |
| 117 static void ToBytes(uint8_t bytes[4*N], |
| 118 const SkNx& a, const SkNx& b, const SkNx& c, const SkNx&
d) { |
| 119 a.toBytes(bytes+0*N); |
| 120 b.toBytes(bytes+1*N); |
| 121 c.toBytes(bytes+2*N); |
| 122 d.toBytes(bytes+3*N); |
| 123 } |
| 124 |
116 SkNx operator + (const SkNx& o) const { return SkNx(fLo + o.fLo, fHi + o.fHi
); } | 125 SkNx operator + (const SkNx& o) const { return SkNx(fLo + o.fLo, fHi + o.fHi
); } |
117 SkNx operator - (const SkNx& o) const { return SkNx(fLo - o.fLo, fHi - o.fHi
); } | 126 SkNx operator - (const SkNx& o) const { return SkNx(fLo - o.fLo, fHi - o.fHi
); } |
118 SkNx operator * (const SkNx& o) const { return SkNx(fLo * o.fLo, fHi * o.fHi
); } | 127 SkNx operator * (const SkNx& o) const { return SkNx(fLo * o.fLo, fHi * o.fHi
); } |
119 SkNx operator / (const SkNx& o) const { return SkNx(fLo / o.fLo, fHi / o.fHi
); } | 128 SkNx operator / (const SkNx& o) const { return SkNx(fLo / o.fLo, fHi / o.fHi
); } |
120 | 129 |
121 SkNx operator == (const SkNx& o) const { return SkNx(fLo == o.fLo, fHi == o.
fHi); } | 130 SkNx operator == (const SkNx& o) const { return SkNx(fLo == o.fLo, fHi == o.
fHi); } |
122 SkNx operator != (const SkNx& o) const { return SkNx(fLo != o.fLo, fHi != o.
fHi); } | 131 SkNx operator != (const SkNx& o) const { return SkNx(fLo != o.fLo, fHi != o.
fHi); } |
123 SkNx operator < (const SkNx& o) const { return SkNx(fLo < o.fLo, fHi < o.
fHi); } | 132 SkNx operator < (const SkNx& o) const { return SkNx(fLo < o.fLo, fHi < o.
fHi); } |
124 SkNx operator > (const SkNx& o) const { return SkNx(fLo > o.fLo, fHi > o.
fHi); } | 133 SkNx operator > (const SkNx& o) const { return SkNx(fLo > o.fLo, fHi > o.
fHi); } |
125 SkNx operator <= (const SkNx& o) const { return SkNx(fLo <= o.fLo, fHi <= o.
fHi); } | 134 SkNx operator <= (const SkNx& o) const { return SkNx(fLo <= o.fLo, fHi <= o.
fHi); } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 typedef SkNx<8, float> Sk8f; | 327 typedef SkNx<8, float> Sk8f; |
319 typedef SkNx<8, float> Sk8s; | 328 typedef SkNx<8, float> Sk8s; |
320 | 329 |
321 typedef SkNx<8, uint16_t> Sk8h; | 330 typedef SkNx<8, uint16_t> Sk8h; |
322 typedef SkNx<16, uint16_t> Sk16h; | 331 typedef SkNx<16, uint16_t> Sk16h; |
323 typedef SkNx<16, uint8_t> Sk16b; | 332 typedef SkNx<16, uint8_t> Sk16b; |
324 | 333 |
325 typedef SkNx<4, int> Sk4i; | 334 typedef SkNx<4, int> Sk4i; |
326 | 335 |
327 #endif//SkNx_DEFINED | 336 #endif//SkNx_DEFINED |
OLD | NEW |