aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/largeglyphblur.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-05-11 14:52:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-11 14:52:12 -0700
commit1107e901c9dac3098e2915213f171ff62d007aa7 (patch)
treea8ba4a007f6d008f93aa307bef55f574e7bf7627 /gm/largeglyphblur.cpp
parentc6325cde797baeedebc515bc8610f96eacbd36c9 (diff)
Fix blur on large glyphs in runs < SkGlyphCache::max
Diffstat (limited to 'gm/largeglyphblur.cpp')
-rw-r--r--gm/largeglyphblur.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/gm/largeglyphblur.cpp b/gm/largeglyphblur.cpp
new file mode 100644
index 0000000000..8723824e13
--- /dev/null
+++ b/gm/largeglyphblur.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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
+namespace skiagm {
+class LargeGlyphBlur : public GM {
+public:
+ LargeGlyphBlur() {}
+
+protected:
+ SkString onShortName() override {
+ return SkString("largeglyphblur");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(kWidth, kHeight);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ const char text[] = "Hamburgefons";
+
+ SkPaint paint;
+ sk_tool_utils::set_portable_typeface(&paint);
+ paint.setTextSize(256);
+ paint.setAntiAlias(true);
+
+ // setup up maskfilter
+ static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40));
+
+ SkPaint blurPaint(paint);
+ SkAutoTUnref<SkMaskFilter> mf(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, kSigma));
+ blurPaint.setMaskFilter(mf);
+
+ 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);
+ }
+
+private:
+ static const int kWidth = 1920;
+ static const int kHeight = 600;
+
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM( return SkNEW(LargeGlyphBlur); )
+}