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

Unified Diff: src/core/SkNx.h

Issue 1184113003: Thorough tests for saturatedAdd and mulDiv255Round. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix portable saturatedAdd() Created 5 years, 6 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 | « no previous file | tests/SkNxTest.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 d968cad19f6c687b6ef41720425dbe22ddb1fbe2..1342266b934f9c007062323a677a5d6bf904a0e6 100644
--- a/src/core/SkNx.h
+++ b/src/core/SkNx.h
@@ -184,7 +184,7 @@ public:
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));
+ return SkNi(sum < fVal ? (T)(~0) : sum);
}
SkNi operator + (const SkNi& o) const { return SkNi(fVal + o.fVal); }
« no previous file with comments | « no previous file | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698