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

Unified Diff: src/core/Sk4px.h

Issue 1141953004: sk4px the rest of the easy xfermodes. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: unify 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 | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/Sk4px.h
diff --git a/src/core/Sk4px.h b/src/core/Sk4px.h
index 028630d100eaedb899505e5bc766e57a1c0e051f..48e09e1c9200d3dbb2d87f4441ca2f534a037cae 100644
--- a/src/core/Sk4px.h
+++ b/src/core/Sk4px.h
@@ -65,6 +65,15 @@ public:
return this->mulWiden(Sk16b(255));
}
+ // Generally faster than this->mulWiden(other).div255RoundNarrow().
+ // May be incorrect by +-1, but is always exactly correct when *this or other is 0 or 255.
+ Sk4px fastMulDiv255Round(const Sk16b& other) const {
+ // (x*y + x) / 256 meets these criteria. (As of course does (x*y + y) / 256 by symmetry.)
+ Sk4px::Wide x = this->widenLo(),
+ xy = this->mulWiden(other);
+ return x.addNarrowHi(xy);
+ }
+
// A generic driver that maps fn over a src array into a dst array.
// fn should take an Sk4px (4 src pixels) and return an Sk4px (4 dst pixels).
template <typename Fn>
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698