blob: 8723824e13707e1ca58d19489ec67ff02dbb3558 [file] [log] [blame]
joshualitt1107e902015-05-11 14:52:11 -07001/*
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
17namespace skiagm {
18class LargeGlyphBlur : public GM {
19public:
20 LargeGlyphBlur() {}
21
22protected:
23 SkString onShortName() override {
24 return SkString("largeglyphblur");
25 }
26
27 SkISize onISize() override {
28 return SkISize::Make(kWidth, kHeight);
29 }
30
31 void onDraw(SkCanvas* canvas) override {
32 const char text[] = "Hamburgefons";
33
34 SkPaint paint;
35 sk_tool_utils::set_portable_typeface(&paint);
36 paint.setTextSize(256);
37 paint.setAntiAlias(true);
38
39 // setup up maskfilter
40 static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
41
42 SkPaint blurPaint(paint);
43 SkAutoTUnref<SkMaskFilter> mf(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, kSigma));
44 blurPaint.setMaskFilter(mf);
45
46 SkTextBlobBuilder builder;
47
48 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
49
50 SkAutoTUnref<const SkTextBlob> blob(builder.build());
51 canvas->drawTextBlob(blob.get(), 10, 200, blurPaint);
52 canvas->drawTextBlob(blob.get(), 10, 200, paint);
53
54 size_t len = strlen(text);
55 canvas->drawText(text, len, 10, 500, blurPaint);
56 canvas->drawText(text, len, 10, 500, paint);
57 }
58
59private:
60 static const int kWidth = 1920;
61 static const int kHeight = 600;
62
63 typedef GM INHERITED;
64};
65
66//////////////////////////////////////////////////////////////////////////////
67
68DEF_GM( return SkNEW(LargeGlyphBlur); )
69}