aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-03-13 09:02:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-13 15:06:47 +0000
commit98aebac62825a99494773d13098b1baeefab1223 (patch)
treea0c25bc235adb1f8747332451eca273c2b6fbaf0 /docs
parent52e943a4693af75b40b62200191981da7458db62 (diff)
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>
Diffstat (limited to 'docs')
-rw-r--r--docs/SkBitmap_Reference.bmh81
1 files changed, 42 insertions, 39 deletions
diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh
index 353d244976..78b527aa2b 100644
--- a/docs/SkBitmap_Reference.bmh
+++ b/docs/SkBitmap_Reference.bmh
@@ -640,16 +640,16 @@ Returns zero if colorType( is kUnknown_SkColorType.
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 @@ Returns zero for kUnknown_SkColorType.
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 @@ Pixel_Ref. Sets offset to top-left position for dst for alignment with Bitmap;
#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