OLD | NEW |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 SkGetPackedA32_SSE2(dst)); | 222 SkGetPackedA32_SSE2(dst)); |
223 __m128i r = srcover_byte_SSE2(SkGetPackedR32_SSE2(src), | 223 __m128i r = srcover_byte_SSE2(SkGetPackedR32_SSE2(src), |
224 SkGetPackedR32_SSE2(dst)); | 224 SkGetPackedR32_SSE2(dst)); |
225 __m128i g = srcover_byte_SSE2(SkGetPackedG32_SSE2(src), | 225 __m128i g = srcover_byte_SSE2(SkGetPackedG32_SSE2(src), |
226 SkGetPackedG32_SSE2(dst)); | 226 SkGetPackedG32_SSE2(dst)); |
227 __m128i b = srcover_byte_SSE2(SkGetPackedB32_SSE2(src), | 227 __m128i b = srcover_byte_SSE2(SkGetPackedB32_SSE2(src), |
228 SkGetPackedB32_SSE2(dst)); | 228 SkGetPackedB32_SSE2(dst)); |
229 return SkPackARGB32_SSE2(a, r, g, b); | 229 return SkPackARGB32_SSE2(a, r, g, b); |
230 } | 230 } |
231 | 231 |
| 232 // Portable version overlay_byte() is in SkXfermode.cpp. |
| 233 static inline __m128i overlay_byte_SSE2(const __m128i& sc, const __m128i& dc, |
| 234 const __m128i& sa, const __m128i& da) { |
| 235 __m128i ida = _mm_sub_epi32(_mm_set1_epi32(255), da); |
| 236 __m128i tmp1 = _mm_mullo_epi16(sc, ida); |
| 237 __m128i isa = _mm_sub_epi32(_mm_set1_epi32(255), sa); |
| 238 __m128i tmp2 = _mm_mullo_epi16(dc, isa); |
| 239 __m128i tmp = _mm_add_epi32(tmp1, tmp2); |
| 240 |
| 241 __m128i cmp = _mm_cmpgt_epi32(_mm_slli_epi32(dc, 1), da); |
| 242 __m128i rc1 = _mm_slli_epi32(sc, 1); // 2 * sc |
| 243 rc1 = Multiply32_SSE2(rc1, dc); // *dc |
| 244 |
| 245 __m128i rc2 = _mm_mullo_epi16(sa, da); // sa * da |
| 246 __m128i tmp3 = _mm_slli_epi32(_mm_sub_epi32(da, dc), 1); // 2 * (da - dc) |
| 247 tmp3 = Multiply32_SSE2(tmp3, _mm_sub_epi32(sa, sc)); // * (sa - sc) |
| 248 rc2 = _mm_sub_epi32(rc2, tmp3); |
| 249 |
| 250 __m128i rc = _mm_or_si128(_mm_andnot_si128(cmp, rc1), |
| 251 _mm_and_si128(cmp, rc2)); |
| 252 return clamp_div255round_SSE2(_mm_add_epi32(rc, tmp)); |
| 253 } |
| 254 |
| 255 static __m128i overlay_modeproc_SSE2(const __m128i& src, const __m128i& dst) { |
| 256 __m128i sa = SkGetPackedA32_SSE2(src); |
| 257 __m128i da = SkGetPackedA32_SSE2(dst); |
| 258 |
| 259 __m128i a = srcover_byte_SSE2(sa, da); |
| 260 __m128i r = overlay_byte_SSE2(SkGetPackedR32_SSE2(src), |
| 261 SkGetPackedR32_SSE2(dst), sa, da); |
| 262 __m128i g = overlay_byte_SSE2(SkGetPackedG32_SSE2(src), |
| 263 SkGetPackedG32_SSE2(dst), sa, da); |
| 264 __m128i b = overlay_byte_SSE2(SkGetPackedB32_SSE2(src), |
| 265 SkGetPackedB32_SSE2(dst), sa, da); |
| 266 return SkPackARGB32_SSE2(a, r, g, b); |
| 267 } |
| 268 |
232 //////////////////////////////////////////////////////////////////////////////// | 269 //////////////////////////////////////////////////////////////////////////////// |
233 | 270 |
234 typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst); | 271 typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst); |
235 | 272 |
236 extern SkXfermodeProcSIMD gSSE2XfermodeProcs[]; | 273 extern SkXfermodeProcSIMD gSSE2XfermodeProcs[]; |
237 | 274 |
238 SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer) | 275 SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer) |
239 : INHERITED(buffer) { | 276 : INHERITED(buffer) { |
240 fProcSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[this->getMode()]); | 277 fProcSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[this->getMode()]); |
241 } | 278 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 dstin_modeproc_SSE2, | 414 dstin_modeproc_SSE2, |
378 srcout_modeproc_SSE2, | 415 srcout_modeproc_SSE2, |
379 dstout_modeproc_SSE2, | 416 dstout_modeproc_SSE2, |
380 srcatop_modeproc_SSE2, | 417 srcatop_modeproc_SSE2, |
381 dstatop_modeproc_SSE2, | 418 dstatop_modeproc_SSE2, |
382 xor_modeproc_SSE2, | 419 xor_modeproc_SSE2, |
383 plus_modeproc_SSE2, | 420 plus_modeproc_SSE2, |
384 modulate_modeproc_SSE2, | 421 modulate_modeproc_SSE2, |
385 screen_modeproc_SSE2, | 422 screen_modeproc_SSE2, |
386 | 423 |
387 NULL, // kOverlay_Mode | 424 overlay_modeproc_SSE2, |
388 NULL, // kDarken_Mode | 425 NULL, // kDarken_Mode |
389 NULL, // kLighten_Mode | 426 NULL, // kLighten_Mode |
390 NULL, // kColorDodge_Mode | 427 NULL, // kColorDodge_Mode |
391 NULL, // kColorBurn_Mode | 428 NULL, // kColorBurn_Mode |
392 NULL, // kHardLight_Mode | 429 NULL, // kHardLight_Mode |
393 NULL, // kSoftLight_Mode | 430 NULL, // kSoftLight_Mode |
394 NULL, // kDifference_Mode | 431 NULL, // kDifference_Mode |
395 NULL, // kExclusion_Mode | 432 NULL, // kExclusion_Mode |
396 multiply_modeproc_SSE2, | 433 multiply_modeproc_SSE2, |
397 | 434 |
398 NULL, // kHue_Mode | 435 NULL, // kHue_Mode |
399 NULL, // kSaturation_Mode | 436 NULL, // kSaturation_Mode |
400 NULL, // kColor_Mode | 437 NULL, // kColor_Mode |
401 NULL, // kLuminosity_Mode | 438 NULL, // kLuminosity_Mode |
402 }; | 439 }; |
403 | 440 |
404 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec, | 441 SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec, |
405 SkXfermode::Mode mode)
{ | 442 SkXfermode::Mode mode)
{ |
406 void* procSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[mode]); | 443 void* procSIMD = reinterpret_cast<void*>(gSSE2XfermodeProcs[mode]); |
407 | 444 |
408 if (procSIMD != NULL) { | 445 if (procSIMD != NULL) { |
409 return SkNEW_ARGS(SkSSE2ProcCoeffXfermode, (rec, mode, procSIMD)); | 446 return SkNEW_ARGS(SkSSE2ProcCoeffXfermode, (rec, mode, procSIMD)); |
410 } | 447 } |
411 return NULL; | 448 return NULL; |
412 } | 449 } |
OLD | NEW |