Make small epsilons more rigorous for gpu gaussian blurs
This also has several other bug fixes and refactorings within it that
I realized were possible while updating every where that had checked
sigma > 0 to be sigma > kEffectivelyZeroSigma.
The big things are that SkBlurPriv.h goes away and its functions are
just moved into SkGpuBlurUtils since they were only used by the GPU.
The implementations of those functions are also collected into
SkGpuBlurUtils.cpp. I removed the GrMatrixConvolution::MakeGaussian,
in favor of SkGpuBlurUtils filling in the kernel itself and then calling
the regular Make. This let me consolidate two different 1D kernel
computing functions, and remove the 1D fallback code from the 2D kernel
calculation because GaussianBlur() can detect that earlier.
The new GM, BlurSigmaSmall, originally drew incorrectly on the GPU
backend because it's small but non-zero sigma would trick the sigma > 0
checks in various places so we'd do a full 2 pass X/Y blur. However,
when the sigma was too small, the kernel was just filled with 0s so the
Y pass would effectively clear everything. While I could have just fixed
that to be a [0, 1, 0] kernel, updating the blur pipeline to compare
against integer radii seems more robust.
Change-Id: I3c41e0235a27615a9056b25e627ffedd995264bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328797
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.cpp b/src/gpu/effects/generated/GrRectBlurEffect.cpp
index e0ed896..e841334 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.cpp
+++ b/src/gpu/effects/generated/GrRectBlurEffect.cpp
@@ -70,14 +70,14 @@
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)");
- SkString _coords8137("float2(half2(xy.x, 0.5))");
- SkString _sample8137 = this->invokeChild(1, args, _coords8137.c_str());
+ SkString _coords8395("float2(half2(xy.x, 0.5))");
+ SkString _sample8395 = this->invokeChild(1, args, _coords8395.c_str());
fragBuilder->codeAppendf(
R"SkSL(
xCoverage = %s.w;)SkSL",
- _sample8137.c_str());
- SkString _coords8195("float2(half2(xy.y, 0.5))");
- SkString _sample8195 = this->invokeChild(1, args, _coords8195.c_str());
+ _sample8395.c_str());
+ SkString _coords8453("float2(half2(xy.y, 0.5))");
+ SkString _sample8453 = this->invokeChild(1, args, _coords8453.c_str());
fragBuilder->codeAppendf(
R"SkSL(
yCoverage = %s.w;
@@ -90,35 +90,35 @@
rect.xy = half2(float2(%s.xy) - pos);
rect.zw = half2(pos - float2(%s.zw));
})SkSL",
- _sample8195.c_str(),
+ _sample8453.c_str(),
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectFVar.isValid() ? args.fUniformHandler->getUniformCStr(rectFVar) : "float4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)",
rectHVar.isValid() ? args.fUniformHandler->getUniformCStr(rectHVar) : "half4(0)");
- SkString _coords9514("float2(half2(rect.x, 0.5))");
- SkString _sample9514 = this->invokeChild(1, args, _coords9514.c_str());
- SkString _coords9577("float2(half2(rect.z, 0.5))");
- SkString _sample9577 = this->invokeChild(1, args, _coords9577.c_str());
+ SkString _coords9772("float2(half2(rect.x, 0.5))");
+ SkString _sample9772 = this->invokeChild(1, args, _coords9772.c_str());
+ SkString _coords9835("float2(half2(rect.z, 0.5))");
+ SkString _sample9835 = this->invokeChild(1, args, _coords9835.c_str());
fragBuilder->codeAppendf(
R"SkSL(
xCoverage = (1.0 - %s.w) - %s.w;)SkSL",
- _sample9514.c_str(), _sample9577.c_str());
- SkString _coords9641("float2(half2(rect.y, 0.5))");
- SkString _sample9641 = this->invokeChild(1, args, _coords9641.c_str());
- SkString _coords9704("float2(half2(rect.w, 0.5))");
- SkString _sample9704 = this->invokeChild(1, args, _coords9704.c_str());
+ _sample9772.c_str(), _sample9835.c_str());
+ SkString _coords9899("float2(half2(rect.y, 0.5))");
+ SkString _sample9899 = this->invokeChild(1, args, _coords9899.c_str());
+ SkString _coords9962("float2(half2(rect.w, 0.5))");
+ SkString _sample9962 = this->invokeChild(1, args, _coords9962.c_str());
fragBuilder->codeAppendf(
R"SkSL(
yCoverage = (1.0 - %s.w) - %s.w;
})SkSL",
- _sample9641.c_str(), _sample9704.c_str());
- SkString _sample9773 = this->invokeChild(0, args);
+ _sample9899.c_str(), _sample9962.c_str());
+ SkString _sample10031 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;
%s = (inputColor * xCoverage) * yCoverage;
)SkSL",
- _sample9773.c_str(), args.fOutputColor);
+ _sample10031.c_str(), args.fOutputColor);
}
private: