Ensure that blur result is identity if both sigmas are near-zero

Change-Id: I0c343167e63f147f21afee805ea934bd5f161024
Bug: chromium:1170700
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360608
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/gm/blurs.cpp b/gm/blurs.cpp
index e0ddb57..32757a5 100644
--- a/gm/blurs.cpp
+++ b/gm/blurs.cpp
@@ -139,11 +139,23 @@
     canvas->drawRect(SkRect::MakeWH(700, 800), p);
 }
 
-DEF_SIMPLE_GM(BlurSmallSigma, canvas, 256, 256) {
-    // Normal sigma on x-axis, a small but non-zero sigma on y-axis that should
-    // be treated as identity.
+DEF_SIMPLE_GM(BlurSmallSigma, canvas, 512, 256) {
+    {
+        // Normal sigma on x-axis, a small but non-zero sigma on y-axis that should
+        // be treated as identity.
+        SkPaint paint;
+        paint.setImageFilter(SkImageFilters::Blur(16.f, 1e-5f, nullptr));
+        canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), paint);
+    }
 
-    SkPaint paint;
-    paint.setImageFilter(SkImageFilters::Blur(16.f, 1e-5f, nullptr));
-    canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), paint);
+    {
+        // Small sigma on both axes, should be treated as identity and no red should show
+        SkPaint paint;
+        paint.setColor(SK_ColorRED);
+        SkRect rect = SkRect::MakeLTRB(320, 64, 448, 192);
+        canvas->drawRect(rect, paint);
+        paint.setColor(SK_ColorBLACK);
+        paint.setImageFilter(SkImageFilters::Blur(1e-5f, 1e-5f, nullptr));
+        canvas->drawRect(rect, paint);
+    }
 }
diff --git a/src/effects/imagefilters/SkBlurImageFilter.cpp b/src/effects/imagefilters/SkBlurImageFilter.cpp
index b1d424f..27addcc 100644
--- a/src/effects/imagefilters/SkBlurImageFilter.cpp
+++ b/src/effects/imagefilters/SkBlurImageFilter.cpp
@@ -627,7 +627,8 @@
 sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
         const Context& ctx, SkVector sigma, const sk_sp<SkSpecialImage> &input, SkIRect inputBounds,
         SkIRect dstBounds, SkIPoint inputOffset, SkIPoint* offset) const {
-    if (0 == sigma.x() && 0 == sigma.y()) {
+    if (SkGpuBlurUtils::IsEffectivelyZeroSigma(sigma.x()) &&
+        SkGpuBlurUtils::IsEffectivelyZeroSigma(sigma.y())) {
         offset->fX = inputBounds.x() + inputOffset.fX;
         offset->fY = inputBounds.y() + inputOffset.fY;
         return input->makeSubset(inputBounds);