From 4be181e304d2b280c6801bd13369cfba236d1a66 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 14 Jul 2015 10:54:19 -0700 Subject: 3-15% speedup to HardLight / Overlay xfermodes. While investigating my bug (skia:4052) I saw this TODO and figured it'd make me feel better about an otherwise unsuccessful investigation. This speeds up HardLight and Overlay (same code) by about 15% with SSE, mostly by rewriting the logic from 1 cheap comparison and 2 expensive div255() calls to 2 cheap comparisons and 1 expensive div255(). NEON speeds up by a more modest ~3%. BUG=skia: Review URL: https://codereview.chromium.org/1230663005 --- tests/SkNxTest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/SkNxTest.cpp b/tests/SkNxTest.cpp index 58932148cb..4005d2518f 100644 --- a/tests/SkNxTest.cpp +++ b/tests/SkNxTest.cpp @@ -192,3 +192,19 @@ DEF_TEST(Sk4px_muldiv255round, r) { } } } + +DEF_TEST(Sk4px_widening, r) { + SkPMColor colors[] = { + SkPreMultiplyColor(0xff00ff00), + SkPreMultiplyColor(0x40008000), + SkPreMultiplyColor(0x7f020406), + SkPreMultiplyColor(0x00000000), + }; + auto packed = Sk4px::Load4(colors); + + auto wideLo = packed.widenLo(), + wideHi = packed.widenHi(), + wideLoHi = packed.widenLoHi(), + wideLoHiAlt = wideLo + wideHi; + REPORTER_ASSERT(r, 0 == memcmp(&wideLoHi, &wideLoHiAlt, sizeof(wideLoHi))); +} -- cgit v1.2.3