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

Unified Diff: src/gpu/glsl/GrGLSLBlend.cpp

Issue 1488213002: Add in shader blending for CoverageSetOp XP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebased Created 5 years 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/gpu/glsl/GrGLSLBlend.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLBlend.cpp
diff --git a/src/gpu/glsl/GrGLSLBlend.cpp b/src/gpu/glsl/GrGLSLBlend.cpp
index 3c83068fc19aa8785f01c5118ae79e59070d7eed..6937977a948a47d00b2de630f6501064a656f544 100644
--- a/src/gpu/glsl/GrGLSLBlend.cpp
+++ b/src/gpu/glsl/GrGLSLBlend.cpp
@@ -433,3 +433,50 @@ void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcCo
emit_advanced_xfermode_code(fsBuilder, srcColor, dstColor, outColor, mode);
}
}
+
+void GrGLSLBlend::AppendRegionOp(GrGLSLFragmentBuilder* fsBuilder, const char* srcColor,
+ const char* dstColor, const char* outColor,
+ SkRegion::Op regionOp) {
+ SkXfermode::Coeff srcCoeff, dstCoeff;
+ switch (regionOp) {
+ case SkRegion::kReplace_Op:
+ srcCoeff = SkXfermode::kOne_Coeff;
+ dstCoeff = SkXfermode::kZero_Coeff;
+ break;
+ case SkRegion::kIntersect_Op:
+ srcCoeff = SkXfermode::kDC_Coeff;
+ dstCoeff = SkXfermode::kZero_Coeff;
+ break;
+ case SkRegion::kUnion_Op:
+ srcCoeff = SkXfermode::kOne_Coeff;
+ dstCoeff = SkXfermode::kISC_Coeff;
+ break;
+ case SkRegion::kXOR_Op:
+ srcCoeff = SkXfermode::kIDC_Coeff;
+ dstCoeff = SkXfermode::kISC_Coeff;
+ break;
+ case SkRegion::kDifference_Op:
+ srcCoeff = SkXfermode::kZero_Coeff;
+ dstCoeff = SkXfermode::kISC_Coeff;
+ break;
+ case SkRegion::kReverseDifference_Op:
+ srcCoeff = SkXfermode::kIDC_Coeff;
+ dstCoeff = SkXfermode::kZero_Coeff;
+ break;
+ default:
+ SkFAIL("Unsupported Op");
+ // We should never get here but to make compiler happy
+ srcCoeff = SkXfermode::kZero_Coeff;
+ dstCoeff = SkXfermode::kZero_Coeff;
+ }
+ fsBuilder->codeAppendf("%s = ", outColor);
+ // append src blend
+ bool didAppend = append_porterduff_term(fsBuilder, srcCoeff, srcColor, srcColor, dstColor,
+ false);
+ // append dst blend
+ if(!append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor, didAppend)) {
+ fsBuilder->codeAppend("vec4(0, 0, 0, 0)");
+ }
+ fsBuilder->codeAppend(";");
+}
+
« no previous file with comments | « src/gpu/glsl/GrGLSLBlend.h ('k') | src/gpu/glsl/GrGLSLXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698