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) { |
msarett
2016/02/02 20:22:36
This performs almost identically to an *unpack* ba
mtklein
2016/02/02 20:29:30
Even on mobile x86 (Venue8)?
mtklein
2016/02/02 20:32:06
(If so that makes me very happy. I love,love,love
msarett
2016/02/02 20:41:44
I only compared the two approaches on my desktop i
mtklein
2016/02/02 20:47:18
:( This is one of those times I hate to be right.
msarett
2016/02/02 20:53:59
Thanks for the extra reference! Got an extra 5% o
| |
456 const uint8_t* src = (const uint8_t*) vsrc; | |
457 | |
458 const __m128i alphaMask = _mm_set1_epi32(0xFF000000); | |
459 const uint8_t X = 0xFF; // Used a placeholder. The value of X is irrelevant . | |
460 const __m128i expand0 = _mm_setr_epi8(0,0,0,X, 1,1,1,X, 2,2,2,X, 3, 3,3,X); | |
461 const __m128i expand1 = _mm_setr_epi8(4,4,4,X, 5,5,5,X, 6,6,6,X, 7, 7,7,X); | |
462 const __m128i expand2 = _mm_setr_epi8(8,8,8,X, 9,9,9,X, 10,10,10,X, 11 ,11,11,X); | |
463 const __m128i expand3 = _mm_setr_epi8(12,12,12,X, 13,13,13,X, 14,14,14,X, 15 ,15,15,X); | |
464 while (count >= 16) { | |
465 __m128i grays = _mm_loadu_si128((const __m128i*) src); | |
466 | |
467 __m128i ggga0 = _mm_or_si128(_mm_shuffle_epi8(grays, expand0), alphaMask ); | |
468 __m128i ggga1 = _mm_or_si128(_mm_shuffle_epi8(grays, expand1), alphaMask ); | |
469 __m128i ggga2 = _mm_or_si128(_mm_shuffle_epi8(grays, expand2), alphaMask ); | |
470 __m128i ggga3 = _mm_or_si128(_mm_shuffle_epi8(grays, expand3), alphaMask ); | |
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 |