Index: src/core/SkXfermode.cpp |
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp |
index 58c557805b0b1a3570278b90a9563d11561849e1..38a160870ef4ca6902a57a22a0b6674184fe4a42 100644 |
--- a/src/core/SkXfermode.cpp |
+++ b/src/core/SkXfermode.cpp |
@@ -1472,3 +1472,64 @@ bool SkProcCoeffXfermode::onAppendStages(SkRasterPipeline* p) const { |
} |
return false; |
} |
+ |
+/////////////////////////////////////////////////////////////////////////////////////////////////// |
+ |
+bool SkBlendMode_SupportsCoverageAsAlpha(SkBlendMode mode) { |
+ switch (mode) { |
+ case SkBlendMode::kDst: |
+ case SkBlendMode::kSrcOver: |
+ case SkBlendMode::kDstOver: |
+ case SkBlendMode::kDstOut: |
+ case SkBlendMode::kSrcATop: |
+ case SkBlendMode::kXor: |
+ case SkBlendMode::kPlus: |
+ return true; |
+ default: |
+ break; |
+ } |
+ return false; |
+} |
+ |
+bool SkXfermode::IsOpaque(SkBlendMode mode, SrcColorOpacity opacityType) { |
+ const ProcCoeff rec = gProcCoeffs[(int)mode]; |
+ |
+ switch (rec.fSC) { |
+ case kDA_Coeff: |
+ case kDC_Coeff: |
+ case kIDA_Coeff: |
+ case kIDC_Coeff: |
+ return false; |
+ default: |
+ break; |
+ } |
+ |
+ switch (rec.fDC) { |
+ case kZero_Coeff: |
+ return true; |
+ case kISA_Coeff: |
+ return kOpaque_SrcColorOpacity == opacityType; |
+ case kSA_Coeff: |
+ return kTransparentBlack_SrcColorOpacity == opacityType || |
+ kTransparentAlpha_SrcColorOpacity == opacityType; |
+ case kSC_Coeff: |
+ return kTransparentBlack_SrcColorOpacity == opacityType; |
+ default: |
+ return false; |
+ } |
+ return false; |
+} |
+ |
+#if SK_SUPPORT_GPU |
+sk_sp<GrXPFactory> SkBlendMode_AsXPFactory(SkBlendMode mode) { |
+ const ProcCoeff rec = gProcCoeffs[(int)mode]; |
+ if (CANNOT_USE_COEFF != rec.fSC) { |
+ sk_sp<GrXPFactory> result(GrPorterDuffXPFactory::Make(mode)); |
+ SkASSERT(result); |
+ return result; |
+ } |
+ |
+ SkASSERT(GrCustomXfermode::IsSupportedMode((SkXfermode::Mode)mode)); |
+ return GrCustomXfermode::MakeXPFactory((SkXfermode::Mode)mode); |
+} |
+#endif |