diff options
author | Herb Derby <herb@google.com> | 2017-10-10 17:14:18 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-11 08:21:09 +0000 |
commit | 5eb1528234733e548a6417161e0b70ce333dbd1d (patch) | |
tree | 497d3fba05965fc55d039154b5393d6adb457704 /src/core/SkNx.h | |
parent | 67cf6896f7f018815521d2ecb5d7c7131a30753e (diff) |
Add mulHi to SkNx
Add mulHi to base SkNx, and specialize implementations for Sk4u for
neon and sse.
Add casts for converting from uint8_t by 4 to uint32_t by 4.
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Change-Id: I29a32e2ad9812a47fff841ceca334e562362836f
Reviewed-on: https://skia-review.googlesource.com/57960
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkNx.h')
-rw-r--r-- | src/core/SkNx.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/SkNx.h b/src/core/SkNx.h index 65e3fcb8c8..6957cb0d38 100644 --- a/src/core/SkNx.h +++ b/src/core/SkNx.h @@ -119,10 +119,13 @@ struct SkNx { AI SkNx saturatedAdd(const SkNx& y) const { return { fLo.saturatedAdd(y.fLo), fHi.saturatedAdd(y.fHi) }; } + + AI SkNx mulHi(const SkNx& m) const { + return { fLo.mulHi(m.fLo), fHi.mulHi(m.fHi) }; + } AI SkNx thenElse(const SkNx& t, const SkNx& e) const { return { fLo.thenElse(t.fLo, e.fLo), fHi.thenElse(t.fHi, e.fHi) }; } - AI static SkNx Min(const SkNx& x, const SkNx& y) { return { Half::Min(x.fLo, y.fLo), Half::Min(x.fHi, y.fHi) }; } @@ -214,6 +217,12 @@ struct SkNx<1,T> { return sum < fVal ? std::numeric_limits<T>::max() : sum; } + AI SkNx mulHi(const SkNx& m) const { + static_assert(std::is_unsigned<T>::value, ""); + static_assert(sizeof(T) <= 4, ""); + return static_cast<T>((static_cast<uint64_t>(fVal) * m.fVal) >> (sizeof(T)*8)); + } + AI SkNx thenElse(const SkNx& t, const SkNx& e) const { return fVal != 0 ? t : e; } private: |