blob: fe82b5ed8cc8b88afdb140a5c7a337bc2b5006e5 [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"
Mike Klein33d20552017-03-22 13:47:51 -04009#include "sk_tool_utils.h"
joshualitt1107e902015-05-11 14:52:11 -070010
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
halcanary2a243382015-09-09 08:16:41 -070018DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
joshualitt1107e902015-05-11 14:52:11 -070019 const char text[] = "Hamburgefons";
20
21 SkPaint paint;
caryclark1818acb2015-07-24 12:09:25 -070022 sk_tool_utils::set_portable_typeface(&paint);
joshualitt1107e902015-05-11 14:52:11 -070023 paint.setTextSize(256);
24 paint.setAntiAlias(true);
25
26 // setup up maskfilter
mtkleindbfd7ab2016-09-01 11:24:54 -070027 const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
joshualitt1107e902015-05-11 14:52:11 -070028
29 SkPaint blurPaint(paint);
reedefdfd512016-04-04 10:02:58 -070030 blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
joshualitt1107e902015-05-11 14:52:11 -070031
32 SkTextBlobBuilder builder;
33
34 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
35
fmalita37283c22016-09-13 10:00:23 -070036 sk_sp<SkTextBlob> blob(builder.make());
37 canvas->drawTextBlob(blob, 10, 200, blurPaint);
38 canvas->drawTextBlob(blob, 10, 200, paint);
joshualitt1107e902015-05-11 14:52:11 -070039
40 size_t len = strlen(text);
41 canvas->drawText(text, len, 10, 500, blurPaint);
42 canvas->drawText(text, len, 10, 500, paint);
joshualitt1107e902015-05-11 14:52:11 -070043}