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

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

Issue 1348583002: Make skpaint->grpaint flow work for composing draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused inheriteds to satisfy clang Created 5 years, 3 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/batches/GrDrawAtlasBatch.cpp ('k') | src/image/SkImageShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrXfermodeFragmentProcessor.cpp
diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
index 2bd641247fc77198524961e30eaf2ae67d5b8f3f..ec2f1f3130b0bb135896f5171afc011488e44963 100644
--- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
+++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
@@ -90,27 +90,18 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProcessor>();
- // Store alpha of input color and un-premultiply the input color by its alpha. We will
- // re-multiply by this alpha after blending the output colors of the two child procs.
- // This is because we don't want the paint's alpha to affect either child proc's output
- // before the blend; we want to apply the paint's alpha AFTER the blend. This mirrors the
- // software implementation of SkComposeShader.
- const char* opaqueInput = nullptr;
- const char* inputAlpha = nullptr;
+ const char* inputColor = nullptr;
if (args.fInputColor) {
- inputAlpha = "inputAlpha";
- opaqueInput = "opaqueInput";
- fsBuilder->codeAppendf("float inputAlpha = %s.a;", args.fInputColor);
- fsBuilder->codeAppendf("vec4 opaqueInput = vec4(%s.rgb / inputAlpha, 1);",
- args.fInputColor);
+ inputColor = "inputColor";
+ fsBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fInputColor);
}
// declare outputColor and emit the code for each of the two children
SkString srcColor("src");
- this->emitChild(0, opaqueInput, &srcColor, args);
+ this->emitChild(0, inputColor, &srcColor, args);
SkString dstColor("dst");
- this->emitChild(1, opaqueInput, &dstColor, args);
+ this->emitChild(1, inputColor, &dstColor, args);
// emit blend code
SkXfermode::Mode mode = cs.getMode();
@@ -118,8 +109,8 @@ void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
GrGLSLBlend::AppendMode(fsBuilder, srcColor.c_str(), dstColor.c_str(), args.fOutputColor, mode);
// re-multiply the output color by the input color's alpha
- if (inputAlpha) {
- fsBuilder->codeAppendf("%s *= %s;", args.fOutputColor, inputAlpha);
+ if (args.fInputColor) {
+ fsBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, args.fInputColor);
}
}
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.cpp ('k') | src/image/SkImageShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698