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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "SkColorPriv.h" 1 #include "SkColorPriv.h"
2 #include "SkColor_opts_SSE2.h" 2 #include "SkColor_opts_SSE2.h"
3 #include "SkMathPriv.h" 3 #include "SkMathPriv.h"
4 #include "SkXfermode.h" 4 #include "SkXfermode.h"
5 #include "SkXfermode_opts_SSE2.h" 5 #include "SkXfermode_opts_SSE2.h"
6 #include "SkXfermode_proccoeff.h" 6 #include "SkXfermode_proccoeff.h"
7 7
8 //////////////////////////////////////////////////////////////////////////////// 8 ////////////////////////////////////////////////////////////////////////////////
9 // 4 pixels SSE2 version functions 9 // 4 pixels SSE2 version functions
10 //////////////////////////////////////////////////////////////////////////////// 10 ////////////////////////////////////////////////////////////////////////////////
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 __m128i g = blendfunc_multiply_byte_SSE2(sg, dg, sa, da); 77 __m128i g = blendfunc_multiply_byte_SSE2(sg, dg, sa, da);
78 78
79 79
80 __m128i sb = SkGetPackedB32_SSE2(src); 80 __m128i sb = SkGetPackedB32_SSE2(src);
81 __m128i db = SkGetPackedB32_SSE2(dst); 81 __m128i db = SkGetPackedB32_SSE2(dst);
82 __m128i b = blendfunc_multiply_byte_SSE2(sb, db, sa, da); 82 __m128i b = blendfunc_multiply_byte_SSE2(sb, db, sa, da);
83 83
84 return SkPackARGB32_SSE2(a, r, g, b); 84 return SkPackARGB32_SSE2(a, r, g, b);
85 } 85 }
86 86
87 static inline __m128i exclusion_byte_SSE2(const __m128i& sc, const __m128i& dc,
88 const __m128i&, __m128i&) {
89 __m128i tmp1 = _mm_mullo_epi16(_mm_set1_epi32(255), sc); // 255 * sc
90 __m128i tmp2 = _mm_mullo_epi16(_mm_set1_epi32(255), dc); // 255 * dc
91 tmp1 = _mm_add_epi32(tmp1, tmp2);
92 tmp2 = _mm_mullo_epi16(sc, dc); // sc * dc
93 tmp2 = _mm_slli_epi32(tmp2, 1); // 2 * sc * dc
94
95 __m128i r = _mm_sub_epi32(tmp1, tmp2);
96 return clamp_div255round_SSE2(r);
97 }
98
99 static __m128i exclusion_modeproc_SSE2(const __m128i& src, const __m128i& dst) {
100 __m128i sa = SkGetPackedA32_SSE2(src);
101 __m128i da = SkGetPackedA32_SSE2(dst);
102
103 __m128i a = srcover_byte_SSE2(sa, da);
104 __m128i r = exclusion_byte_SSE2(SkGetPackedR32_SSE2(src),
105 SkGetPackedR32_SSE2(dst), sa, da);
106 __m128i g = exclusion_byte_SSE2(SkGetPackedG32_SSE2(src),
107 SkGetPackedG32_SSE2(dst), sa, da);
108 __m128i b = exclusion_byte_SSE2(SkGetPackedB32_SSE2(src),
109 SkGetPackedB32_SSE2(dst), sa, da);
110 return SkPackARGB32_SSE2(a, r, g, b);
111 }
112
87 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
88 114
89 typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst); 115 typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst);
90 116
91 extern SkXfermodeProcSIMD gSSE2XfermodeProcs[]; 117 extern SkXfermodeProcSIMD gSSE2XfermodeProcs[];
92 118
93 SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer) 119 SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer)
94 : INHERITED(buffer) { 120 : INHERITED(buffer) {
95 fProcSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[this->getMode()]); 121 fProcSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[this->getMode()]);
96 } 122 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 NULL, // kScreen_Mode 266 NULL, // kScreen_Mode
241 267
242 NULL, // kOverlay_Mode 268 NULL, // kOverlay_Mode
243 NULL, // kDarken_Mode 269 NULL, // kDarken_Mode
244 NULL, // kLighten_Mode 270 NULL, // kLighten_Mode
245 NULL, // kColorDodge_Mode 271 NULL, // kColorDodge_Mode
246 NULL, // kColorBurn_Mode 272 NULL, // kColorBurn_Mode
247 NULL, // kHardLight_Mode 273 NULL, // kHardLight_Mode
248 NULL, // kSoftLight_Mode 274 NULL, // kSoftLight_Mode
249 NULL, // kDifference_Mode 275 NULL, // kDifference_Mode
250 NULL, // kExclusion_Mode 276 exclusion_modeproc_SSE2,
251 multiply_modeproc_SSE2, 277 multiply_modeproc_SSE2,
252 278
253 NULL, // kHue_Mode 279 NULL, // kHue_Mode
254 NULL, // kSaturation_Mode 280 NULL, // kSaturation_Mode
255 NULL, // kColor_Mode 281 NULL, // kColor_Mode
256 NULL, // kLuminosity_Mode 282 NULL, // kLuminosity_Mode
257 }; 283 };
258 284
259 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec, 285 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec,
260 SkXfermode::Mode mode) { 286 SkXfermode::Mode mode) {
261 void* procSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[mode]); 287 void* procSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[mode]);
262 288
263 if (procSIMD != NULL) { 289 if (procSIMD != NULL) {
264 return SkNEW_ARGS(SkSSE2ProcCoeffXfermode, (rec, mode, procSIMD)); 290 return SkNEW_ARGS(SkSSE2ProcCoeffXfermode, (rec, mode, procSIMD));
265 } 291 }
266 return NULL; 292 return NULL;
267 } 293 }
OLDNEW
« 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