| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // These just keep the types as Sk4px so the user doesn't have to keep casti
ng. | 96 // These just keep the types as Sk4px so the user doesn't have to keep casti
ng. |
| 97 Sk4px operator + (const Sk4px& o) const { return INHERITED::operator+(o); } | 97 Sk4px operator + (const Sk4px& o) const { return INHERITED::operator+(o); } |
| 98 Sk4px operator - (const Sk4px& o) const { return INHERITED::operator-(o); } | 98 Sk4px operator - (const Sk4px& o) const { return INHERITED::operator-(o); } |
| 99 Sk4px operator < (const Sk4px& o) const { return INHERITED::operator<(o); } | 99 Sk4px operator < (const Sk4px& o) const { return INHERITED::operator<(o); } |
| 100 Sk4px thenElse(const Sk4px& t, const Sk4px& e) const { return INHERITED::the
nElse(t,e); } | 100 Sk4px thenElse(const Sk4px& t, const Sk4px& e) const { return INHERITED::the
nElse(t,e); } |
| 101 | 101 |
| 102 // Generally faster than (*this * o).div255(). | 102 // Generally faster than (*this * o).div255(). |
| 103 // May be incorrect by +-1, but is always exactly correct when *this or o is
0 or 255. | 103 // May be incorrect by +-1, but is always exactly correct when *this or o is
0 or 255. |
| 104 Sk4px approxMulDiv255(const Sk16b& o) const { | 104 Sk4px approxMulDiv255(const Sk16b& o) const { |
| 105 // (x*y + x) / 256 meets these criteria. (As of course does (x*y + y) /
256 by symmetry.) | 105 // (x*y + x) / 256 meets these criteria. (As of course does (x*y + y) /
256 by symmetry.) |
| 106 // FYI: (x*y + 255) / 256 also meets these criteria. In my brief testin
g, it was slower. |
| 106 return this->widenLo().addNarrowHi(*this * o); | 107 return this->widenLo().addNarrowHi(*this * o); |
| 107 } | 108 } |
| 108 | 109 |
| 109 // A generic driver that maps fn over a src array into a dst array. | 110 // A generic driver that maps fn over a src array into a dst array. |
| 110 // fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels)
. | 111 // fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels)
. |
| 111 template <typename Fn, typename Dst> | 112 template <typename Fn, typename Dst> |
| 112 static void MapSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) { | 113 static void MapSrc(int n, Dst* dst, const SkPMColor* src, const Fn& fn) { |
| 113 SkASSERT(dst); | 114 SkASSERT(dst); |
| 114 SkASSERT(src); | 115 SkASSERT(src); |
| 115 // This looks a bit odd, but it helps loop-invariant hoisting across dif
ferent calls to fn. | 116 // This looks a bit odd, but it helps loop-invariant hoisting across dif
ferent calls to fn. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 244 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
| 244 #include "../opts/Sk4px_SSE2.h" | 245 #include "../opts/Sk4px_SSE2.h" |
| 245 #elif defined(SK_ARM_HAS_NEON) | 246 #elif defined(SK_ARM_HAS_NEON) |
| 246 #include "../opts/Sk4px_NEON.h" | 247 #include "../opts/Sk4px_NEON.h" |
| 247 #else | 248 #else |
| 248 #include "../opts/Sk4px_none.h" | 249 #include "../opts/Sk4px_none.h" |
| 249 #endif | 250 #endif |
| 250 #endif | 251 #endif |
| 251 | 252 |
| 252 #endif//Sk4px_DEFINED | 253 #endif//Sk4px_DEFINED |
| OLD | NEW |