fix fiddle with blur

Docs-Preview: https://skia.org/?cl=114018
NOTRY=true
R=caryclark@google.com
Bug: skia:6898
Change-Id: Ied96a0b8479a9b359299ba24ecfa55022046beb0
Reviewed-on: https://skia-review.googlesource.com/114018
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh
index 353d244..78b527a 100644
--- a/docs/SkBitmap_Reference.bmh
+++ b/docs/SkBitmap_Reference.bmh
@@ -640,16 +640,16 @@
                 bitmap.bytesPerPixel());
     }
 #StdOut
-color: kUnknown_SkColorType      bytesPerPixel: 0

-color: kAlpha_8_SkColorType      bytesPerPixel: 1

-color: kRGB_565_SkColorType      bytesPerPixel: 2

-color: kARGB_4444_SkColorType    bytesPerPixel: 2

-color: kRGBA_8888_SkColorType    bytesPerPixel: 4

-color: kRGB_888x_SkColorType     bytesPerPixel: 4

-color: kBGRA_8888_SkColorType    bytesPerPixel: 4

-color: kRGBA_1010102_SkColorType bytesPerPixel: 4

-color: kRGB_101010x_SkColorType  bytesPerPixel: 4

-color: kGray_8_SkColorType       bytesPerPixel: 1

+color: kUnknown_SkColorType      bytesPerPixel: 0
+color: kAlpha_8_SkColorType      bytesPerPixel: 1
+color: kRGB_565_SkColorType      bytesPerPixel: 2
+color: kARGB_4444_SkColorType    bytesPerPixel: 2
+color: kRGBA_8888_SkColorType    bytesPerPixel: 4
+color: kRGB_888x_SkColorType     bytesPerPixel: 4
+color: kBGRA_8888_SkColorType    bytesPerPixel: 4
+color: kRGBA_1010102_SkColorType bytesPerPixel: 4
+color: kRGB_101010x_SkColorType  bytesPerPixel: 4
+color: kGray_8_SkColorType       bytesPerPixel: 1
 color: kRGBA_F16_SkColorType     bytesPerPixel: 8
 ##
 ##
@@ -710,16 +710,16 @@
                 bitmap.shiftPerPixel());
     }
 #StdOut
-color: kUnknown_SkColorType       shiftPerPixel: 0

-color: kAlpha_8_SkColorType       shiftPerPixel: 0

-color: kRGB_565_SkColorType       shiftPerPixel: 1

-color: kARGB_4444_SkColorType     shiftPerPixel: 1

-color: kRGBA_8888_SkColorType     shiftPerPixel: 2

-color: kRGB_888x_SkColorType      shiftPerPixel: 2

-color: kBGRA_8888_SkColorType     shiftPerPixel: 2

-color: kRGBA_1010102_SkColorType  shiftPerPixel: 2

-color: kRGB_101010x_SkColorType   shiftPerPixel: 2

-color: kGray_8_SkColorType        shiftPerPixel: 0

+color: kUnknown_SkColorType       shiftPerPixel: 0
+color: kAlpha_8_SkColorType       shiftPerPixel: 0
+color: kRGB_565_SkColorType       shiftPerPixel: 1
+color: kARGB_4444_SkColorType     shiftPerPixel: 1
+color: kRGBA_8888_SkColorType     shiftPerPixel: 2
+color: kRGB_888x_SkColorType      shiftPerPixel: 2
+color: kBGRA_8888_SkColorType     shiftPerPixel: 2
+color: kRGBA_1010102_SkColorType  shiftPerPixel: 2
+color: kRGB_101010x_SkColorType   shiftPerPixel: 2
+color: kGray_8_SkColorType        shiftPerPixel: 0
 color: kRGBA_F16_SkColorType      shiftPerPixel: 3
 ##
 ##
@@ -3287,25 +3287,28 @@
 #Bug 7103
 #Example
 #Height 160
-    SkBitmap alpha, bitmap;
-    bitmap.allocN32Pixels(100, 100);
-    SkCanvas offscreen(bitmap);
-    offscreen.clear(0);
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    paint.setColor(SK_ColorBLUE);
-    paint.setStyle(SkPaint::kStroke_Style);
-    paint.setStrokeWidth(20);
-    offscreen.drawCircle(50, 50, 39, paint);
-    offscreen.flush();
-    const SkScalar kBlurSigma = SkBlurMaskFilter::ConvertRadiusToSigma(SkIntToScalar(25));
-    paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma,
-                                    SkBlurMaskFilter::kHighQuality_BlurFlag));
-    SkIPoint offset;
-    bitmap.extractAlpha(&alpha, &paint, &offset);
-    paint.setColor(SK_ColorRED);
-    canvas->drawBitmap(bitmap, 0, -offset.fY, &paint);
-    canvas->drawBitmap(alpha, 100 + offset.fX, 0, &paint);
+    auto radiusToSigma = [](SkScalar radius) -> SkScalar {

+         static const SkScalar kBLUR_SIGMA_SCALE = 0.57735f;

+         return radius > 0 ? kBLUR_SIGMA_SCALE * radius + 0.5f : 0.0f;

+    };

