Debian Codegraph @

gm/largeglyphblur.cpp

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