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

Unified Diff: src/core/Sk4pxXfermode.h

Issue 1230663005: 3-15% speedup to HardLight / Overlay xfermodes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add a test that widenLo() | widenHi() == widenLoHi() Created 5 years, 5 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/opts/Sk4px_NEON.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/Sk4pxXfermode.h
diff --git a/src/core/Sk4pxXfermode.h b/src/core/Sk4pxXfermode.h
index 98b0bd901f83d40ea23dd131b2bdcbd4d88456e0..97321b7413cdfe98ad8072f96f3082ac4ec98704 100644
--- a/src/core/Sk4pxXfermode.h
+++ b/src/core/Sk4pxXfermode.h
@@ -68,15 +68,13 @@ XFERMODE(HardLight) {
auto sa = s.alphas(),
da = d.alphas();
- auto isLite = (sa-s) < s;
+ auto isLite = ((sa-s) < s).widenLoHi();
auto dark = s*d << 1,
lite = sa*da - ((da-d)*(sa-s) << 1),
both = s*da.inv() + d*sa.inv();
- // TODO: do isLite in 16-bit so we only have to div255() once.
- auto colors = isLite.thenElse((lite + both).div255(),
- (dark + both).div255());
+ auto colors = (both + isLite.thenElse(lite, dark)).div255();
return alphas.zeroColors() + colors.zeroAlphas();
}
XFERMODE(Overlay) { return HardLight::Xfer(d,s); }
« no previous file with comments | « src/core/Sk4px.h ('k') | src/opts/Sk4px_NEON.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698