diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 15 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLXferProcessor.cpp | 10 |
3 files changed, 14 insertions, 17 deletions
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 470af46783..cd2fe563d1 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -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); - } } } diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 96d322f0f9..7d22ad37fa 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -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, diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp index ba5b5dacae..41a467753c 100644 --- a/src/gpu/glsl/GrGLSLXferProcessor.cpp +++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp @@ -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); } |