Check for divide by zero in fill_in_1D_gaussian_kernel

Bug: skia:7769
Change-Id: I56a67f8a6f19437359ad6e7bf2d57f6e9a7992c9
Reviewed-on: https://skia-review.googlesource.com/118240
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Greg Daniel 2018-04-03 13:38:01 -04:00 committed by Skia Commit-Bot
parent d09b06a349
commit 3aecc305e1

View File

@ -177,7 +177,15 @@ void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrShaderC
///////////////////////////////////////////////////////////////////////////////
static void fill_in_1D_gaussian_kernel(float* kernel, int width, float gaussianSigma, int radius) {
const float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma);
float twoSigmaSqrd = 2.0f * gaussianSigma * gaussianSigma;
if (SkScalarNearlyZero(twoSigmaSqrd, SK_ScalarNearlyZero)) {
for (int i = 0; i < width; ++i) {
kernel[i] = 0.0f;
}
return;
}
const float denom = 1.0f / twoSigmaSqrd;
float sum = 0.0f;
for (int i = 0; i < width; ++i) {