Index: src/core/SkNx.h |
diff --git a/src/core/SkNx.h b/src/core/SkNx.h |
index 9d319623a6f473e34795eb91a1983bf8aa8ef74b..ed939c3e4feb9824a7a3b011166df5b9c459cd4b 100644 |
--- a/src/core/SkNx.h |
+++ b/src/core/SkNx.h |
@@ -57,6 +57,10 @@ public: |
fHi.store(vals+N/2); |
} |
+ SkNi saturatedAdd(const SkNi& o) const { |
+ return SkNi(fLo.saturatedAdd(o.fLo), fHi.saturatedAdd(o.fHi)); |
+ } |
+ |
SkNi operator + (const SkNi& o) const { return SkNi(fLo + o.fLo, fHi + o.fHi); } |
SkNi operator - (const SkNi& o) const { return SkNi(fLo - o.fLo, fHi - o.fHi); } |
SkNi operator * (const SkNi& o) const { return SkNi(fLo * o.fLo, fHi * o.fHi); } |
@@ -166,6 +170,12 @@ public: |
void store(T vals[1]) const { vals[0] = fVal; } |
+ SkNi saturatedAdd(const SkNi& o) const { |
+ SkASSERT((T)(~0) > 0); // TODO: support signed T |
+ T sum = fVal + o.fVal; |
+ return SkNi(sum > fVal ? sum : (T)(~0)); |
+ } |
+ |
SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); } |
SkNi operator - (const SkNi& o) const { return SkNi(fVal - o.fVal); } |
SkNi operator * (const SkNi& o) const { return SkNi(fVal * o.fVal); } |