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" |
| 12 | #include "SkBlurMaskFilter.h" |
| 13 | #include "SkCanvas.h" |
| 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); |
reed | efdfd51 | 2016-04-04 10:02:58 -0700 | [diff] [blame] | 30 | blurPaint.setMaskFilter(SkBlurMaskFilter::Make(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 | } |