From 2a475eae622adc1e8fa29206be1eaf862c23548e Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 28 Apr 2017 15:35:12 -0400 Subject: 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 Reviewed-by: Cary Clark Reviewed-by: Mike Reed Reviewed-by: Cary Clark --- gm/tilemodes_scaled.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gm/tilemodes_scaled.cpp') diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp index 807d63b369..3833fa2943 100644 --- a/gm/tilemodes_scaled.cpp +++ b/gm/tilemodes_scaled.cpp @@ -107,7 +107,7 @@ protected: str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); p.setTextAlign(SkPaint::kCenter_Align); - canvas->drawText(str.c_str(), str.size(), scale*(x + r.width()/2), y, p); + canvas->drawString(str, scale*(x + r.width()/2), y, p); x += r.width() * 4 / 3; } @@ -145,7 +145,7 @@ protected: p.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&p); str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); - canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y + r.height() * 2 / 3), p); + canvas->drawString(str, scale*x, scale*(y + r.height() * 2 / 3), p); } y += r.height() * 4 / 3; @@ -228,7 +228,7 @@ protected: for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { SkString str(gModeNames[kx]); - canvas->drawText(str.c_str(), str.size(), x + r.width()/2, y, p); + canvas->drawString(str, x + r.width()/2, y, p); x += r.width() * 4 / 3; } @@ -239,7 +239,7 @@ protected: x = SkIntToScalar(16) + w; SkString str(gModeNames[ky]); - canvas->drawText(str.c_str(), str.size(), x, y + h/2, p); + canvas->drawString(str, x, y + h/2, p); x += SkIntToScalar(50); for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { -- cgit v1.2.3