2015-05-11 21:52:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gm.h"
|
2017-03-22 17:47:51 +00:00
|
|
|
#include "sk_tool_utils.h"
|
2015-05-11 21:52:11 +00:00
|
|
|
|
|
|
|
#include "SkBlurMask.h"
|
|
|
|
#include "SkCanvas.h"
|
2018-03-14 17:01:17 +00:00
|
|
|
#include "SkMaskFilter.h"
|
2015-05-11 21:52:11 +00:00
|
|
|
#include "SkTextBlob.h"
|
|
|
|
|
|
|
|
// This test ensures that glyphs whose point size is less than the SkGlyphCache's maxmium, but
|
|
|
|
// who have a large blur, are still handled correctly
|
2015-09-09 15:16:41 +00:00
|
|
|
DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
|
2015-05-11 21:52:11 +00:00
|
|
|
const char text[] = "Hamburgefons";
|
|
|
|
|
|
|
|
SkPaint paint;
|
2015-07-24 19:09:25 +00:00
|
|
|
sk_tool_utils::set_portable_typeface(&paint);
|
2015-05-11 21:52:11 +00:00
|
|
|
paint.setTextSize(256);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
|
|
|
|
// setup up maskfilter
|
2016-09-01 18:24:54 +00:00
|
|
|
const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
|
2015-05-11 21:52:11 +00:00
|
|
|
|
|
|
|
SkPaint blurPaint(paint);
|
2018-03-14 17:01:17 +00:00
|
|
|
blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma));
|
2015-05-11 21:52:11 +00:00
|
|
|
|
|
|
|
SkTextBlobBuilder builder;
|
|
|
|
|
|
|
|
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
|
|
|
|
|
2016-09-13 17:00:23 +00:00
|
|
|
sk_sp<SkTextBlob> blob(builder.make());
|
|
|
|
canvas->drawTextBlob(blob, 10, 200, blurPaint);
|
|
|
|
canvas->drawTextBlob(blob, 10, 200, paint);
|
2015-05-11 21:52:11 +00:00
|
|
|
|
|
|
|
size_t len = strlen(text);
|
|
|
|
canvas->drawText(text, len, 10, 500, blurPaint);
|
|
|
|
canvas->drawText(text, len, 10, 500, paint);
|
|
|
|
}
|