Herb Derby | df33fef | 2017-08-14 14:58:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 9 | #include "include/core/SkBlurTypes.h" |
| 10 | #include "include/core/SkCanvas.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkColor.h" |
| 12 | #include "include/core/SkFont.h" |
| 13 | #include "include/core/SkMaskFilter.h" |
Ben Wagner | 6a34f3a | 2019-05-01 10:59:30 -0400 | [diff] [blame] | 14 | #include "include/core/SkPaint.h" |
Kevin Lubick | bca43ec | 2023-10-30 10:11:22 -0400 | [diff] [blame] | 15 | #include "tools/fonts/FontToolUtils.h" |
Herb Derby | df33fef | 2017-08-14 14:58:14 -0400 | [diff] [blame] | 16 | |
| 17 | // GM to check the behavior from chrome bug:745290 |
| 18 | DEF_SIMPLE_GM(blurSmallRadii, canvas, 100, 100) { |
| 19 | double sigmas[] = {0.5, 0.75, 1.0, 1.5, 2.5}; |
| 20 | SkPaint paint; |
Kevin Lubick | bca43ec | 2023-10-30 10:11:22 -0400 | [diff] [blame] | 21 | SkFont font = ToolUtils::DefaultPortableFont(); |
Herb Derby | df33fef | 2017-08-14 14:58:14 -0400 | [diff] [blame] | 22 | |
| 23 | for (auto sigma : sigmas) { |
| 24 | paint.setColor(SK_ColorBLACK); |
| 25 | paint.setAntiAlias(true); |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 26 | paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma)); |
Kevin Lubick | bca43ec | 2023-10-30 10:11:22 -0400 | [diff] [blame] | 27 | canvas->drawString("Guest", 20, 10, font, paint); |
Herb Derby | df33fef | 2017-08-14 14:58:14 -0400 | [diff] [blame] | 28 | |
| 29 | paint.setMaskFilter(nullptr); |
| 30 | paint.setColor(SK_ColorWHITE); |
Kevin Lubick | bca43ec | 2023-10-30 10:11:22 -0400 | [diff] [blame] | 31 | canvas->drawString("Guest", 20, 10, font, paint); |
Herb Derby | df33fef | 2017-08-14 14:58:14 -0400 | [diff] [blame] | 32 | canvas->translate(0, 20); |
| 33 | } |
| 34 | } |