diff options
author | Herb Derby <herb@google.com> | 2017-12-20 14:36:53 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-13 18:48:32 +0000 |
commit | 010d39de0ca109aa8932de6e9712090cc750ca2e (patch) | |
tree | 7a4f976db3908662ccd5db7ac38011b6f36154af /gm | |
parent | 1798739ab8d31a1277e49f997e82323ac598e6bd (diff) |
Make a GM for checking blur bounds.
Change-Id: I30e7ac2ad37f666e3fafe94a3f52a764e1e2e652
Reviewed-on: https://skia-review.googlesource.com/88040
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/blurpositioning.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gm/blurpositioning.cpp b/gm/blurpositioning.cpp new file mode 100644 index 0000000000..23bacdcceb --- /dev/null +++ b/gm/blurpositioning.cpp @@ -0,0 +1,36 @@ +/* + * 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 "gm.h" +#include "SkBlurImageFilter.h" + +// For all sigma, the black box should be centered in the red outline. For small sigma, +// the rectangle is not blurred, but still must be centered properly. + +DEF_SIMPLE_GM(check_small_sigma_offset, canvas, 200, 1200) { + + for (auto sigma : {0.0, 0.1, 0.2, 0.3, 0.4, 0.6, 0.8, 1.0, 1.2}) { + // border calculation from SkBlurImageFilter + int border = SkScalarCeilToInt(sigma * 3); + + SkRect r = SkRect::MakeXYWH(50, 50, 100, 50); + SkRect b = r.makeOutset(border + 1, border + 1); + b.inset(0.5f, 0.5f); + SkPaint p; + p.setColor(SK_ColorRED); + p.setStyle(SkPaint::Style::kStroke_Style); + + canvas->drawRect(b, p); + + p.reset(); + p.setColor(SK_ColorBLACK); + p.setImageFilter(SkBlurImageFilter::Make(sigma, sigma, nullptr)); + canvas->drawRect(r, p); + + canvas->translate(0, 100); + } +} |