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

Unified Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 1170553002: Apply coverage in XP base class when using dst reads (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: names Created 5 years, 6 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/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/gl/GrGLXferProcessor.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 83c72f934255f9bd6ac674b77313bf52cb802e41..ecaa87f941cb80f840d74f7f45ca589fcc4cfc21 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -306,7 +306,6 @@ public:
}
const char* name() const override { return "Porter Duff"; }
- bool hasSecondaryOutput() const override { return fBlendFormula.hasSecondaryOutput(); }
GrGLXferProcessor* createGLInstance() const override;
@@ -325,6 +324,8 @@ private:
void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
+ bool onHasSecondaryOutput() const override { return fBlendFormula.hasSecondaryOutput(); }
+
void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override {
blendInfo->fEquation = fBlendFormula.fBlendEquation;
blendInfo->fSrcBlend = fBlendFormula.fSrcCoeff;
@@ -393,7 +394,7 @@ public:
};
private:
- void onEmitCode(const EmitArgs& args) override {
+ void emitOutputsForBlendState(const EmitArgs& args) override {
const PorterDuffXferProcessor& xp = args.fXP.cast<PorterDuffXferProcessor>();
GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
@@ -459,7 +460,6 @@ public:
}
const char* name() const override { return "Porter Duff Shader"; }
- bool hasSecondaryOutput() const override { return false; }
GrGLXferProcessor* createGLInstance() const override;
@@ -543,29 +543,22 @@ public:
}
private:
- void onEmitCode(const EmitArgs& args) override {
- const ShaderPDXferProcessor& xp = args.fXP.cast<ShaderPDXferProcessor>();
- GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+ void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor,
+ const char* outColor, const GrXferProcessor& proc) override {
+ const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
+ GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
SkXfermode::Coeff srcCoeff, dstCoeff;
SkXfermode::ModeAsCoeff(xp.getXfermode(), &srcCoeff, &dstCoeff);
- const char* dstColor = fsBuilder->dstColor();
-
- fsBuilder->codeAppend("vec4 colorBlend =");
+ fsBuilder->codeAppendf("%s =", outColor);
// append src blend
- bool didAppend = append_porterduff_term(fsBuilder, srcCoeff,
- args.fInputColor, args.fInputColor,
- dstColor, false);
+ bool didAppend = append_porterduff_term(fsBuilder, srcCoeff, srcColor, srcColor, dstColor,
+ false);
// append dst blend
- SkAssertResult(append_porterduff_term(fsBuilder, dstCoeff,
- dstColor, args.fInputColor,
- dstColor, didAppend));
+ SkAssertResult(append_porterduff_term(fsBuilder, dstCoeff, dstColor, srcColor, dstColor,
+ didAppend));
fsBuilder->codeAppend(";");
-
- fsBuilder->codeAppendf("%s = %s * colorBlend + (vec4(1.0) - %s) * %s;",
- args.fOutputPrimary, args.fInputCoverage, args.fInputCoverage,
- dstColor);
}
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
@@ -596,8 +589,6 @@ public:
GrGLXferProcessor* createGLInstance() const override;
- bool hasSecondaryOutput() const override { return false; }
-
private:
PDLCDXferProcessor(GrColor blendConstant, uint8_t alpha);
@@ -642,7 +633,7 @@ public:
GrProcessorKeyBuilder* b) {}
private:
- void onEmitCode(const EmitArgs& args) override {
+ void emitOutputsForBlendState(const EmitArgs& args) override {
GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInputColor,
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/gl/GrGLXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698