diff options
author | 2017-07-10 13:49:05 -0400 | |
---|---|---|
committer | 2017-07-10 19:49:18 +0000 | |
commit | a48ae6ec2feb32e3d781ad43353209a90059a01d (patch) | |
tree | 432a6d907f63ba87c2422253c67be9a1acf0c90c /gm | |
parent | a2318576d6510dc63513ce335ed0027666bd55bf (diff) |
Blur gm.
Change-Id: I47294ba47880237541dee8193df55e31b3487f24
Reviewed-on: https://skia-review.googlesource.com/22061
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/blurimagevmask.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/gm/blurimagevmask.cpp b/gm/blurimagevmask.cpp new file mode 100644 index 0000000000..15f8d1e1ca --- /dev/null +++ b/gm/blurimagevmask.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkBlurMaskFilter.h" +#include "SkBlurImageFilter.h" +#include "gm.h" +#include "sk_tool_utils.h" + + +DEF_SIMPLE_GM(blurimagevmask, canvas, 700, 1200) { + SkPaint paint; + paint.setAntiAlias(true); + paint.setColor(SK_ColorBLACK); + + SkPaint textPaint; + textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); + textPaint.setTextSize(SkIntToScalar(25)); + + const double sigmas[] = {3.0, 8.0, 16.0, 24.0, 32.0}; + + canvas->drawString("mask blur", 285, 50, textPaint); + canvas->drawString("image blur", 285 + 250, 50, textPaint); + + + SkRect r = {35, 100, 135, 200}; + for (auto sigma:sigmas) { + + canvas->drawRect(r, paint); + + char out[100]; + sprintf(out, "Sigma: %g", sigma); + canvas->drawString(out, r.left(), r.bottom() + 35, textPaint); + + r.offset(250, 0); + + paint.setMaskFilter( + SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, + SkBlurMaskFilter::kHighQuality_BlurFlag)); + canvas->drawRect(r, paint); + paint.setMaskFilter(nullptr); + + SkPaint imageBlurPaint; + r.offset(250, 0); + imageBlurPaint.setImageFilter(SkBlurImageFilter::Make(sigma, sigma, nullptr)); + canvas->saveLayer(nullptr, &imageBlurPaint); + + canvas->drawRect(r, paint); + canvas->restore(); + r.offset(-500, 200); + } + +} |