update stroketext gm

TBR=bungeman

Author: reed@google.com

Review URL: https://codereview.chromium.org/293983016

git-svn-id: http://skia.googlecode.com/svn/trunk@14848 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-22 17:41:41 +00:00
parent df1d83d786
commit 74266814a0
2 changed files with 34 additions and 9 deletions

View File

@ -64,3 +64,7 @@ tilemodes
shadertext3
shadertext
shadertext2
# Changing this GM to add more test cases (failing at the moment)
# Need to rebaseline when they are fixed
stroketext

View File

@ -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: