aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp2
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index 121e225796..fdd4990328 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -177,7 +177,7 @@ void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrShaderC
///////////////////////////////////////////////////////////////////////////////
static void fill_in_1D_gaussian_kernel(float* kernel, int width, float gaussianSigma, int radius) {
- float twoSigmaSqrd = 2.0f * gaussianSigma * gaussianSigma;
+ const float twoSigmaSqrd = 2.0f * gaussianSigma * gaussianSigma;
if (SkScalarNearlyZero(twoSigmaSqrd, SK_ScalarNearlyZero)) {
for (int i = 0; i < width; ++i) {
kernel[i] = 0.0f;
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index ffbcf500ab..56b012afe5 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -215,8 +215,19 @@ bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons
static void fill_in_2D_gaussian_kernel(float* kernel, int width, int height,
SkScalar sigmaX, SkScalar sigmaY) {
SkASSERT(width * height <= MAX_KERNEL_SIZE);
- const float sigmaXDenom = 1.0f / (2.0f * SkScalarToFloat(SkScalarSquare(sigmaX)));
- const float sigmaYDenom = 1.0f / (2.0f * SkScalarToFloat(SkScalarSquare(sigmaY)));
+ const float twoSigmaSqrdX = 2.0f * SkScalarToFloat(SkScalarSquare(sigmaX));
+ const float twoSigmaSqrdY = 2.0f * SkScalarToFloat(SkScalarSquare(sigmaY));
+
+ if (SkScalarNearlyZero(twoSigmaSqrdX, SK_ScalarNearlyZero) ||
+ SkScalarNearlyZero(twoSigmaSqrdY, SK_ScalarNearlyZero)) {
+ for (int i = 0; i < width * height; ++i) {
+ kernel[i] = 0.0f;
+ }
+ return;
+ }
+
+ const float sigmaXDenom = 1.0f / twoSigmaSqrdX;
+ const float sigmaYDenom = 1.0f / twoSigmaSqrdY;
const int xRadius = width / 2;
const int yRadius = height / 2;