| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkXfermode.h" | 8 #include "SkXfermode.h" |
| 9 #include "SkXfermode_proccoeff.h" | 9 #include "SkXfermode_proccoeff.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 { color_modeproc, CANNOT_USE_COEFF, CANNOT_USE_COEFF }, | 643 { color_modeproc, CANNOT_USE_COEFF, CANNOT_USE_COEFF }, |
| 644 { luminosity_modeproc, CANNOT_USE_COEFF, CANNOT_USE_COEFF }, | 644 { luminosity_modeproc, CANNOT_USE_COEFF, CANNOT_USE_COEFF }, |
| 645 }; | 645 }; |
| 646 | 646 |
| 647 /////////////////////////////////////////////////////////////////////////////// | 647 /////////////////////////////////////////////////////////////////////////////// |
| 648 | 648 |
| 649 bool SkXfermode::asMode(Mode* mode) const { | 649 bool SkXfermode::asMode(Mode* mode) const { |
| 650 return false; | 650 return false; |
| 651 } | 651 } |
| 652 | 652 |
| 653 bool SkXfermode::asFragmentProcessor(const GrFragmentProcessor**, | 653 const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter( |
| 654 const GrFragmentProcessor*) const { | 654 const GrFragment
Processor*) const { |
| 655 return false; | 655 // This should never be called. |
| 656 // TODO: make pure virtual in SkXfermode once Android update lands |
| 657 SkASSERT(0); |
| 658 return nullptr; |
| 656 } | 659 } |
| 657 | 660 |
| 658 bool SkXfermode::asXPFactory(GrXPFactory**) const { | 661 GrXPFactory* SkXfermode::asXPFactory() const { |
| 659 return false; | 662 // This should never be called. |
| 663 // TODO: make pure virtual in SkXfermode once Android update lands |
| 664 SkASSERT(0); |
| 665 return nullptr; |
| 660 } | 666 } |
| 661 | 667 |
| 662 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ | 668 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ |
| 663 // no-op. subclasses should override this | 669 // no-op. subclasses should override this |
| 664 return dst; | 670 return dst; |
| 665 } | 671 } |
| 666 | 672 |
| 667 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 673 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
| 668 const SkPMColor* SK_RESTRICT src, int count, | 674 const SkPMColor* SK_RESTRICT src, int count, |
| 669 const SkAlpha* SK_RESTRICT aa) const { | 675 const SkAlpha* SK_RESTRICT aa) const { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 } | 901 } |
| 896 } | 902 } |
| 897 } | 903 } |
| 898 } | 904 } |
| 899 | 905 |
| 900 #if SK_SUPPORT_GPU | 906 #if SK_SUPPORT_GPU |
| 901 #include "effects/GrCustomXfermode.h" | 907 #include "effects/GrCustomXfermode.h" |
| 902 #include "effects/GrPorterDuffXferProcessor.h" | 908 #include "effects/GrPorterDuffXferProcessor.h" |
| 903 #include "effects/GrXfermodeFragmentProcessor.h" | 909 #include "effects/GrXfermodeFragmentProcessor.h" |
| 904 | 910 |
| 905 bool SkProcCoeffXfermode::asFragmentProcessor(const GrFragmentProcessor** fp, | 911 const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilt
er( |
| 906 const GrFragmentProcessor* dst) co
nst { | 912 const GrFragmentProc
essor* dst) const { |
| 907 if (fp) { | 913 SkASSERT(dst); |
| 908 SkASSERT(dst); | 914 return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode); |
| 909 *fp = GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode); | |
| 910 SkASSERT(*fp || kSrc_Mode == fMode); | |
| 911 } | |
| 912 return true; | |
| 913 } | 915 } |
| 914 | 916 |
| 915 bool SkProcCoeffXfermode::asXPFactory(GrXPFactory** xp) const { | 917 GrXPFactory* SkProcCoeffXfermode::asXPFactory() const { |
| 916 if (CANNOT_USE_COEFF != fSrcCoeff) { | 918 if (CANNOT_USE_COEFF != fSrcCoeff) { |
| 917 if (xp) { | 919 GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode); |
| 918 *xp = GrPorterDuffXPFactory::Create(fMode); | 920 SkASSERT(result); |
| 919 SkASSERT(*xp); | 921 return result; |
| 920 } | |
| 921 return true; | |
| 922 } | 922 } |
| 923 | 923 |
| 924 if (GrCustomXfermode::IsSupportedMode(fMode)) { | 924 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
| 925 if (xp) { | 925 return GrCustomXfermode::CreateXPFactory(fMode); |
| 926 *xp = GrCustomXfermode::CreateXPFactory(fMode); | |
| 927 SkASSERT(*xp); | |
| 928 } | |
| 929 return true; | |
| 930 } | |
| 931 return false; | |
| 932 } | 926 } |
| 933 #endif | 927 #endif |
| 934 | 928 |
| 935 const char* SkXfermode::ModeName(Mode mode) { | 929 const char* SkXfermode::ModeName(Mode mode) { |
| 936 SkASSERT((unsigned) mode <= (unsigned)kLastMode); | 930 SkASSERT((unsigned) mode <= (unsigned)kLastMode); |
| 937 const char* gModeStrings[] = { | 931 const char* gModeStrings[] = { |
| 938 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", | 932 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", |
| 939 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", | 933 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", |
| 940 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", | 934 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", |
| 941 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", | 935 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 if (!xfer) { | 1057 if (!xfer) { |
| 1064 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; | 1058 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; |
| 1065 } | 1059 } |
| 1066 | 1060 |
| 1067 return xfer->isOpaque(opacityType); | 1061 return xfer->isOpaque(opacityType); |
| 1068 } | 1062 } |
| 1069 | 1063 |
| 1070 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1064 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
| 1071 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1065 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
| 1072 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1066 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| OLD | NEW |