joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BD-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 | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBlurTypes.h" |
| 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkFont.h" |
| 12 | #include "include/core/SkFontTypes.h" |
| 13 | #include "include/core/SkMaskFilter.h" |
| 14 | #include "include/core/SkPaint.h" |
| 15 | #include "include/core/SkScalar.h" |
| 16 | #include "include/core/SkTextBlob.h" |
| 17 | #include "include/core/SkTypeface.h" |
| 18 | #include "src/core/SkBlurMask.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "tools/ToolUtils.h" |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 20 | |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 21 | #include <string.h> |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 22 | |
Herb Derby | 5fd955e | 2019-01-16 11:23:29 -0500 | [diff] [blame] | 23 | // This test ensures that glyphs whose point size is less than the SkStrike's maxmium, but |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 24 | // who have a large blur, are still handled correctly |
halcanary | 2a24338 | 2015-09-09 08:16:41 -0700 | [diff] [blame] | 25 | DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) { |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 26 | const char text[] = "Hamburgefons"; |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 27 | |
Mike Klein | ea3f014 | 2019-03-20 11:12:10 -0500 | [diff] [blame] | 28 | SkFont font(ToolUtils::create_portable_typeface(), 256); |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 29 | auto blob = SkTextBlob::MakeFromText(text, strlen(text), font); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 30 | |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 31 | // setup up maskfilter |
| 32 | const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40)); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 33 | |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 34 | SkPaint blurPaint; |
| 35 | blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma)); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 36 | |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 37 | canvas->drawTextBlob(blob, 10, 200, blurPaint); |
| 38 | canvas->drawTextBlob(blob, 10, 200, SkPaint()); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 39 | |
Mike Reed | ea8900e | 2018-12-22 17:37:30 -0500 | [diff] [blame] | 40 | size_t len = strlen(text); |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame] | 41 | canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, blurPaint); |
| 42 | canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, SkPaint()); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 43 | } |