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

Unified Diff: gm/stroketext.cpp

Issue 293983016: update stroketext gm (Closed) Base URL: https://skia.googlecode.com/svn/trunk
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 | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/stroketext.cpp
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp
index 387843a0b43f8f83bde67dde87b1b246c4a95319..80c63fdc37763b1cc0b0826650bb0d96377e2edc 100644
--- a/gm/stroketext.cpp
+++ b/gm/stroketext.cpp
@@ -7,6 +7,7 @@
#include "gm.h"
#include "SkCanvas.h"
+#include "SkDashPathEffect.h"
static void test_nulldev(SkCanvas* canvas) {
SkBitmap bm;
@@ -23,21 +24,41 @@ static void test_nulldev(SkCanvas* canvas) {
c.writePixels(src, 0, 0);
}
-static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint) {
+static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint, SkScalar strokeWidth) {
SkPaint p(paint);
- SkPoint loc = { 20, 450 };
+ SkPoint loc = { 20, 435 };
- canvas->drawText("P", 1, loc.fX, loc.fY - 225, p);
- canvas->drawPosText("P", 1, &loc, p);
+ if (strokeWidth > 0) {
+ p.setStyle(SkPaint::kFill_Style);
+ canvas->drawText("P", 1, loc.fX, loc.fY - 225, p);
+ canvas->drawPosText("P", 1, &loc, p);
+ }
p.setColor(SK_ColorRED);
p.setStyle(SkPaint::kStroke_Style);
- p.setStrokeWidth(10);
+ p.setStrokeWidth(strokeWidth);
canvas->drawText("P", 1, loc.fX, loc.fY - 225, p);
canvas->drawPosText("P", 1, &loc, p);
}
+static void draw_text_set(SkCanvas* canvas, const SkPaint& paint) {
+ SkAutoCanvasRestore acr(canvas, true);
+
+ draw_text_stroked(canvas, paint, 10);
+
+ canvas->translate(200, 0);
+ draw_text_stroked(canvas, paint, 0);
+
+ const SkScalar intervals[] = { 20, 10, 5, 10 };
+ const SkScalar phase = 0;
+
+ canvas->translate(200, 0);
+ SkPaint p(paint);
+ p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), phase))->unref();
+ draw_text_stroked(canvas, paint, 10);
+}
+
class StrokeTextGM : public skiagm::GM {
// Skia has a threshold above which it draws text via paths instead of using scalercontext
// and caching the glyph. This GM wants to ensure that we draw stroking correctly on both
@@ -59,7 +80,7 @@ protected:
}
virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(640, 480);
+ return SkISize::Make(1200, 480);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
@@ -68,11 +89,11 @@ protected:
paint.setAntiAlias(true);
paint.setTextSize(kBelowThreshold_TextSize);
- draw_text_stroked(canvas, paint);
+ draw_text_set(canvas, paint);
- canvas->translate(200, 0);
+ canvas->translate(600, 0);
paint.setTextSize(kAboveThreshold_TextSize);
- draw_text_stroked(canvas, paint);
+ draw_text_set(canvas, paint);
}
private:
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698