blob: 19d390be541b5a9ec7757d04a7e8d7474699dade [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
halcanary2a243382015-09-09 08:16:41 -070017DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
joshualitt1107e902015-05-11 14:52:11 -070018 const char text[] = "Hamburgefons";
19
20 SkPaint paint;
caryclark1818acb2015-07-24 12:09:25 -070021 sk_tool_utils::set_portable_typeface(&paint);
joshualitt1107e902015-05-11 14:52:11 -070022 paint.setTextSize(256);
23 paint.setAntiAlias(true);
24
25 // setup up maskfilter
mtkleindbfd7ab2016-09-01 11:24:54 -070026 const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
joshualitt1107e902015-05-11 14:52:11 -070027
28 SkPaint blurPaint(paint);
reedefdfd512016-04-04 10:02:58 -070029 blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
joshualitt1107e902015-05-11 14:52:11 -070030
31 SkTextBlobBuilder builder;
32
33 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
34
fmalita37283c22016-09-13 10:00:23 -070035 sk_sp<SkTextBlob> blob(builder.make());
36 canvas->drawTextBlob(blob, 10, 200, blurPaint);
37 canvas->drawTextBlob(blob, 10, 200, paint);
joshualitt1107e902015-05-11 14:52:11 -070038
39 size_t len = strlen(text);
40 canvas->drawText(text, len, 10, 500, blurPaint);
41 canvas->drawText(text, len, 10, 500, paint);
joshualitt1107e902015-05-11 14:52:11 -070042}