aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkNx.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-05-14 17:53:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-14 17:53:04 -0700
commit27e517ae533775889c98c65fa2f07b98357ecbc2 (patch)
treed704d214466ff9b951f5aa6c97326c382fddd9d0 /src/core/SkNx.h
parent9d214295e47405019d1494182a5182a92a22f0a6 (diff)
add Min to SkNi, specialized for u8 and u16 on SSE and NEON
0x8001 / 0x7fff don't seem to work, but we were close: 0x8000 does. I plan to use this to implement the Difference xfermode, and it seems generally handy. BUG=skia: Review URL: https://codereview.chromium.org/1133933004
Diffstat (limited to 'src/core/SkNx.h')
-rw-r--r--src/core/SkNx.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/SkNx.h b/src/core/SkNx.h
index ed939c3e4f..af7194840a 100644
--- a/src/core/SkNx.h
+++ b/src/core/SkNx.h
@@ -68,7 +68,11 @@ public:
SkNi operator << (int bits) const { return SkNi(fLo << bits, fHi << bits); }
SkNi operator >> (int bits) const { return SkNi(fLo >> bits, fHi >> bits); }
- // TODO: comparisons, min, max?
+ static SkNi Min(const SkNi& a, const SkNi& b) {
+ return SkNi(SkNi<N/2, T>::Min(a.fLo, b.fLo), SkNi<N/2, T>::Min(a.fHi, b.fHi));
+ }
+
+ // TODO: comparisons, max?
template <int k> T kth() const {
SkASSERT(0 <= k && k < N);
@@ -183,6 +187,8 @@ public:
SkNi operator << (int bits) const { return SkNi(fVal << bits); }
SkNi operator >> (int bits) const { return SkNi(fVal >> bits); }
+ static SkNi Min(const SkNi& a, const SkNi& b) { return SkNi(SkTMin(a.fVal, b.fVal)); }
+
template <int k> T kth() const {
SkASSERT(0 == k);
return fVal;