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 Sk4px_DEFINED | 8 #ifndef Sk4px_DEFINED |
9 #define Sk4px_DEFINED | 9 #define Sk4px_DEFINED |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // 1, 2, or 4 SkPMColors with 16-bit components. | 59 // 1, 2, or 4 SkPMColors with 16-bit components. |
60 // This is most useful as the result of a multiply, e.g. from mulWiden(). | 60 // This is most useful as the result of a multiply, e.g. from mulWiden(). |
61 class Wide : public Sk16h { | 61 class Wide : public Sk16h { |
62 public: | 62 public: |
63 Wide(const Sk16h& v) : Sk16h(v) {} | 63 Wide(const Sk16h& v) : Sk16h(v) {} |
64 | 64 |
65 // Pack the top byte of each component back down into 4 SkPMColors. | 65 // Pack the top byte of each component back down into 4 SkPMColors. |
66 Sk4px addNarrowHi(const Sk16h&) const; | 66 Sk4px addNarrowHi(const Sk16h&) const; |
67 | 67 |
68 // Rounds, i.e. (x+127) / 255. | 68 // Rounds, i.e. (x+127) / 255. |
69 Sk4px div255() const { | 69 Sk4px div255() const; |
70 // Calculated as ((x+128) + ((x+128)>>8)) >> 8. | |
71 auto v = *this + Sk16h(128); | |
72 return v.addNarrowHi(v >> 8); | |
73 } | |
74 | 70 |
75 // These just keep the types as Wide so the user doesn't have to keep ca
sting. | 71 // These just keep the types as Wide so the user doesn't have to keep ca
sting. |
76 Wide operator * (const Wide& o) const { return INHERITED::operator*(o);
} | 72 Wide operator * (const Wide& o) const { return INHERITED::operator*(o);
} |
77 Wide operator + (const Wide& o) const { return INHERITED::operator+(o);
} | 73 Wide operator + (const Wide& o) const { return INHERITED::operator+(o);
} |
78 Wide operator - (const Wide& o) const { return INHERITED::operator-(o);
} | 74 Wide operator - (const Wide& o) const { return INHERITED::operator-(o);
} |
79 Wide operator >> (int bits) const { return INHERITED::operator>>(bits);
} | 75 Wide operator >> (int bits) const { return INHERITED::operator>>(bits);
} |
80 Wide operator << (int bits) const { return INHERITED::operator<<(bits);
} | 76 Wide operator << (int bits) const { return INHERITED::operator<<(bits);
} |
81 static Wide Min(const Wide& a, const Wide& b) { return INHERITED::Min(a,
b); } | 77 static Wide Min(const Wide& a, const Wide& b) { return INHERITED::Min(a,
b); } |
82 Wide thenElse(const Wide& t, const Wide& e) const { return INHERITED::th
enElse(t,e); } | 78 Wide thenElse(const Wide& t, const Wide& e) const { return INHERITED::th
enElse(t,e); } |
83 | 79 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 240 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
245 #include "../opts/Sk4px_SSE2.h" | 241 #include "../opts/Sk4px_SSE2.h" |
246 #elif defined(SK_ARM_HAS_NEON) | 242 #elif defined(SK_ARM_HAS_NEON) |
247 #include "../opts/Sk4px_NEON.h" | 243 #include "../opts/Sk4px_NEON.h" |
248 #else | 244 #else |
249 #include "../opts/Sk4px_none.h" | 245 #include "../opts/Sk4px_none.h" |
250 #endif | 246 #endif |
251 #endif | 247 #endif |
252 | 248 |
253 #endif//Sk4px_DEFINED | 249 #endif//Sk4px_DEFINED |
OLD | NEW |