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

Unified Diff: src/core/SkXfermode.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkSpriteBlitter_RGB16.cpp ('k') | src/core/SkXfermodeInterpretation.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/core/SkSpriteBlitter_RGB16.cpp ('k') | src/core/SkXfermodeInterpretation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698