blob: 2c106ec3224e7514bf2f50926a47245e9e184804 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -04009#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"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050019#include "tools/ToolUtils.h"
joshualitt1107e902015-05-11 14:52:11 -070020
Ben Wagner7fde8e12019-05-01 17:28:53 -040021#include <string.h>
joshualitt1107e902015-05-11 14:52:11 -070022
Herb Derby5fd955e2019-01-16 11:23:29 -050023// This test ensures that glyphs whose point size is less than the SkStrike's maxmium, but
joshualitt1107e902015-05-11 14:52:11 -070024// who have a large blur, are still handled correctly
halcanary2a243382015-09-09 08:16:41 -070025DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
Mike Reedea8900e2018-12-22 17:37:30 -050026 const char text[] = "Hamburgefons";
joshualitt1107e902015-05-11 14:52:11 -070027
Mike Kleinea3f0142019-03-20 11:12:10 -050028 SkFont font(ToolUtils::create_portable_typeface(), 256);
Mike Reedea8900e2018-12-22 17:37:30 -050029 auto blob = SkTextBlob::MakeFromText(text, strlen(text), font);
joshualitt1107e902015-05-11 14:52:11 -070030
Mike Reedea8900e2018-12-22 17:37:30 -050031 // setup up maskfilter
32 const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
joshualitt1107e902015-05-11 14:52:11 -070033
Mike Reedea8900e2018-12-22 17:37:30 -050034 SkPaint blurPaint;
35 blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma));
joshualitt1107e902015-05-11 14:52:11 -070036
Mike Reedea8900e2018-12-22 17:37:30 -050037 canvas->drawTextBlob(blob, 10, 200, blurPaint);
38 canvas->drawTextBlob(blob, 10, 200, SkPaint());
joshualitt1107e902015-05-11 14:52:11 -070039
Mike Reedea8900e2018-12-22 17:37:30 -050040 size_t len = strlen(text);
Ben Wagner51e15a62019-05-07 15:38:46 -040041 canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, blurPaint);
42 canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, SkPaint());
joshualitt1107e902015-05-11 14:52:11 -070043}