Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: src/core/SkNx.h

Issue 1138893002: Plus xfermode using Sk4px. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/Sk4px.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); }
« no previous file with comments | « src/core/Sk4px.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698