Fix kernel width calculation in GPU-based Gaussian blur. When converting the
authorsenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jul 2011 21:48:35 +0000 (21:48 +0000)
committersenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jul 2011 21:48:35 +0000 (21:48 +0000)
sigma value to a kernel width, it should be rounded up.  Otherwise, for small
sigmas, the edge pixels of the kernel may be missing.

git-svn-id: http://skia.googlecode.com/svn/trunk@1891 2bbb7eff-a529-9590-31e7-b0007b416f81

samplecode/SampleBigBlur.cpp
src/gpu/SkGpuDevice.cpp

index 243e0df..aa5dc28 100644 (file)
@@ -28,7 +28,7 @@ protected:
             SkBlurMaskFilter::kHighQuality_BlurFlag);
         paint.setMaskFilter(mf)->unref();
         canvas->translate(200, 200);
-        canvas->drawCircle(100, 100, 250, paint);
+        canvas->drawCircle(100, 100, 200, paint);
         canvas->restore();
     }
 
index 513b5bb..90ab4bb 100644 (file)
@@ -865,7 +865,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
         sigma *= 0.5f;
     }
     scaleRect(&srcRect, 1.0f / scaleFactor);
-    int halfWidth = static_cast<int>(sigma * 3.0f);
+    int halfWidth = static_cast<int>(ceilf(sigma * 3.0f));
     int kernelWidth = halfWidth * 2 + 1;
 
     SkIRect srcIRect;