Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: gm/patheffect4bigtext.cpp

Issue 290443004: add a GM case to ensure path effect for big filled/stroked text is correctly rendered (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/patheffect4bigtext.cpp
diff --git a/gm/patheffect4bigtext.cpp b/gm/patheffect4bigtext.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b090674678929761f6f1269b859db5e38daf8378
--- /dev/null
+++ b/gm/patheffect4bigtext.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "Sk2DPathEffect.h"
+#include "SkCanvas.h"
+
+// PathEffect for a text impacts the paths generated for the text. Big text
+// and hairline text are drawn by paths, instead of using scalercontext and
+// caching the glyph. This GM wants to ensure that we draw filled, thick-stroked,
+// and hairline-stroked text with path effect correctly on both sides of the
+// threshold.
+static void draw_text(SkCanvas* canvas, const SkPaint& paint) {
+ SkPaint p(paint);
+
+ SkPoint loc = { 250, 225 };
+ p.setColor(SK_ColorRED);
+
+ canvas->drawText("P", 1, loc.fX - 225, loc.fY, p);
+ canvas->drawPosText("P", 1, &loc, p);
+
+ loc.set(250, 450);
+ p.setColor(SK_ColorGREEN);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(10);
+ canvas->drawText("P", 1, loc.fX - 225, loc.fY, p);
+ canvas->drawPosText("P", 1, &loc, p);
+
+ loc.set(250, 675);
+ p.setColor(SK_ColorBLUE);
+ p.setStrokeWidth(0);
+ canvas->drawText("P", 1, loc.fX - 225, loc.fY, p);
+ canvas->drawPosText("P", 1, &loc, p);
+}
+
+class PathEffect4BigTextGM : public skiagm::GM {
+public:
+ PathEffect4BigTextGM() {}
+
+protected:
+ virtual uint32_t onGetFlags() const SK_OVERRIDE {
+ return kSkipTiled_Flag;
+ }
+
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("patheffect4bigtext");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(900, 700);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+
+ SkMatrix lattice;
+ lattice.setScale(SK_Scalar1, SK_Scalar1 * 6, 0, 0);
+ lattice.postRotate(SkIntToScalar(30), 0, 0);
+ paint.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1 * 2, lattice))->unref();
+
+ SkScalar textSize[2] = {240, 270};
+ for (size_t i = 0; i < SK_ARRAY_COUNT(textSize); ++i) {
+ paint.setTextSize(textSize[i]);
+ draw_text(canvas, paint);
+ canvas->translate(450, 0);
+ }
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(PathEffect4BigTextGM); )
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698