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 | |
| 8 | #include "gm.h" |
Mike Klein | 33d2055 | 2017-03-22 13:47:51 -0400 | [diff] [blame] | 9 | #include "sk_tool_utils.h" |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 10 | |
| 11 | #include "SkBlurMask.h" |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 12 | #include "SkCanvas.h" |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 13 | #include "SkMaskFilter.h" |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 14 | #include "SkTextBlob.h" |
| 15 | |
| 16 | // This test ensures that glyphs whose point size is less than the SkGlyphCache's maxmium, but |
| 17 | // who have a large blur, are still handled correctly |
halcanary | 2a24338 | 2015-09-09 08:16:41 -0700 | [diff] [blame] | 18 | DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) { |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 19 | const char text[] = "Hamburgefons"; |
| 20 | |
| 21 | SkPaint paint; |
caryclark | 1818acb | 2015-07-24 12:09:25 -0700 | [diff] [blame] | 22 | sk_tool_utils::set_portable_typeface(&paint); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 23 | paint.setTextSize(256); |
| 24 | paint.setAntiAlias(true); |
| 25 | |
| 26 | // setup up maskfilter |
mtklein | dbfd7ab | 2016-09-01 11:24:54 -0700 | [diff] [blame] | 27 | const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40)); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 28 | |
| 29 | SkPaint blurPaint(paint); |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 30 | blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma)); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 31 | |
| 32 | SkTextBlobBuilder builder; |
| 33 | |
| 34 | sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); |
| 35 | |
fmalita | 37283c2 | 2016-09-13 10:00:23 -0700 | [diff] [blame] | 36 | sk_sp<SkTextBlob> blob(builder.make()); |
| 37 | canvas->drawTextBlob(blob, 10, 200, blurPaint); |
| 38 | canvas->drawTextBlob(blob, 10, 200, paint); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 39 | |
| 40 | size_t len = strlen(text); |
| 41 | canvas->drawText(text, len, 10, 500, blurPaint); |
| 42 | canvas->drawText(text, len, 10, 500, paint); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 43 | } |