Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: src/core/SkXfermode.cpp

Issue 1674673002: Alter SkXfermode's asFragmentProcessor & asXPFactory contracts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test bug Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/effects/SkXfermodeImageFilter.h ('k') | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #if SK_SUPPORT_GPU
654 const GrFragmentProcessor*) const { 654 const GrFragmentProcessor* SkXfermode::getFragmentProcessorForImageFilter(
655 return false; 655 const GrFragment Processor*) const {
656 // This should never be called.
657 // TODO: make pure virtual in SkXfermode once Android update lands
658 SkASSERT(0);
659 return nullptr;
656 } 660 }
657 661
658 bool SkXfermode::asXPFactory(GrXPFactory**) const { 662 GrXPFactory* SkXfermode::asXPFactory() const {
659 return false; 663 // This should never be called.
664 // TODO: make pure virtual in SkXfermode once Android update lands
665 SkASSERT(0);
666 return nullptr;
660 } 667 }
668 #endif
661 669
662 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{ 670 SkPMColor SkXfermode::xferColor(SkPMColor src, SkPMColor dst) const{
663 // no-op. subclasses should override this 671 // no-op. subclasses should override this
664 return dst; 672 return dst;
665 } 673 }
666 674
667 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst, 675 void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst,
668 const SkPMColor* SK_RESTRICT src, int count, 676 const SkPMColor* SK_RESTRICT src, int count,
669 const SkAlpha* SK_RESTRICT aa) const { 677 const SkAlpha* SK_RESTRICT aa) const {
670 SkASSERT(dst && src && count >= 0); 678 SkASSERT(dst && src && count >= 0);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 } 903 }
896 } 904 }
897 } 905 }
898 } 906 }
899 907
900 #if SK_SUPPORT_GPU 908 #if SK_SUPPORT_GPU
901 #include "effects/GrCustomXfermode.h" 909 #include "effects/GrCustomXfermode.h"
902 #include "effects/GrPorterDuffXferProcessor.h" 910 #include "effects/GrPorterDuffXferProcessor.h"
903 #include "effects/GrXfermodeFragmentProcessor.h" 911 #include "effects/GrXfermodeFragmentProcessor.h"
904 912
905 bool SkProcCoeffXfermode::asFragmentProcessor(const GrFragmentProcessor** fp, 913 const GrFragmentProcessor* SkProcCoeffXfermode::getFragmentProcessorForImageFilt er(
906 const GrFragmentProcessor* dst) co nst { 914 const GrFragmentProc essor* dst) const {
907 if (fp) { 915 SkASSERT(dst);
908 SkASSERT(dst); 916 return GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode);
909 *fp = GrXfermodeFragmentProcessor::CreateFromDstProcessor(dst, fMode);
910 SkASSERT(*fp || kSrc_Mode == fMode);
911 }
912 return true;
913 } 917 }
914 918
915 bool SkProcCoeffXfermode::asXPFactory(GrXPFactory** xp) const { 919 GrXPFactory* SkProcCoeffXfermode::asXPFactory() const {
916 if (CANNOT_USE_COEFF != fSrcCoeff) { 920 if (CANNOT_USE_COEFF != fSrcCoeff) {
917 if (xp) { 921 GrXPFactory* result = GrPorterDuffXPFactory::Create(fMode);
918 *xp = GrPorterDuffXPFactory::Create(fMode); 922 SkASSERT(result);
919 SkASSERT(*xp); 923 return result;
920 }
921 return true;
922 } 924 }
923 925
924 if (GrCustomXfermode::IsSupportedMode(fMode)) { 926 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode));
925 if (xp) { 927 return GrCustomXfermode::CreateXPFactory(fMode);
926 *xp = GrCustomXfermode::CreateXPFactory(fMode);
927 SkASSERT(*xp);
928 }
929 return true;
930 }
931 return false;
932 } 928 }
933 #endif 929 #endif
934 930
935 const char* SkXfermode::ModeName(Mode mode) { 931 const char* SkXfermode::ModeName(Mode mode) {
936 SkASSERT((unsigned) mode <= (unsigned)kLastMode); 932 SkASSERT((unsigned) mode <= (unsigned)kLastMode);
937 const char* gModeStrings[] = { 933 const char* gModeStrings[] = {
938 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", 934 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn",
939 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", 935 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus",
940 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", 936 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge",
941 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", 937 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion",
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 if (!xfer) { 1059 if (!xfer) {
1064 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; 1060 return SkXfermode::kOpaque_SrcColorOpacity == opacityType;
1065 } 1061 }
1066 1062
1067 return xfer->isOpaque(opacityType); 1063 return xfer->isOpaque(opacityType);
1068 } 1064 }
1069 1065
1070 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1066 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1071 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1067 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1072 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1068 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « include/effects/SkXfermodeImageFilter.h ('k') | src/core/SkXfermode_proccoeff.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698