diff options
author | Cary Clark <caryclark@google.com> | 2017-04-28 15:35:12 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-28 20:41:04 +0000 |
commit | 2a475eae622adc1e8fa29206be1eaf862c23548e (patch) | |
tree | 6bad5dbe2ef7aad1c7e657df6bd8cfe3a752c5fd /gm/lcdtext.cpp | |
parent | ec138b40ba940ab0d76b5550ee2c5505629c5293 (diff) |
add drawString helper to canvas
Many tests and examples use drawText with
a guess of how long the text is in bytes,
or a call to strlen(). Add a helper to
SkCanvas to simplify these examples.
Add another helper for SkString.
R=reed@google.com
Change-Id: I0204a31e938f065606f08ee7cd9a6b36db791ee2
Reviewed-on: https://skia-review.googlesource.com/13642
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'gm/lcdtext.cpp')
-rw-r--r-- | gm/lcdtext.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp index 5a549eb74c..41e83d68fd 100644 --- a/gm/lcdtext.cpp +++ b/gm/lcdtext.cpp @@ -58,7 +58,7 @@ protected: paint.setLCDRenderText(lcdRenderTextEnabled); paint.setTextSize(textHeight); - canvas->drawText(string.c_str(), string.size(), 0, y, paint); + canvas->drawString(string, 0, y, paint); y += textHeight; } @@ -120,7 +120,7 @@ protected: paint.setTextSize(rec[i].fTextSize); ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y()); - canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y(), paint); + canvas->drawString(rec[i].fText, loc.x(), loc.y(), paint); } } @@ -138,7 +138,7 @@ DEF_SIMPLE_GM(savelayer_lcdtext, canvas, 620, 260) { paint.setLCDRenderText(true); paint.setTextSize(20); - canvas->drawText("Hamburgefons", 12, 30, 30, paint); + canvas->drawString("Hamburgefons", 30, 30, paint); const bool gPreserveLCDText[] = { false, true }; @@ -149,15 +149,15 @@ DEF_SIMPLE_GM(savelayer_lcdtext, canvas, 620, 260) { if (preserve) { SkPaint noLCD = paint; noLCD.setLCDRenderText(false); - canvas->drawText("LCD not supported", 17, 30, 60, noLCD); + canvas->drawString("LCD not supported", 30, 60, noLCD); } else { - canvas->drawText("Hamburgefons", 12, 30, 60, paint); + canvas->drawString("Hamburgefons", 30, 60, paint); } SkPaint p; p.setColor(0xFFCCCCCC); canvas->drawRect(SkRect::MakeLTRB(25, 70, 200, 100), p); - canvas->drawText("Hamburgefons", 12, 30, 90, paint); + canvas->drawString("Hamburgefons", 30, 90, paint); canvas->restore(); canvas->translate(0, 80); |