+    SkBitmap alpha, bitmap;

+    bitmap.allocN32Pixels(100, 100);

+    SkCanvas offscreen(bitmap);

+    offscreen.clear(0);

+    SkPaint paint;

+    paint.setAntiAlias(true);

+    paint.setColor(SK_ColorBLUE);

+    paint.setStyle(SkPaint::kStroke_Style);

+    paint.setStrokeWidth(20);

+    offscreen.drawCircle(50, 50, 39, paint);

+    offscreen.flush();

+    paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, radiusToSigma(25),

+                        SkBlurMaskFilter::kHighQuality_BlurFlag));

+    SkIPoint offset;

+    bitmap.extractAlpha(&alpha, &paint, &offset);

+    paint.setColor(SK_ColorRED);

+    canvas->drawBitmap(bitmap, 0, -offset.fY, &paint);

+    canvas->drawBitmap(alpha, 100 + offset.fX, 0, &paint);

 ##
 
 #SeeAlso extractSubset
diff --git a/site/user/api/SkBitmap_Reference.md b/site/user/api/SkBitmap_Reference.md
index 437b4cc..999460c 100644
--- a/site/user/api/SkBitmap_Reference.md
+++ b/site/user/api/SkBitmap_Reference.md
@@ -3518,7 +3518,7 @@
 
 ### Example
 
-<div><fiddle-embed name="e122936b119f20098aace454c2105a12"></fiddle-embed></div>
+<div><fiddle-embed name="c102065eea5c3f109fdcad3f0e269ce5"></fiddle-embed></div>
 
 ### See Also
 
diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm
index 868f0fa..261f7d8 100644
--- a/site/user/api/catalog.htm
+++ b/site/user/api/catalog.htm
@@ -3766,10 +3766,10 @@
     "name": "SkBitmap::extractAlpha"
 },
     "SkBitmap_extractAlpha_2": {
-    "code": "void draw(SkCanvas* canvas) {\n    SkBitmap alpha, bitmap;\n    bitmap.allocN32Pixels(100, 100);\n    SkCanvas offscreen(bitmap);\n    offscreen.clear(0);\n    SkPaint paint;\n    paint.setAntiAlias(true);\n    paint.setColor(SK_ColorBLUE);\n    paint.setStyle(SkPaint::kStroke_Style);\n    paint.setStrokeWidth(20);\n    offscreen.drawCircle(50, 50, 39, paint);\n    offscreen.flush();\n    const SkScalar kBlurSigma = SkBlurMaskFilter::ConvertRadiusToSigma(SkIntToScalar(25));\n    paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma,\n                                    SkBlurMaskFilter::kHighQuality_BlurFlag));\n    SkIPoint offset;\n    bitmap.extractAlpha(&alpha, &paint, &offset);\n    paint.setColor(SK_ColorRED);\n    canvas->drawBitmap(bitmap, 0, -offset.fY, &paint);\n    canvas->drawBitmap(alpha, 100 + offset.fX, 0, &paint);\n}",
+    "code": "void draw(SkCanvas* canvas) {\n    auto radiusToSigma = [](SkScalar radius) -> SkScalar {\n         static const SkScalar kBLUR_SIGMA_SCALE = 0.57735f;\n         return radius > 0 ? kBLUR_SIGMA_SCALE * radius + 0.5f : 0.0f;\n    };\n    SkBitmap alpha, bitmap;\n    bitmap.allocN32Pixels(100, 100);\n    SkCanvas offscreen(bitmap);\n    offscreen.clear(0);\n    SkPaint paint;\n    paint.setAntiAlias(true);\n    paint.setColor(SK_ColorBLUE);\n    paint.setStyle(SkPaint::kStroke_Style);\n    paint.setStrokeWidth(20);\n    offscreen.drawCircle(50, 50, 39, paint);\n    offscreen.flush();\n    paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, radiusToSigma(25),\n                        SkBlurMaskFilter::kHighQuality_BlurFlag));\n    SkIPoint offset;\n    bitmap.extractAlpha(&alpha, &paint, &offset);\n    paint.setColor(SK_ColorRED);\n    canvas->drawBitmap(bitmap, 0, -offset.fY, &paint);\n    canvas->drawBitmap(alpha, 100 + offset.fX, 0, &paint);\n}",
     "width": 256,
     "height": 160,
-    "hash": "e122936b119f20098aace454c2105a12",
+    "hash": "c102065eea5c3f109fdcad3f0e269ce5",
     "file": "SkBitmap_Reference",
     "name": "SkBitmap::extractAlpha_2"
 },