| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkOpts.h" | 10 #include "SkOpts.h" |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 for (int x = 0; x < dstWidth; x++) { | 585 for (int x = 0; x < dstWidth; x++) { |
| 586 const uint8_t r = SkMulDiv255Round(src[0], src[3]); | 586 const uint8_t r = SkMulDiv255Round(src[0], src[3]); |
| 587 const uint8_t g = SkMulDiv255Round(src[1], src[3]); | 587 const uint8_t g = SkMulDiv255Round(src[1], src[3]); |
| 588 const uint8_t b = SkMulDiv255Round(src[2], src[3]); | 588 const uint8_t b = SkMulDiv255Round(src[2], src[3]); |
| 589 | 589 |
| 590 dst[x] = SkPackARGB32NoCheck(0xFF, r, g, b); | 590 dst[x] = SkPackARGB32NoCheck(0xFF, r, g, b); |
| 591 src += deltaSrc; | 591 src += deltaSrc; |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 | 594 |
| 595 static void fast_swizzle_cmyk_to_n32( |
| 596 void* dst, const uint8_t* src, int width, int bpp, int deltaSrc, int off
set, |
| 597 const SkPMColor ctable[]) { |
| 598 |
| 599 // This function must not be called if we are sampling. If we are not |
| 600 // sampling, deltaSrc should equal bpp. |
| 601 SkASSERT(deltaSrc == bpp); |
| 602 |
| 603 #ifdef SK_PMCOLOR_IS_RGBA |
| 604 SkOpts::CMYK_to_RGB1((uint32_t*) dst, src + offset, width); |
| 605 #else |
| 606 SkOpts::CMYK_to_BGR1((uint32_t*) dst, src + offset, width); |
| 607 #endif |
| 608 } |
| 609 |
| 595 static void swizzle_cmyk_to_565( | 610 static void swizzle_cmyk_to_565( |
| 596 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, | 611 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, |
| 597 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { | 612 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { |
| 598 | 613 |
| 599 src += offset; | 614 src += offset; |
| 600 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow; | 615 uint16_t* SK_RESTRICT dst = (uint16_t*)dstRow; |
| 601 for (int x = 0; x < dstWidth; x++) { | 616 for (int x = 0; x < dstWidth; x++) { |
| 602 const uint8_t r = SkMulDiv255Round(src[0], src[3]); | 617 const uint8_t r = SkMulDiv255Round(src[0], src[3]); |
| 603 const uint8_t g = SkMulDiv255Round(src[1], src[3]); | 618 const uint8_t g = SkMulDiv255Round(src[1], src[3]); |
| 604 const uint8_t b = SkMulDiv255Round(src[2], src[3]); | 619 const uint8_t b = SkMulDiv255Round(src[2], src[3]); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 819 } |
| 805 break; | 820 break; |
| 806 case kRGB: | 821 case kRGB: |
| 807 switch (dstInfo.colorType()) { | 822 switch (dstInfo.colorType()) { |
| 808 case kN32_SkColorType: | 823 case kN32_SkColorType: |
| 809 proc = &swizzle_rgb_to_n32; | 824 proc = &swizzle_rgb_to_n32; |
| 810 fastProc = &fast_swizzle_rgb_to_n32; | 825 fastProc = &fast_swizzle_rgb_to_n32; |
| 811 break; | 826 break; |
| 812 case kRGB_565_SkColorType: | 827 case kRGB_565_SkColorType: |
| 813 proc = &swizzle_rgb_to_565; | 828 proc = &swizzle_rgb_to_565; |
| 829 break; |
| 814 default: | 830 default: |
| 815 break; | 831 break; |
| 816 } | 832 } |
| 817 break; | 833 break; |
| 818 case kRGBA: | 834 case kRGBA: |
| 819 switch (dstInfo.colorType()) { | 835 switch (dstInfo.colorType()) { |
| 820 case kN32_SkColorType: | 836 case kN32_SkColorType: |
| 821 if (dstInfo.alphaType() == kUnpremul_SkAlphaType) { | 837 if (dstInfo.alphaType() == kUnpremul_SkAlphaType) { |
| 822 if (SkCodec::kYes_ZeroInitialized == zeroInit) { | 838 if (SkCodec::kYes_ZeroInitialized == zeroInit) { |
| 823 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_n32
_unpremul>; | 839 proc = &SkipLeading8888ZerosThen<swizzle_rgba_to_n32
_unpremul>; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 837 } | 853 } |
| 838 break; | 854 break; |
| 839 default: | 855 default: |
| 840 break; | 856 break; |
| 841 } | 857 } |
| 842 break; | 858 break; |
| 843 case kCMYK: | 859 case kCMYK: |
| 844 switch (dstInfo.colorType()) { | 860 switch (dstInfo.colorType()) { |
| 845 case kN32_SkColorType: | 861 case kN32_SkColorType: |
| 846 proc = &swizzle_cmyk_to_n32; | 862 proc = &swizzle_cmyk_to_n32; |
| 863 fastProc = &fast_swizzle_cmyk_to_n32; |
| 847 break; | 864 break; |
| 848 case kRGB_565_SkColorType: | 865 case kRGB_565_SkColorType: |
| 849 proc = &swizzle_cmyk_to_565; | 866 proc = &swizzle_cmyk_to_565; |
| 850 break; | 867 break; |
| 851 default: | 868 default: |
| 852 break; | 869 break; |
| 853 } | 870 } |
| 854 break; | 871 break; |
| 855 case kNoOp8: | 872 case kNoOp8: |
| 856 proc = &sample1; | 873 proc = &sample1; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } | 945 } |
| 929 | 946 |
| 930 return fAllocatedWidth; | 947 return fAllocatedWidth; |
| 931 } | 948 } |
| 932 | 949 |
| 933 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { | 950 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { |
| 934 SkASSERT(nullptr != dst && nullptr != src); | 951 SkASSERT(nullptr != dst && nullptr != src); |
| 935 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS
rcBPP, | 952 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS
rcBPP, |
| 936 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); | 953 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); |
| 937 } | 954 } |
| OLD | NEW |