diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-12 20:31:24 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-12 20:31:24 +0000 |
commit | 641e33b3f6014b193856ba5789b1a0278a92e083 (patch) | |
tree | ac7a272220a9f073bf1c1e3c20ddb1a8d69ebf91 /gm/stroketext.cpp | |
parent | e54a23fcfa42b2fc9d320650de72bcb2d9566b2d (diff) |
add gm to show bug in stroked-text in drawPosText
BUG=skia:
R=fmalita@google.com, bungeman@google.com, fmalita@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/198083003
git-svn-id: http://skia.googlecode.com/svn/trunk@13777 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/stroketext.cpp')
-rw-r--r-- | gm/stroketext.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp new file mode 100644 index 0000000000..e6ffa0ec85 --- /dev/null +++ b/gm/stroketext.cpp @@ -0,0 +1,62 @@ +/* + * 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 "SkCanvas.h" + +static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint) { + SkPaint p(paint); + SkPoint loc = { 20, 450 }; + + 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); + + canvas->drawText("P", 1, loc.fX, loc.fY - 225, p); + canvas->drawPosText("P", 1, &loc, p); +} + +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 + // sides of this threshold. + enum { + kBelowThreshold_TextSize = 255, + kAboveThreshold_TextSize = 257 + }; +public: + StrokeTextGM() {} + +protected: + virtual SkString onShortName() SK_OVERRIDE { + return SkString("stroketext"); + } + + virtual SkISize onISize() SK_OVERRIDE { + return SkISize::Make(640, 480); + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + SkPaint paint; + paint.setAntiAlias(true); + + paint.setTextSize(kBelowThreshold_TextSize); + draw_text_stroked(canvas, paint); + + canvas->translate(200, 0); + paint.setTextSize(kAboveThreshold_TextSize); + draw_text_stroked(canvas, paint); + } + +private: + typedef skiagm::GM INHERITED; +}; + +DEF_GM( return SkNEW(StrokeTextGM); ) |