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

Unified Diff: src/gpu/effects/GrPorterDuffXferProcessor.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/effects/GrCustomXfermode.cpp ('k') | src/gpu/glsl/GrGLSLBlend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrPorterDuffXferProcessor.cpp
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index e288f0c8bd6be7a5861e9f76f5bdc1ca66a00a7e..42a96319769d73da286d29119de389aad6afb9b5 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -548,12 +548,27 @@ 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 {
const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.getXfermode());
+
+ // Apply coverage.
+ if (xp.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&, const GrXferProcessor&) override {}
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/glsl/GrGLSLBlend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698