| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkSwizzler_opts_DEFINED | 8 #ifndef SkSwizzler_opts_DEFINED |
| 9 #define SkSwizzler_opts_DEFINED | 9 #define SkSwizzler_opts_DEFINED |
| 10 | 10 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 445 } |
| 446 | 446 |
| 447 static void RGB_to_RGB1(uint32_t dst[], const void* src, int count) { | 447 static void RGB_to_RGB1(uint32_t dst[], const void* src, int count) { |
| 448 insert_alpha_should_swaprb<false>(dst, src, count); | 448 insert_alpha_should_swaprb<false>(dst, src, count); |
| 449 } | 449 } |
| 450 | 450 |
| 451 static void RGB_to_BGR1(uint32_t dst[], const void* src, int count) { | 451 static void RGB_to_BGR1(uint32_t dst[], const void* src, int count) { |
| 452 insert_alpha_should_swaprb<true>(dst, src, count); | 452 insert_alpha_should_swaprb<true>(dst, src, count); |
| 453 } | 453 } |
| 454 | 454 |
| 455 static void gray_to_RGB1(uint32_t dst[], const void* src, int count) { | 455 static void gray_to_RGB1(uint32_t dst[], const void* vsrc, int count) { |
| 456 const uint8_t* src = (const uint8_t*) vsrc; |
| 457 |
| 458 const __m128i alphas = _mm_set1_epi8((uint8_t) 0xFF); |
| 459 while (count >= 16) { |
| 460 __m128i grays = _mm_loadu_si128((const __m128i*) src); |
| 461 |
| 462 __m128i gg_lo = _mm_unpacklo_epi8(grays, grays); |
| 463 __m128i gg_hi = _mm_unpackhi_epi8(grays, grays); |
| 464 __m128i ga_lo = _mm_unpacklo_epi8(grays, alphas); |
| 465 __m128i ga_hi = _mm_unpackhi_epi8(grays, alphas); |
| 466 |
| 467 __m128i ggga0 = _mm_unpacklo_epi16(gg_lo, ga_lo); |
| 468 __m128i ggga1 = _mm_unpackhi_epi16(gg_lo, ga_lo); |
| 469 __m128i ggga2 = _mm_unpacklo_epi16(gg_hi, ga_hi); |
| 470 __m128i ggga3 = _mm_unpackhi_epi16(gg_hi, ga_hi); |
| 471 |
| 472 _mm_storeu_si128((__m128i*) (dst + 0), ggga0); |
| 473 _mm_storeu_si128((__m128i*) (dst + 4), ggga1); |
| 474 _mm_storeu_si128((__m128i*) (dst + 8), ggga2); |
| 475 _mm_storeu_si128((__m128i*) (dst + 12), ggga3); |
| 476 |
| 477 src += 16; |
| 478 dst += 16; |
| 479 count -= 16; |
| 480 } |
| 481 |
| 456 gray_to_RGB1_portable(dst, src, count); | 482 gray_to_RGB1_portable(dst, src, count); |
| 457 } | 483 } |
| 458 | 484 |
| 459 #else | 485 #else |
| 460 | 486 |
| 461 static void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) { | 487 static void RGBA_to_rgbA(uint32_t* dst, const void* src, int count) { |
| 462 RGBA_to_rgbA_portable(dst, src, count); | 488 RGBA_to_rgbA_portable(dst, src, count); |
| 463 } | 489 } |
| 464 | 490 |
| 465 static void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) { | 491 static void RGBA_to_bgrA(uint32_t* dst, const void* src, int count) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 480 | 506 |
| 481 static void gray_to_RGB1(uint32_t dst[], const void* src, int count) { | 507 static void gray_to_RGB1(uint32_t dst[], const void* src, int count) { |
| 482 gray_to_RGB1_portable(dst, src, count); | 508 gray_to_RGB1_portable(dst, src, count); |
| 483 } | 509 } |
| 484 | 510 |
| 485 #endif | 511 #endif |
| 486 | 512 |
| 487 } | 513 } |
| 488 | 514 |
| 489 #endif // SkSwizzler_opts_DEFINED | 515 #endif // SkSwizzler_opts_DEFINED |
| OLD | NEW |