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

Unified Diff: src/effects/SkArithmeticMode_gpu.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 | « no previous file | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkArithmeticMode_gpu.cpp
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index 994b073ca7000012fcbf8940dd982d4c9b87d67a..a3793243ee6a93ded79c6a79907c1a71b4db7a51 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -213,8 +213,10 @@ private:
void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
GrGLSLXPFragmentBuilder* fragBuilder,
const char* srcColor,
+ const char* srcCoverage,
const char* dstColor,
const char* outColor,
+ const char* outColorSecondary,
const GrXferProcessor& proc) override {
fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, kDefault_GrSLPrecision,
@@ -222,6 +224,19 @@ private:
const char* kUni = pb->getUniformCStr(fKUni);
add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
+
+ // Apply coverage.
+ if (proc.dstReadUsesMixedSamples()) {
+ if (srcCoverage) {
+ fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
+ fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
+ } else {
+ fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ }
+ } else if (srcCoverage) {
+ fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ outColor, srcCoverage, outColor, srcCoverage, dstColor);
+ }
}
void onSetData(const GrGLSLProgramDataManager& pdman,
« no previous file with comments | « no previous file | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698