| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkXfermode.h" | 10 #include "SkXfermode.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 SkPMColor C = this->xferColor(src[i], dstC); | 744 SkPMColor C = this->xferColor(src[i], dstC); |
| 745 if (0xFF != a) { | 745 if (0xFF != a) { |
| 746 C = SkFourByteInterp(C, dstC, a); | 746 C = SkFourByteInterp(C, dstC, a); |
| 747 } | 747 } |
| 748 dst[i] = SkPixel32ToPixel16_ToU16(C); | 748 dst[i] = SkPixel32ToPixel16_ToU16(C); |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 void SkXfermode::xfer4444(SkPMColor16* SK_RESTRICT dst, | |
| 755 const SkPMColor* SK_RESTRICT src, int count, | |
| 756 const SkAlpha* SK_RESTRICT aa) const { | |
| 757 SkASSERT(dst && src && count >= 0); | |
| 758 | |
| 759 if (NULL == aa) { | |
| 760 for (int i = count - 1; i >= 0; --i) { | |
| 761 SkPMColor dstC = SkPixel4444ToPixel32(dst[i]); | |
| 762 dst[i] = SkPixel32ToPixel4444(this->xferColor(src[i], dstC)); | |
| 763 } | |
| 764 } else { | |
| 765 for (int i = count - 1; i >= 0; --i) { | |
| 766 unsigned a = aa[i]; | |
| 767 if (0 != a) { | |
| 768 SkPMColor dstC = SkPixel4444ToPixel32(dst[i]); | |
| 769 SkPMColor C = this->xferColor(src[i], dstC); | |
| 770 if (0xFF != a) { | |
| 771 C = SkFourByteInterp(C, dstC, a); | |
| 772 } | |
| 773 dst[i] = SkPixel32ToPixel4444(C); | |
| 774 } | |
| 775 } | |
| 776 } | |
| 777 } | |
| 778 | |
| 779 void SkXfermode::xferA8(SkAlpha* SK_RESTRICT dst, | 754 void SkXfermode::xferA8(SkAlpha* SK_RESTRICT dst, |
| 780 const SkPMColor src[], int count, | 755 const SkPMColor src[], int count, |
| 781 const SkAlpha* SK_RESTRICT aa) const { | 756 const SkAlpha* SK_RESTRICT aa) const { |
| 782 SkASSERT(dst && src && count >= 0); | 757 SkASSERT(dst && src && count >= 0); |
| 783 | 758 |
| 784 if (NULL == aa) { | 759 if (NULL == aa) { |
| 785 for (int i = count - 1; i >= 0; --i) { | 760 for (int i = count - 1; i >= 0; --i) { |
| 786 SkPMColor res = this->xferColor(src[i], (dst[i] << SK_A32_SHIFT)); | 761 SkPMColor res = this->xferColor(src[i], (dst[i] << SK_A32_SHIFT)); |
| 787 dst[i] = SkToU8(SkGetPackedA32(res)); | 762 dst[i] = SkToU8(SkGetPackedA32(res)); |
| 788 } | 763 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 if (0xFF != a) { | 829 if (0xFF != a) { |
| 855 C = SkFourByteInterp(C, dstC, a); | 830 C = SkFourByteInterp(C, dstC, a); |
| 856 } | 831 } |
| 857 dst[i] = SkPixel32ToPixel16_ToU16(C); | 832 dst[i] = SkPixel32ToPixel16_ToU16(C); |
| 858 } | 833 } |
| 859 } | 834 } |
| 860 } | 835 } |
| 861 } | 836 } |
| 862 } | 837 } |
| 863 | 838 |
| 864 void SkProcXfermode::xfer4444(SkPMColor16* SK_RESTRICT dst, | |
| 865 const SkPMColor* SK_RESTRICT src, int count, | |
| 866 const SkAlpha* SK_RESTRICT aa) const { | |
| 867 SkASSERT(dst && src && count >= 0); | |
| 868 | |
| 869 SkXfermodeProc proc = fProc; | |
| 870 | |
| 871 if (NULL != proc) { | |
| 872 if (NULL == aa) { | |
| 873 for (int i = count - 1; i >= 0; --i) { | |
| 874 SkPMColor dstC = SkPixel4444ToPixel32(dst[i]); | |
| 875 dst[i] = SkPixel32ToPixel4444(proc(src[i], dstC)); | |
| 876 } | |
| 877 } else { | |
| 878 for (int i = count - 1; i >= 0; --i) { | |
| 879 unsigned a = aa[i]; | |
| 880 if (0 != a) { | |
| 881 SkPMColor dstC = SkPixel4444ToPixel32(dst[i]); | |
| 882 SkPMColor C = proc(src[i], dstC); | |
| 883 if (0xFF != a) { | |
| 884 C = SkFourByteInterp(C, dstC, a); | |
| 885 } | |
| 886 dst[i] = SkPixel32ToPixel4444(C); | |
| 887 } | |
| 888 } | |
| 889 } | |
| 890 } | |
| 891 } | |
| 892 | |
| 893 void SkProcXfermode::xferA8(SkAlpha* SK_RESTRICT dst, | 839 void SkProcXfermode::xferA8(SkAlpha* SK_RESTRICT dst, |
| 894 const SkPMColor* SK_RESTRICT src, int count, | 840 const SkPMColor* SK_RESTRICT src, int count, |
| 895 const SkAlpha* SK_RESTRICT aa) const { | 841 const SkAlpha* SK_RESTRICT aa) const { |
| 896 SkASSERT(dst && src && count >= 0); | 842 SkASSERT(dst && src && count >= 0); |
| 897 | 843 |
| 898 SkXfermodeProc proc = fProc; | 844 SkXfermodeProc proc = fProc; |
| 899 | 845 |
| 900 if (NULL != proc) { | 846 if (NULL != proc) { |
| 901 if (NULL == aa) { | 847 if (NULL == aa) { |
| 902 for (int i = count - 1; i >= 0; --i) { | 848 for (int i = count - 1; i >= 0; --i) { |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 return proc16; | 1968 return proc16; |
| 2023 } | 1969 } |
| 2024 | 1970 |
| 2025 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
| 2026 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
| 2027 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
| 2028 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
| 2029 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
| 2030 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
| 2031 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1977 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |