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::asFragmentProcessor(const GrFragmentProce ssor*) const { |
654 const GrFragmentProcessor*) const { | 654 // This should never be called. |
655 return false; | 655 // TODO: make pure virtual in SkXfermode once Android update lands |
656 SkASSERT(0); | |
657 return nullptr; | |
656 } | 658 } |
657 | 659 |
658 bool SkXfermode::asXPFactory(GrXPFactory**) const { | 660 GrXPFactory* SkXfermode::asXPFactory() const { |
659 return false; | 661 // This should never be called. |
662 // TODO: make pure virtual in SkXfermode once Android update lands | |
663 SkASSERT(0); | |
664 return nullptr; | |
660 } | 665 } |
661 | 666 |
662 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ | 667 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ |
663 // no-op. subclasses should override this | 668 // no-op. subclasses should override this |
664 return dst; | 669 return dst; |
665 } | 670 } |
666 | 671 |
667 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 672 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
668 const SkPMColor* SK_RESTRICT src, int count, | 673 const SkPMColor* SK_RESTRICT src, int count, |
669 const SkAlpha* SK_RESTRICT aa) const { | 674 const SkAlpha* SK_RESTRICT aa) const { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
895 } | 900 } |
896 } | 901 } |
897 } | 902 } |
898 } | 903 } |
899 | 904 |
900 #if SK_SUPPORT_GPU | 905 #if SK_SUPPORT_GPU |
901 #include "effects/GrCustomXfermode.h" | 906 #include "effects/GrCustomXfermode.h" |
902 #include "effects/GrPorterDuffXferProcessor.h" | 907 #include "effects/GrPorterDuffXferProcessor.h" |
903 #include "effects/GrXfermodeFragmentProcessor.h" | 908 #include "effects/GrXfermodeFragmentProcessor.h" |
904 | 909 |
905 bool SkProcCoeffXfermode::asFragmentProcessor(const GrFragmentProcessor** fp, | 910 const GrFragmentProcessor* SkProcCoeffXfermode::asFragmentProcessor( |
906 const GrFragmentProcessor* dst) co nst { | 911 const GrFragmentProc essor* dst) const { |
907 if (fp) { | 912 SkASSERT(dst); |
908 SkASSERT(dst); | 913 return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode); |
909 *fp = GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode); | |
910 SkASSERT(*fp || kSrc_Mode == fMode); | |
911 } | |
912 return true; | |
913 } | 914 } |
914 | 915 |
915 bool SkProcCoeffXfermode::asXPFactory(GrXPFactory** xp) const { | 916 GrXPFactory* SkProcCoeffXfermode::asXPFactory() const { |
916 if (CANNOT_USE_COEFF != fSrcCoeff) { | 917 if (CANNOT_USE_COEFF != fSrcCoeff) { |
917 if (xp) { | 918 SkASSERT(fMode <= kLastCoeffMode); |
egdaniel
2016/02/08 15:32:11
I feel like this assert assumes knowledge of exact
robertphillips
2016/02/08 15:54:53
Done.
| |
918 *xp = GrPorterDuffXPFactory::Create(fMode); | 919 return GrPorterDuffXPFactory::Create(fMode); |
919 SkASSERT(*xp); | |
920 } | |
921 return true; | |
922 } | 920 } |
923 | 921 |
924 if (GrCustomXfermode::IsSupportedMode(fMode)) { | 922 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
925 if (xp) { | 923 return GrCustomXfermode::CreateXPFactory(fMode); |
926 *xp = GrCustomXfermode::CreateXPFactory(fMode); | |
927 SkASSERT(*xp); | |
928 } | |
929 return true; | |
930 } | |
931 return false; | |
932 } | 924 } |
933 #endif | 925 #endif |
934 | 926 |
935 const char* SkXfermode::ModeName(Mode mode) { | 927 const char* SkXfermode::ModeName(Mode mode) { |
936 SkASSERT((unsigned) mode <= (unsigned)kLastMode); | 928 SkASSERT((unsigned) mode <= (unsigned)kLastMode); |
937 const char* gModeStrings[] = { | 929 const char* gModeStrings[] = { |
938 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", | 930 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", |
939 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", | 931 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", |
940 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", | 932 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", |
941 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", | 933 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1063 if (!xfer) { | 1055 if (!xfer) { |
1064 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; | 1056 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; |
1065 } | 1057 } |
1066 | 1058 |
1067 return xfer->isOpaque(opacityType); | 1059 return xfer->isOpaque(opacityType); |
1068 } | 1060 } |
1069 | 1061 |
1070 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1062 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1071 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1063 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1072 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1064 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |