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

Unified Diff: src/opts/SkXfermode_opts_SSE2.cpp

Issue 233733005: Xfermode: SSE2 implementation of exclusion_modeproc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkXfermode_opts_SSE2.cpp
diff --git a/src/opts/SkXfermode_opts_SSE2.cpp b/src/opts/SkXfermode_opts_SSE2.cpp
index 01c782b9ef3df48267b4a040a1a17ec51f971997..0118542d7d67d72a869a398a81e6b39784ff4234 100644
--- a/src/opts/SkXfermode_opts_SSE2.cpp
+++ b/src/opts/SkXfermode_opts_SSE2.cpp
@@ -84,6 +84,32 @@ static __m128i multiply_modeproc_SSE2(const __m128i& src, const __m128i& dst) {
return SkPackARGB32_SSE2(a, r, g, b);
}
+static inline __m128i exclusion_byte_SSE2(const __m128i& sc, const __m128i& dc,
+ const __m128i&, __m128i&) {
+ __m128i tmp1 = _mm_mullo_epi16(_mm_set1_epi32(255), sc); // 255 * sc
+ __m128i tmp2 = _mm_mullo_epi16(_mm_set1_epi32(255), dc); // 255 * dc
+ tmp1 = _mm_add_epi32(tmp1, tmp2);
+ tmp2 = _mm_mullo_epi16(sc, dc); // sc * dc
+ tmp2 = _mm_slli_epi32(tmp2, 1); // 2 * sc * dc
+
+ __m128i r = _mm_sub_epi32(tmp1, tmp2);
+ return clamp_div255round_SSE2(r);
+}
+
+static __m128i exclusion_modeproc_SSE2(const __m128i& src, const __m128i& dst) {
+ __m128i sa = SkGetPackedA32_SSE2(src);
+ __m128i da = SkGetPackedA32_SSE2(dst);
+
+ __m128i a = srcover_byte_SSE2(sa, da);
+ __m128i r = exclusion_byte_SSE2(SkGetPackedR32_SSE2(src),
+ SkGetPackedR32_SSE2(dst), sa, da);
+ __m128i g = exclusion_byte_SSE2(SkGetPackedG32_SSE2(src),
+ SkGetPackedG32_SSE2(dst), sa, da);
+ __m128i b = exclusion_byte_SSE2(SkGetPackedB32_SSE2(src),
+ SkGetPackedB32_SSE2(dst), sa, da);
+ return SkPackARGB32_SSE2(a, r, g, b);
+}
+
////////////////////////////////////////////////////////////////////////////////
typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst);
@@ -247,7 +273,7 @@ SkXfermodeProcSIMD gSSE2XfermodeProcs[] = {
NULL, // kHardLight_Mode
NULL, // kSoftLight_Mode
NULL, // kDifference_Mode
- NULL, // kExclusion_Mode
+ exclusion_modeproc_SSE2,
multiply_modeproc_SSE2,
NULL, // kHue_Mode
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698