Remove setting of alpha coverage in text ops when in LCD mode

Bug: skia:
Change-Id: I0e320497fe72a0edad7bda7ea1c34dc2f713fc56
Reviewed-on: https://skia-review.googlesource.com/17530
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2017-05-22 16:34:34 -04:00 committed by Skia Commit-Bot
parent 8793e38898
commit 5592382a7a
3 changed files with 14 additions and 17 deletions

View File

@ -72,12 +72,6 @@ public:
fragBuilder->codeAppendf("%s = ", args.fOutputCoverage);
fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVec2f_GrSLType);
fragBuilder->codeAppend(";");
if (cte.maskFormat() == kA565_GrMaskFormat) {
// set alpha to be max of rgb coverage
fragBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);",
args.fOutputCoverage, args.fOutputCoverage,
args.fOutputCoverage, args.fOutputCoverage);
}
}
}

View File

@ -712,17 +712,14 @@ public:
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want distance
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend("vec4 val = "
"vec4(clamp((distance + vec3(afwidth)) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);");
fragBuilder->codeAppendf("%s = "
"vec4(clamp((distance + vec3(afwidth)) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0);",
args.fOutputCoverage);
} else {
fragBuilder->codeAppend(
"vec4 val = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), distance), 1.0);");
fragBuilder->codeAppendf(
"%s = vec4(smoothstep(vec3(-afwidth), vec3(afwidth), distance), 1.0);",
args.fOutputCoverage);
}
// set alpha to be max of rgb coverage
fragBuilder->codeAppend("val.a = max(max(val.r, val.g), val.b);");
fragBuilder->codeAppendf("%s = val;", args.fOutputCoverage);
}
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& processor,

View File

@ -44,8 +44,14 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
if (args.fInputCoverage) {
// We don't think any shaders actually output negative coverage, but just as a safety
// check for floating point precision errors we compare with <= here
fragBuilder->codeAppendf("if (all(lessThanEqual(%s, vec4(0)))) {"
// check for floating point precision errors we compare with <= here. We just check the
// rgb values of the coverage since the alpha may not have been set when using lcd. If
// we are using single channel coverage alpha will equal to rgb anyways.
//
// The discard here also helps for batching text draws together which need to read from
// a dst copy for blends. Though this only helps the case where the outer bounding boxes
// of each letter overlap and not two actually parts of the text.
fragBuilder->codeAppendf("if (all(lessThanEqual(%s.rgb, vec3(0)))) {"
" discard;"
"}", args.fInputCoverage);
}