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/gm.h"
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"
19 #include "tools/ToolUtils.h"
20 
21 #include <string.h>
22 
23 // This test ensures that glyphs whose point size is less than the SkStrike's maxmium, but
24 // who have a large blur, are still handled correctly
25 DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
26     const char text[] = "Hamburgefons";
27 
28     SkFont font(ToolUtils::create_portable_typeface(), 256);
29     auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
30 
31     // setup up maskfilter
32     const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
33 
34     SkPaint blurPaint;
35     blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma));
36 
37     canvas->drawTextBlob(blob, 10, 200, blurPaint);
38     canvas->drawTextBlob(blob, 10, 200, SkPaint());
39 
40     size_t len = strlen(text);
41     canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, blurPaint);
42     canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, SkPaint());
43 }
44