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" |
| 9 | |
| 10 | #include "SkBlurMask.h" |
| 11 | #include "SkBlurMaskFilter.h" |
| 12 | #include "SkCanvas.h" |
| 13 | #include "SkTextBlob.h" |
| 14 | |
| 15 | // This test ensures that glyphs whose point size is less than the SkGlyphCache's maxmium, but |
| 16 | // who have a large blur, are still handled correctly |
halcanary | 2a24338 | 2015-09-09 08:16:41 -0700 | [diff] [blame^] | 17 | DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) { |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 18 | const char text[] = "Hamburgefons"; |
| 19 | |
| 20 | SkPaint paint; |
caryclark | 1818acb | 2015-07-24 12:09:25 -0700 | [diff] [blame] | 21 | sk_tool_utils::set_portable_typeface(&paint); |
joshualitt | 1107e90 | 2015-05-11 14:52:11 -0700 | [diff] [blame] | 22 | paint.setTextSize(256); |
| 23 | paint.setAntiAlias(true); |
| 24 | |
| 25 | // setup up maskfilter |
| 26 | static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40)); |
| 27 | |
| 28 | SkPaint blurPaint(paint); |
| 29 | SkAutoTUnref<SkMaskFilter> mf(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, kSigma)); |
| 30 | blurPaint.setMaskFilter(mf); |
| 31 | |
| 32 | SkTextBlobBuilder builder; |
| 33 | |
| 34 | sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); |
| 35 | |
| 36 | SkAutoTUnref<const SkTextBlob> blob(builder.build()); |
| 37 | canvas->drawTextBlob(blob.get(), 10, 200, blurPaint); |
| 38 | canvas->drawTextBlob(blob.get(), 10, 200, paint); |
| 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 | } |