Revert "ccpr: Simplify triangle corners"
This reverts commit 622650a1949f9a68793ac895d9fbadee7177d860.
Reason for revert: Going to try to improve AAA quality on curve corners
Original change's description:
> ccpr: Simplify triangle corners
>
> Modifies triangle corner shaders to just approximate their coverage with
> linear values that ramp to zero at bloat vertices outside the triangle.
>
> For the vertex backend, since corners now have the same fragment shader
> as the rest of the triangle, we fold them in with the other steps and
> draw triangles in a single pass.
>
> The geometry backend still draws triangles in two passes, as there is
> not an apparent performance advantage in combining them.
>
> Bug: skia:
> Change-Id: Ib4a89d793a3c706f734d0271875c8a3e5c87c49b
> Reviewed-on: https://skia-review.googlesource.com/112632
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com
Change-Id: I45e7b9d7d7f8452b28bd54ca1e90a1f046cb2462
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/113180
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCQuadraticShader.cpp b/src/gpu/ccpr/GrCCQuadraticShader.cpp
index e164cff..baa10fd 100644
--- a/src/gpu/ccpr/GrCCQuadraticShader.cpp
+++ b/src/gpu/ccpr/GrCCQuadraticShader.cpp
@@ -13,7 +13,9 @@
using Shader = GrCCCoverageProcessor::Shader;
-const char* GrCCQuadraticShader::emitSetupCode(GrGLSLVertexGeoBuilder* s, const char* pts) const {
+void GrCCQuadraticShader::emitSetupCode(GrGLSLVertexGeoBuilder* s, const char* pts,
+ const char* /*repetitionID*/, const char* /*wind*/,
+ GeometryVars* vars) const {
s->declareGlobal(fCanonicalMatrix);
s->codeAppendf("%s = float3x3(0.0, 0, 1, "
"0.5, 0, 1, "
@@ -36,20 +38,23 @@
"%s[0] + tan0 * t, "
"%s[1] + tan1 * t, "
"%s[2]);", pts, pts, pts, pts);
- return "quadratic_hull";
+ vars->fHullVars.fAlternatePoints = "quadratic_hull";
}
-Shader::CoverageHandling GrCCQuadraticShader::onEmitVaryings(GrGLSLVaryingHandler* varyingHandler,
- GrGLSLVarying::Scope scope,
- SkString* code, const char* position,
- const char* coverageTimesWind) {
+void GrCCQuadraticShader::onEmitVaryings(GrGLSLVaryingHandler* varyingHandler,
+ GrGLSLVarying::Scope scope, SkString* code,
+ const char* position, const char* inputCoverage,
+ const char* wind) {
fCoords.reset(kFloat4_GrSLType, scope);
varyingHandler->addVarying("coords", &fCoords);
code->appendf("%s.xy = (%s * float3(%s, 1)).xy;",
OutName(fCoords), fCanonicalMatrix.c_str(), position);
code->appendf("%s.zw = float2(2 * %s.x, -1) * float2x2(%s);",
OutName(fCoords), OutName(fCoords), fCanonicalMatrix.c_str());
- return CoverageHandling::kNotHandled;
+
+ fCoverageTimesWind.reset(kHalf_GrSLType, scope);
+ varyingHandler->addVarying("coverage_times_wind", &fCoverageTimesWind);
+ code->appendf("%s = %s * %s;", OutName(fCoverageTimesWind), inputCoverage, wind);
}
void GrCCQuadraticShader::onEmitFragmentCode(const GrCCCoverageProcessor& proc,
@@ -62,5 +67,5 @@
f->codeAppendf("d /= %f;", proc.debugBloat());
}
#endif
- f->codeAppendf("%s = clamp(0.5 - d, 0, 1);", outputCoverage);
+ f->codeAppendf("%s = clamp(0.5 - d, 0, 1) * %s;", outputCoverage, fCoverageTimesWind.fsIn());
}