skia2/gm/largeglyphblur.cpp
mtklein dbfd7ab108 Replace a lot of 'static const' with 'constexpr' or 'const'.
'static const' means, there must be at most one of these, and initialize it at
compile time if possible or runtime if necessary.  This leads to unexpected
code execution, and TSAN* will complain about races on the guard variables.

Generally 'constexpr' or 'const' are better choices.  Neither can cause races:
they're either intialized at compile time (constexpr) or intialized each time
independently (const).

This CL prefers constexpr where possible, and uses const where not.  It even
prefers constexpr over const where they don't make a difference... I want to have
lots of examples of constexpr for people to see and mimic.

The scoped-to-class static has nothing to do with any of this, and is not changed.

* Not yet on the bots, which use an older TSAN.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2300623005

Review-Url: https://codereview.chromium.org/2300623005
2016-09-01 11:24:54 -07:00

43 lines
1.3 KiB
C++

/*
* 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"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#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
DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
const char text[] = "Hamburgefons";
SkPaint paint;
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(256);
paint.setAntiAlias(true);
// setup up maskfilter
const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
SkPaint blurPaint(paint);
blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma));
SkTextBlobBuilder builder;
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
SkAutoTUnref<const SkTextBlob> blob(builder.build());
canvas->drawTextBlob(blob.get(), 10, 200, blurPaint);
canvas->drawTextBlob(blob.get(), 10, 200, paint);
size_t len = strlen(text);
canvas->drawText(text, len, 10, 500, blurPaint);
canvas->drawText(text, len, 10, 500, paint);
}