diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp index 9edf21476ccf..3dd79658f294 100644 --- a/bench/DisplacementBench.cpp +++ b/bench/DisplacementBench.cpp @@ -40,7 +40,7 @@ class DisplacementBaseBench : public Benchmark { paint.setColor(0xFF884422); paint.setTextSize(SkIntToScalar(96)); const char* str = "g"; - canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint); + canvas.drawString(str, SkIntToScalar(15), SkIntToScalar(55), paint); } void makeCheckerboard() { diff --git a/bench/FontScalerBench.cpp b/bench/FontScalerBench.cpp index a5ab7b5e7f28..366c54c30c9b 100644 --- a/bench/FontScalerBench.cpp +++ b/bench/FontScalerBench.cpp @@ -37,7 +37,7 @@ class FontScalerBench : public Benchmark { for (int ps = 9; ps <= 24; ps += 2) { paint.setTextSize(SkIntToScalar(ps)); - canvas->drawText(fText.c_str(), fText.size(), + canvas->drawString(fText, 0, SkIntToScalar(20), paint); } } diff --git a/bench/MergeBench.cpp b/bench/MergeBench.cpp index 8b6004df1bcf..c37d198f7b5b 100644 --- a/bench/MergeBench.cpp +++ b/bench/MergeBench.cpp @@ -24,7 +24,7 @@ static sk_sp make_bitmap() { paint.setColor(0xFF884422); paint.setTextSize(SkIntToScalar(96)); const char* str = "g"; - surface->getCanvas()->drawText(str, strlen(str), 15, 55, paint); + surface->getCanvas()->drawString(str, 15, 55, paint); return surface->makeImageSnapshot(); } diff --git a/bench/ShaderMaskBench.cpp b/bench/ShaderMaskBench.cpp index 90a5037f05a8..8fd99b653688 100644 --- a/bench/ShaderMaskBench.cpp +++ b/bench/ShaderMaskBench.cpp @@ -71,14 +71,14 @@ class ShaderMaskBench : public Benchmark { for (int i = 0; i < loops; i++) { SkScalar x = x0 + rand.nextUScalar1() * dim.fX; SkScalar y = y0 + rand.nextUScalar1() * dim.fY; - canvas->drawText(fText.c_str(), fText.size(), x, y, paint); + canvas->drawString(fText, x, y, paint); } paint.setTextSize(SkIntToScalar(48)); for (int i = 0; i < loops / 4 ; i++) { SkScalar x = x0 + rand.nextUScalar1() * dim.fX; SkScalar y = y0 + rand.nextUScalar1() * dim.fY; - canvas->drawText(fText.c_str(), fText.size(), x, y, paint); + canvas->drawString(fText, x, y, paint); } } diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp index f4a7cddbae50..6e9df4afc7e8 100644 --- a/bench/TextBench.cpp +++ b/bench/TextBench.cpp @@ -140,7 +140,7 @@ class TextBench : public Benchmark { } else { SkScalar x = x0 + rand.nextUScalar1() * dim.fX; SkScalar y = y0 + rand.nextUScalar1() * dim.fY; - canvas->drawText(fText.c_str(), fText.size(), x, y, paint); + canvas->drawString(fText, x, y, paint); } } } diff --git a/fuzz/FilterFuzz.cpp b/fuzz/FilterFuzz.cpp index 312f9321d4c2..cf65701d364b 100644 --- a/fuzz/FilterFuzz.cpp +++ b/fuzz/FilterFuzz.cpp @@ -239,7 +239,7 @@ static void make_g_bitmap(SkBitmap& bitmap) { paint.setColor(0xFF884422); paint.setTextSize(SkIntToScalar(kBitmapSize/2)); const char* str = "g"; - canvas.drawText(str, strlen(str), SkIntToScalar(kBitmapSize/8), + canvas.drawString(str, SkIntToScalar(kBitmapSize/8), SkIntToScalar(kBitmapSize/4), paint); } @@ -325,7 +325,7 @@ static void drawSomething(SkCanvas* canvas) { canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint); paint.setColor(SK_ColorBLACK); paint.setTextSize(SkIntToScalar(kBitmapSize/3)); - canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); + canvas->drawString("Picture", SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); } static sk_sp make_color_filter() { diff --git a/gm/aaxfermodes.cpp b/gm/aaxfermodes.cpp index 96b9b4880b2c..eab68b4e81d8 100644 --- a/gm/aaxfermodes.cpp +++ b/gm/aaxfermodes.cpp @@ -107,10 +107,10 @@ class AAXfermodesGM : public skiagm::GM { if (kShape_Pass == drawingPass) { fLabelPaint.setTextAlign(SkPaint::kCenter_Align); - canvas->drawText("Src Unknown", sizeof("Src Unknown") - 1, + canvas->drawString("Src Unknown", kLabelSpacing + kShapeTypeSpacing * 1.5f + kShapeSpacing / 2, kSubtitleSpacing / 2 + fLabelPaint.getTextSize() / 3, fLabelPaint); - canvas->drawText("Src Opaque", sizeof("Src Opaque") - 1, + canvas->drawString("Src Opaque", kLabelSpacing + kShapeTypeSpacing * 1.5f + kShapeSpacing / 2 + kPaintSpacing, kSubtitleSpacing / 2 + fLabelPaint.getTextSize() / 3, fLabelPaint); @@ -180,10 +180,10 @@ class AAXfermodesGM : public skiagm::GM { titlePaint.setTextSize(9 * titlePaint.getTextSize() / 8); titlePaint.setFakeBoldText(true); titlePaint.setTextAlign(SkPaint::kCenter_Align); - canvas->drawText("Porter Duff", sizeof("Porter Duff") - 1, + canvas->drawString("Porter Duff", kLabelSpacing + 4 * kShapeTypeSpacing, kTitleSpacing / 2 + titlePaint.getTextSize() / 3, titlePaint); - canvas->drawText("Advanced", sizeof("Advanced") - 1, + canvas->drawString("Advanced", kXfermodeTypeSpacing + kLabelSpacing + 4 * kShapeTypeSpacing, kTitleSpacing / 2 + titlePaint.getTextSize() / 3, titlePaint); @@ -194,7 +194,7 @@ class AAXfermodesGM : public skiagm::GM { void drawModeName(SkCanvas* canvas, SkBlendMode mode) { const char* modeName = SkBlendMode_Name(mode); fLabelPaint.setTextAlign(SkPaint::kRight_Align); - canvas->drawText(modeName, strlen(modeName), kLabelSpacing - kShapeSize / 4, + canvas->drawString(modeName, kLabelSpacing - kShapeSize / 4, fLabelPaint.getTextSize() / 4, fLabelPaint); } diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index 98d6621c6ba3..4c8ea359f160 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -150,7 +150,7 @@ static void draw(SkCanvas* canvas, const char text[]) { SkASSERT(src.colorType() == colorType); canvas->drawBitmap(src, 0.0f, 0.0f); - canvas->drawText(text, strlen(text), 0.0f, 12.0f, p); + canvas->drawString(text, 0.0f, 12.0f, p); } DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) { diff --git a/gm/animatedGif.cpp b/gm/animatedGif.cpp index dd08abfd36b8..5f4fe71cb0f6 100644 --- a/gm/animatedGif.cpp +++ b/gm/animatedGif.cpp @@ -27,7 +27,7 @@ namespace { SkPaint paint; SkRect bounds; paint.measureText(errorText.c_str(), errorText.size(), &bounds); - canvas->drawText(errorText.c_str(), errorText.size(), kOffset, bounds.height() + kOffset, + canvas->drawString(errorText, kOffset, bounds.height() + kOffset, paint); } } diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp index c01ece7990ff..54169ceef657 100644 --- a/gm/arithmode.cpp +++ b/gm/arithmode.cpp @@ -60,7 +60,7 @@ static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar SkString str; str.appendScalar(k[i]); SkScalar width = paint.measureText(str.c_str(), str.size()); - canvas->drawText(str.c_str(), str.size(), x, y + paint.getTextSize(), paint); + canvas->drawString(str, x, y + paint.getTextSize(), paint); x += width + SkIntToScalar(10); } } @@ -152,7 +152,7 @@ class ArithmodeGM : public skiagm::GM { paint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&paint); SkString str(enforcePMColor ? "enforcePM" : "no enforcePM"); - canvas->drawText(str.c_str(), str.size(), 0, paint.getTextSize(), paint); + canvas->drawString(str, 0, paint.getTextSize(), paint); } canvas->translate(0, HH + 12); } diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp index 4d5005e2da9e..6b3c9b11cbc8 100644 --- a/gm/bigtext.cpp +++ b/gm/bigtext.cpp @@ -43,7 +43,7 @@ class BigTextGM : public skiagm::GM { }; paint.setColor(SK_ColorRED); - canvas->drawText("/", 1, pos.fX, pos.fY, paint); + canvas->drawString("/", pos.fX, pos.fY, paint); paint.setColor(SK_ColorBLUE); canvas->drawPosText("\\", 1, &pos, paint); diff --git a/gm/bitmapcopy.cpp b/gm/bitmapcopy.cpp index 64f11368ad74..ec9e423d12e6 100644 --- a/gm/bitmapcopy.cpp +++ b/gm/bitmapcopy.cpp @@ -101,7 +101,7 @@ class BitmapCopyGM : public GM { SkScalar textWidth = paint.measureText(name, strlen(name)); SkScalar x = (width - textWidth) / SkScalar(2); SkScalar y = paint.getFontSpacing() / SkScalar(2); - canvas->drawText(name, strlen(name), x, y, paint); + canvas->drawString(name, x, y, paint); // Draw destination bitmap canvas->translate(0, vertOffset); diff --git a/gm/bitmapfilters.cpp b/gm/bitmapfilters.cpp index b99ab1059f13..4d31cae4213a 100644 --- a/gm/bitmapfilters.cpp +++ b/gm/bitmapfilters.cpp @@ -52,7 +52,7 @@ static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { paint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&paint); const char* name = sk_tool_utils::colortype_name(bm.colorType()); - canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8, + canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8, paint); canvas->translate(SkIntToScalar(48), 0); diff --git a/gm/blurs.cpp b/gm/blurs.cpp index f1f44e72322c..a7b1a5f769f7 100644 --- a/gm/blurs.cpp +++ b/gm/blurs.cpp @@ -55,14 +55,14 @@ DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, sk_tool_utils::color_to_565(0xFFDDDDDD SkScalar x = SkIntToScalar(70); SkScalar y = SkIntToScalar(400); paint.setColor(SK_ColorBLACK); - canvas->drawText("Hamburgefons Style", 18, x, y, paint); - canvas->drawText("Hamburgefons Style", 18, + canvas->drawString("Hamburgefons Style", x, y, paint); + canvas->drawString("Hamburgefons Style", x, y + SkIntToScalar(50), paint); paint.setMaskFilter(nullptr); paint.setColor(SK_ColorWHITE); x -= SkIntToScalar(2); y -= SkIntToScalar(2); - canvas->drawText("Hamburgefons Style", 18, x, y, paint); + canvas->drawString("Hamburgefons Style", x, y, paint); } canvas->restore(); flags = SkBlurMaskFilter::kHighQuality_BlurFlag; diff --git a/gm/bmpfilterqualityrepeat.cpp b/gm/bmpfilterqualityrepeat.cpp index e7ea97db9633..313fd9336bed 100644 --- a/gm/bmpfilterqualityrepeat.cpp +++ b/gm/bmpfilterqualityrepeat.cpp @@ -76,7 +76,7 @@ class BmpFilterQualityRepeat : public skiagm::GM { bmpPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTM, kTM, &lm)); bmpPaint.setFilterQuality(kQualities[q].fQuality); canvas->drawRect(rect, bmpPaint); - canvas->drawText(kQualities[q].fName, strlen(kQualities[q].fName), 20, 40, textPaint); + canvas->drawString(kQualities[q].fName, 20, 40, textPaint); canvas->translate(250, 0); } diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp index f871e53d55e1..7626f9a0711b 100644 --- a/gm/coloremoji.cpp +++ b/gm/coloremoji.cpp @@ -88,7 +88,7 @@ class ColorEmojiGM : public GM { paint.setTextSize(textSize); paint.getFontMetrics(&metrics); y += -metrics.fAscent; - canvas->drawText(text, strlen(text), 10, y, paint); + canvas->drawString(text, 10, y, paint); y += metrics.fDescent + metrics.fLeading; } @@ -124,7 +124,7 @@ class ColorEmojiGM : public GM { shaderPaint.setTextSize(30); shaderPaint.getFontMetrics(&metrics); y += -metrics.fAscent; - canvas->drawText(text, strlen(text), 380, y, shaderPaint); + canvas->drawString(text, 380, y, shaderPaint); y += metrics.fDescent + metrics.fLeading; } } @@ -162,10 +162,10 @@ class ColorEmojiGM : public GM { canvas->save(); canvas->drawRect(clipRect, clipHairline); paint.setAlpha(0x20); - canvas->drawText(text, strlen(text), 0, 0, paint); + canvas->drawString(text, 0, 0, paint); canvas->clipRect(clipRect); paint.setAlpha(0xFF); - canvas->drawText(text, strlen(text), 0, 0, paint); + canvas->drawString(text, 0, 0, paint); canvas->restore(); canvas->translate(0, SkIntToScalar(25)); } diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp index d7e8b6c81ea8..ee3db7671d78 100644 --- a/gm/coloremoji_blendmodes.cpp +++ b/gm/coloremoji_blendmodes.cpp @@ -138,7 +138,7 @@ class ColorEmojiBlendModesGM : public GM { } #if 1 const char* label = SkBlendMode_Name(gModes[i]); - canvas->drawText(label, strlen(label), x + w/2, y - labelP.getTextSize()/2, labelP); + canvas->drawString(label, x + w/2, y - labelP.getTextSize()/2, labelP); #endif x += w + SkIntToScalar(10); if ((i % W) == W - 1) { diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp index a1ca021b1628..b938cd508875 100644 --- a/gm/colorwheel.cpp +++ b/gm/colorwheel.cpp @@ -46,17 +46,17 @@ DEF_SIMPLE_GM(colorwheelnative, canvas, 128, 28) { canvas->clear(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); paint.setColor(SK_ColorRED); - canvas->drawText("R", 1, 8.0f, 20.0f, paint); + canvas->drawString("R", 8.0f, 20.0f, paint); paint.setColor(SK_ColorGREEN); - canvas->drawText("G", 1, 24.0f, 20.0f, paint); + canvas->drawString("G", 24.0f, 20.0f, paint); paint.setColor(SK_ColorBLUE); - canvas->drawText("B", 1, 40.0f, 20.0f, paint); + canvas->drawString("B", 40.0f, 20.0f, paint); paint.setColor(SK_ColorCYAN); - canvas->drawText("C", 1, 56.0f, 20.0f, paint); + canvas->drawString("C", 56.0f, 20.0f, paint); paint.setColor(SK_ColorMAGENTA); - canvas->drawText("M", 1, 72.0f, 20.0f, paint); + canvas->drawString("M", 72.0f, 20.0f, paint); paint.setColor(SK_ColorYELLOW); - canvas->drawText("Y", 1, 88.0f, 20.0f, paint); + canvas->drawString("Y", 88.0f, 20.0f, paint); paint.setColor(SK_ColorBLACK); - canvas->drawText("K", 1, 104.0f, 20.0f, paint); + canvas->drawString("K", 104.0f, 20.0f, paint); } diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp index 296871581db3..ae9c4db31f22 100644 --- a/gm/complexclip.cpp +++ b/gm/complexclip.cpp @@ -151,15 +151,14 @@ class ComplexClipGM : public GM { SkScalar txtX = SkIntToScalar(45); paint.setColor(gClipAColor); const char* aTxt = doInvA ? "InvA " : "A "; - canvas->drawText(aTxt, strlen(aTxt), txtX, SkIntToScalar(220), paint); + canvas->drawString(aTxt, txtX, SkIntToScalar(220), paint); txtX += paint.measureText(aTxt, strlen(aTxt)); paint.setColor(SK_ColorBLACK); - canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), - txtX, SkIntToScalar(220), paint); + canvas->drawString(gOps[op].fName, txtX, SkIntToScalar(220), paint); txtX += paint.measureText(gOps[op].fName, strlen(gOps[op].fName)); paint.setColor(gClipBColor); const char* bTxt = doInvB ? "InvB " : "B "; - canvas->drawText(bTxt, strlen(bTxt), txtX, SkIntToScalar(220), paint); + canvas->drawString(bTxt, txtX, SkIntToScalar(220), paint); canvas->translate(SkIntToScalar(250),0); } diff --git a/gm/complexclip3.cpp b/gm/complexclip3.cpp index 47b80ab7add9..7c5c67212860 100644 --- a/gm/complexclip3.cpp +++ b/gm/complexclip3.cpp @@ -103,8 +103,7 @@ class ComplexClip3GM : public GM { doAAB ? "A" : "B", doInvB ? "I" : "N"); - canvas->drawText(str.c_str(), strlen(str.c_str()), txtX, SkIntToScalar(130), - paint); + canvas->drawString(str.c_str(), txtX, SkIntToScalar(130), paint); if (doInvB) { canvas->translate(SkIntToScalar(150),0); } else { diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp index a595a07d3890..2e0fde2861b6 100644 --- a/gm/constcolorprocessor.cpp +++ b/gm/constcolorprocessor.cpp @@ -135,7 +135,7 @@ class ConstColorProcessor : public GM { // get the bounds of the text in order to position it labelPaint.measureText(inputLabel.c_str(), inputLabel.size(), &inputLabelBounds); - canvas->drawText(inputLabel.c_str(), inputLabel.size(), + canvas->drawString(inputLabel, renderRect.fRight + kPad, -inputLabelBounds.fTop, labelPaint); // update the bounds to reflect the offset we used to draw it. @@ -144,7 +144,7 @@ class ConstColorProcessor : public GM { SkRect procLabelBounds; labelPaint.measureText(procLabel.c_str(), procLabel.size(), &procLabelBounds); - canvas->drawText(procLabel.c_str(), procLabel.size(), + canvas->drawString(procLabel, renderRect.fRight + kPad, inputLabelBounds.fBottom + 2.f - procLabelBounds.fTop, labelPaint); diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp index fd2156c1d767..6bbcd9012bca 100644 --- a/gm/cubicpaths.cpp +++ b/gm/cubicpaths.cpp @@ -202,10 +202,10 @@ class CubicPathGM : public skiagm::GM { titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Cubic Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, with stroke width 10"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -244,18 +244,15 @@ class CubicPathGM : public skiagm::GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(gCaps[cap].fName, - strlen(gCaps[cap].fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(gCaps[cap].fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); } canvas->restore(); } @@ -347,10 +344,10 @@ class CubicClosePathGM : public skiagm::GM { titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Cubic Closed Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, with stroke width 10"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -389,18 +386,15 @@ class CubicClosePathGM : public skiagm::GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(gCaps[cap].fName, - strlen(gCaps[cap].fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(gCaps[cap].fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); } canvas->restore(); } diff --git a/gm/dashing.cpp b/gm/dashing.cpp index 13d45cb913a9..b527fbf987a2 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -543,7 +543,7 @@ DEF_SIMPLE_GM(dashtextcaps, canvas, 512, 512) { sk_tool_utils::set_portable_typeface(&p); const SkScalar intervals[] = { 12, 12 }; p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); - canvas->drawText("Sausages", 8, 10, 90, p); + canvas->drawString("Sausages", 10, 90, p); canvas->drawLine(8, 120, 456, 120, p); } diff --git a/gm/degeneratesegments.cpp b/gm/degeneratesegments.cpp index 25da045bc474..9de66ea9ea2c 100644 --- a/gm/degeneratesegments.cpp +++ b/gm/degeneratesegments.cpp @@ -294,10 +294,10 @@ class DegenerateSegmentsGM : public GM { const char title[] = "Random Paths Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, " "with Stroke width 6"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(220*SK_Scalar1, 50*SK_Scalar1); @@ -351,38 +351,30 @@ class DegenerateSegmentsGM : public GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(style.fName, - strlen(style.fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(fill.fName, - strlen(fill.fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(cap.fName, - strlen(cap.fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); - canvas->drawText(gSegmentNames[s1], - strlen(gSegmentNames[s1]), - 0, rect.height() + 48 * SK_Scalar1, - labelPaint); - canvas->drawText(gSegmentNames[s2], - strlen(gSegmentNames[s2]), - 0, rect.height() + 60 * SK_Scalar1, - labelPaint); - canvas->drawText(gSegmentNames[s3], - strlen(gSegmentNames[s3]), - 0, rect.height() + 72 * SK_Scalar1, - labelPaint); - canvas->drawText(gSegmentNames[s4], - strlen(gSegmentNames[s4]), - 0, rect.height() + 84 * SK_Scalar1, - labelPaint); - canvas->drawText(gSegmentNames[s5], - strlen(gSegmentNames[s5]), - 0, rect.height() + 96 * SK_Scalar1, - labelPaint); + canvas->drawString(style.fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(fill.fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(cap.fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); + canvas->drawString(gSegmentNames[s1], + 0, rect.height() + 48 * SK_Scalar1, + labelPaint); + canvas->drawString(gSegmentNames[s2], + 0, rect.height() + 60 * SK_Scalar1, + labelPaint); + canvas->drawString(gSegmentNames[s3], + 0, rect.height() + 72 * SK_Scalar1, + labelPaint); + canvas->drawString(gSegmentNames[s4], + 0, rect.height() + 84 * SK_Scalar1, + labelPaint); + canvas->drawString(gSegmentNames[s5], + 0, rect.height() + 96 * SK_Scalar1, + labelPaint); } canvas->restore(); } diff --git a/gm/dftext.cpp b/gm/dftext.cpp index fb69f9b4e171..6067327b810d 100644 --- a/gm/dftext.cpp +++ b/gm/dftext.cpp @@ -187,7 +187,7 @@ class DFTextGM : public skiagm::GM { if (fEmojiTypeface) { paint.setTypeface(fEmojiTypeface); paint.setTextSize(SkIntToScalar(19)); - canvas->drawText(fEmojiText, strlen(fEmojiText), 670, 90, paint); + canvas->drawString(fEmojiText, 670, 90, paint); } #if SK_SUPPORT_GPU // render offscreen buffer diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp index ba1edc9835c7..fefc94bd57bf 100644 --- a/gm/downsamplebitmap.cpp +++ b/gm/downsamplebitmap.cpp @@ -127,13 +127,13 @@ class DownsampleBitmapTextGM: public DownsampleBitmapGM { paint.setTextSize(fTextSize); setTypeface(&paint, "serif", SkFontStyle()); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 1.2f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 2.4f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 3.6f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, paint); } private: typedef DownsampleBitmapGM INHERITED; diff --git a/gm/drawatlascolor.cpp b/gm/drawatlascolor.cpp index de64caba806a..548641b35424 100644 --- a/gm/drawatlascolor.cpp +++ b/gm/drawatlascolor.cpp @@ -138,7 +138,7 @@ class DrawAtlasColorsGM : public skiagm::GM { for (int i = 0; i < numModes; ++i) { const char* label = SkBlendMode_Name(gModes[i]); - canvas->drawText(label, strlen(label), + canvas->drawString(label, i*(target.width()+kPad)+kPad, SkIntToScalar(kTextPad), textP); } diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp index 0becf45183d6..2cd1b2f93ea7 100644 --- a/gm/drawbitmaprect.cpp +++ b/gm/drawbitmaprect.cpp @@ -180,7 +180,7 @@ class DrawBitmapRectGM : public skiagm::GM { sk_tool_utils::set_portable_typeface(&blackPaint); SkString title; title.printf("Bitmap size: %d x %d", gBmpSize, gBmpSize); - canvas->drawText(title.c_str(), title.size(), 0, + canvas->drawString(title, 0, titleHeight, blackPaint); canvas->translate(0, SK_Scalar1 * kPadY / 2 + titleHeight); @@ -199,7 +199,7 @@ class DrawBitmapRectGM : public skiagm::GM { blackPaint.setTextSize(SK_Scalar1 * 10); SkScalar baseline = dstRect.height() + blackPaint.getTextSize() + SK_Scalar1 * 3; - canvas->drawText(label.c_str(), label.size(), + canvas->drawString(label, 0, baseline, blackPaint); blackPaint.setStyle(SkPaint::kStroke_Style); diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp index c4052e381541..07ec8d8c3f92 100644 --- a/gm/drawlooper.cpp +++ b/gm/drawlooper.cpp @@ -43,7 +43,7 @@ class DrawLooperGM : public skiagm::GM { canvas->drawCircle(50, 50, 30, paint); canvas->drawRect({ 150, 50, 200, 100 }, paint); - canvas->drawText("Looper", 6, 230, 100, paint); + canvas->drawString("Looper", 230, 100, paint); } private: diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp index 87cd798483ee..11de72785aad 100644 --- a/gm/dropshadowimagefilter.cpp +++ b/gm/dropshadowimagefilter.cpp @@ -45,7 +45,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp im paint.setTextAlign(SkPaint::kCenter_Align); canvas->save(); canvas->clipRect(r); - canvas->drawText("Text", 4, r.centerX(), r.centerY(), paint); + canvas->drawString("Text", r.centerX(), r.centerY(), paint); canvas->restore(); } diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp index f6086b195a6e..3385ae4a6909 100644 --- a/gm/dstreadshuffle.cpp +++ b/gm/dstreadshuffle.cpp @@ -85,7 +85,7 @@ class DstReadShuffle : public GM { paint->setTextSize(100.f); paint->setFakeBoldText(true); sk_tool_utils::set_portable_typeface(paint); - canvas->drawText(text, strlen(text), 0.f, 100.f, *paint); + canvas->drawString(text, 0.f, 100.f, *paint); } default: break; diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp index 56377e7338e1..67da93f36541 100644 --- a/gm/emptypath.cpp +++ b/gm/emptypath.cpp @@ -68,10 +68,10 @@ class EmptyPathGM : public GM { titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Empty Paths Drawn Into Rectangle Clips With " "Indicated Style and Fill"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -109,14 +109,12 @@ class EmptyPathGM : public GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(12 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 15 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 28 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 15 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 28 * SK_Scalar1, + labelPaint); } } canvas->restore(); diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp index 0f3371cb9062..92aeddc788ef 100644 --- a/gm/filterbitmap.cpp +++ b/gm/filterbitmap.cpp @@ -125,13 +125,13 @@ class FilterBitmapTextGM: public FilterBitmapGM { paint.setTextSize(fTextSize); setTypeface(&paint, "serif", SkFontStyle()); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 1.2f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 2.4f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 3.6f*fTextSize, paint); setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic)); - canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint); + canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, paint); } private: typedef FilterBitmapGM INHERITED; diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp index 8775b58220df..f3f891073c50 100644 --- a/gm/fontcache.cpp +++ b/gm/fontcache.cpp @@ -15,7 +15,7 @@ static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x, SkScalar y, const SkPaint& paint) { - canvas->drawText(text.c_str(), text.size(), x, y, paint); + canvas->drawString(text, x, y, paint); return x + paint.measureText(text.c_str(), text.size()); } diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index aecb46e180e2..bef26f3c182f 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -21,7 +21,7 @@ static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x, SkScalar y, const SkPaint& paint) { - canvas->drawText(text.c_str(), text.size(), x, y, paint); + canvas->drawString(text, x, y, paint); return x + paint.measureText(text.c_str(), text.size()); } diff --git a/gm/gamma.cpp b/gm/gamma.cpp index 864272600e7e..818895792aaa 100644 --- a/gm/gamma.cpp +++ b/gm/gamma.cpp @@ -63,9 +63,9 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) { auto nextRect = [&](const char* label, const char* label2) { canvas->drawRect(r, p); - canvas->drawText(label, strlen(label), 0, sz + textPaint.getFontSpacing(), textPaint); + canvas->drawString(label, 0, sz + textPaint.getFontSpacing(), textPaint); if (label2) { - canvas->drawText(label2, strlen(label2), 0, sz + 2 * textPaint.getFontSpacing(), + canvas->drawString(label2, 0, sz + 2 * textPaint.getFontSpacing(), textPaint); } advance(); @@ -73,7 +73,7 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) { auto nextBitmap = [&](const SkBitmap& bmp, const char* label) { canvas->drawBitmap(bmp, 0, 0); - canvas->drawText(label, strlen(label), 0, sz + textPaint.getFontSpacing(), textPaint); + canvas->drawString(label, 0, sz + textPaint.getFontSpacing(), textPaint); advance(); }; @@ -86,12 +86,12 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) { SkString srcText = SkStringPrintf("%08X", srcColor); SkString dstText = SkStringPrintf("%08X", dstColor); - canvas->drawText(srcText.c_str(), srcText.size(), 0, sz + textPaint.getFontSpacing(), + canvas->drawString(srcText, 0, sz + textPaint.getFontSpacing(), textPaint); const char* modeName = SkBlendMode_Name(mode); - canvas->drawText(modeName, strlen(modeName), 0, sz + 2 * textPaint.getFontSpacing(), + canvas->drawString(modeName, 0, sz + 2 * textPaint.getFontSpacing(), textPaint); - canvas->drawText(dstText.c_str(), dstText.size(), 0, sz + 3 * textPaint.getFontSpacing(), + canvas->drawString(dstText, 0, sz + 3 * textPaint.getFontSpacing(), textPaint); advance(); }; diff --git a/gm/gamut.cpp b/gm/gamut.cpp index 2aaa2b36d3a6..9339aa8274c4 100644 --- a/gm/gamut.cpp +++ b/gm/gamut.cpp @@ -179,8 +179,7 @@ static void draw_gamut_grid(SkCanvas* canvas, SkTArrayclear(SK_ColorBLACK); renderer->draw(wideGamutCanvas); - canvas->drawText(renderer->label(), strlen(renderer->label()), x, y + textHeight, - textPaint); + canvas->drawString(renderer->label(), x, y + textHeight, textPaint); // Re-interpret the off-screen images, so we can see the raw data (eg, Wide gamut squares // will look desaturated, relative to sRGB). diff --git a/gm/gm.cpp b/gm/gm.cpp index c8f125093744..1ba571a15be9 100644 --- a/gm/gm.cpp +++ b/gm/gm.cpp @@ -82,7 +82,7 @@ void GM::DrawGpuOnlyMessage(SkCanvas* canvas) { paint.setColor(SK_ColorRED); sk_tool_utils::set_portable_typeface(&paint); constexpr char kTxt[] = "GPU Only"; - bmpCanvas.drawText(kTxt, strlen(kTxt), 20, 40, paint); + bmpCanvas.drawString(kTxt, 20, 40, paint); SkMatrix localM; localM.setRotate(35.f); localM.postTranslate(10.f, 0.f); diff --git a/gm/gradtext.cpp b/gm/gradtext.cpp index 7f7f22277c4e..cc0c079d77f8 100644 --- a/gm/gradtext.cpp +++ b/gm/gradtext.cpp @@ -57,7 +57,7 @@ class ChromeGradTextGM1 : public GM { paint.setShader(make_chrome_solid()); paint.setTextSize(SkIntToScalar(500)); - canvas->drawText("I", 1, 0, 100, paint); + canvas->drawString("I", 0, 100, paint); } private: typedef GM INHERITED; @@ -77,17 +77,17 @@ class ChromeGradTextGM2 : public GM { sk_tool_utils::set_portable_typeface(&paint); paint.setStyle(SkPaint::kFill_Style); - canvas->drawText("Normal Fill Text", 16, 0, 50, paint); + canvas->drawString("Normal Fill Text", 0, 50, paint); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawText("Normal Stroke Text", 18, 0, 100, paint); + canvas->drawString("Normal Stroke Text", 0, 100, paint); // Minimal repro doesn't require AA, LCD, or a nondefault typeface paint.setShader(make_chrome_solid()); paint.setStyle(SkPaint::kFill_Style); - canvas->drawText("Gradient Fill Text", 18, 0, 150, paint); + canvas->drawString("Gradient Fill Text", 0, 150, paint); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawText("Gradient Stroke Text", 20, 0, 200, paint); + canvas->drawString("Gradient Stroke Text", 0, 200, paint); } private: typedef GM INHERITED; diff --git a/gm/highcontrastfilter.cpp b/gm/highcontrastfilter.cpp index e5330d24cf68..0c7c5e1de679 100644 --- a/gm/highcontrastfilter.cpp +++ b/gm/highcontrastfilter.cpp @@ -52,7 +52,7 @@ static void draw_scene(SkCanvas* canvas, const SkHighContrastConfig& config) { paint.setARGB(0xff, 0xbb, 0x77, 0x77); paint.setTextSize(0.15f); - canvas->drawText("A", 1, 0.15f, 0.35f, paint); + canvas->drawString("A", 0.15f, 0.35f, paint); bounds = SkRect::MakeLTRB(0.1f, 0.8f, 0.9f, 1.0f); paint.setARGB(0xff, 0xcc, 0xcc, 0xff); @@ -60,7 +60,7 @@ static void draw_scene(SkCanvas* canvas, const SkHighContrastConfig& config) { paint.setARGB(0xff, 0x88, 0x88, 0xbb); paint.setTextSize(0.15f); - canvas->drawText("Z", 1, 0.75f, 0.95f, paint); + canvas->drawString("Z", 0.75f, 0.95f, paint); bounds = SkRect::MakeLTRB(0.1f, 0.4f, 0.9f, 0.6f); SkPoint pts[] = { { 0, 0 }, { 1, 0 } }; diff --git a/gm/image.cpp b/gm/image.cpp index 8e38ae716d1d..fc7a5ff1e092 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -150,17 +150,17 @@ class ImageGM : public skiagm::GM { sk_tool_utils::set_portable_typeface(&textPaint); textPaint.setTextSize(8); - canvas->drawText(kLabel1, strlen(kLabel1), 10, 60, textPaint); - canvas->drawText(kLabel2, strlen(kLabel2), 10, 140, textPaint); - canvas->drawText(kLabel3, strlen(kLabel3), 10, 220, textPaint); - canvas->drawText(kLabel4, strlen(kLabel4), 10, 300, textPaint); - canvas->drawText(kLabel5, strlen(kLabel5), 10, 380, textPaint); - canvas->drawText(kLabel6, strlen(kLabel6), 10, 460, textPaint); - canvas->drawText(kLabel7, strlen(kLabel7), 10, 540, textPaint); - - canvas->drawText(kLabel8, strlen(kLabel8), 80, 10, textPaint); - canvas->drawText(kLabel9, strlen(kLabel9), 160, 10, textPaint); - canvas->drawText(kLabel10, strlen(kLabel10), 265, 10, textPaint); + canvas->drawString(kLabel1, 10, 60, textPaint); + canvas->drawString(kLabel2, 10, 140, textPaint); + canvas->drawString(kLabel3, 10, 220, textPaint); + canvas->drawString(kLabel4, 10, 300, textPaint); + canvas->drawString(kLabel5, 10, 380, textPaint); + canvas->drawString(kLabel6, 10, 460, textPaint); + canvas->drawString(kLabel7, 10, 540, textPaint); + + canvas->drawString(kLabel8, 80, 10, textPaint); + canvas->drawString(kLabel9, 160, 10, textPaint); + canvas->drawString(kLabel10, 265, 10, textPaint); canvas->translate(80, 20); diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp index d15f11c745a8..47d6374c9537 100644 --- a/gm/imageblur.cpp +++ b/gm/imageblur.cpp @@ -28,7 +28,7 @@ void imageblurgm_draw(SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas* canvas) { int y = rand.nextULessThan(HEIGHT); textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000)); textPaint.setTextSize(rand.nextRangeScalar(0, 300)); - canvas->drawText(str, strlen(str), SkIntToScalar(x), + canvas->drawString(str, SkIntToScalar(x), SkIntToScalar(y), textPaint); } canvas->restore(); diff --git a/gm/imageblur2.cpp b/gm/imageblur2.cpp index 19c92f31934f..b6f9ff502614 100644 --- a/gm/imageblur2.cpp +++ b/gm/imageblur2.cpp @@ -70,11 +70,10 @@ class BlurImageFilter : public GM { textPaint.setTextSize(textSize); for (int i = 0; i < testStringCount; i++) { - canvas->drawText(kTestStrings[i], - strlen(kTestStrings[i]), - SkIntToScalar(x * dx), - SkIntToScalar(y * dy + textSize * i + textSize), - textPaint); + canvas->drawString(kTestStrings[i], + SkIntToScalar(x * dx), + SkIntToScalar(y * dy + textSize * i + textSize), + textPaint); } canvas->restore(); } diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp index 7d846be370bb..7f1cfbd630b1 100644 --- a/gm/imageblurtiled.cpp +++ b/gm/imageblurtiled.cpp @@ -53,7 +53,7 @@ class ImageBlurTiledGM : public GM { int posY = 0; for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) { posY += 100; - canvas->drawText(str[i], strlen(str[i]), SkIntToScalar(0), + canvas->drawString(str[i], SkIntToScalar(0), SkIntToScalar(posY), textPaint); } canvas->restore(); diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp index f088f673961b..6e347134d314 100644 --- a/gm/imagefiltersbase.cpp +++ b/gm/imagefiltersbase.cpp @@ -155,7 +155,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp im sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(r.height()/2); paint.setTextAlign(SkPaint::kCenter_Align); - canvas->drawText("Text", 4, r.centerX(), r.centerY(), paint); + canvas->drawString("Text", r.centerX(), r.centerY(), paint); } static void draw_bitmap(SkCanvas* canvas, const SkRect& r, sk_sp imf) { @@ -271,7 +271,7 @@ class ImageFiltersTextBaseGM : public skiagm::GM { SkAutoCanvasRestore acr(canvas, true); for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) { paint.setFlags(flags[i]); - canvas->drawText("Hamburgefons", 11, 0, 0, paint); + canvas->drawString("Hamburgefon", 0, 0, paint); canvas->translate(0, 40); } } diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp index b8db8abefa19..5af64920079e 100644 --- a/gm/imagefilterscropped.cpp +++ b/gm/imagefilterscropped.cpp @@ -46,7 +46,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp im sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(r.height()/2); paint.setTextAlign(SkPaint::kCenter_Align); - canvas->drawText("Text", 4, r.centerX(), r.centerY(), paint); + canvas->drawString("Text", r.centerX(), r.centerY(), paint); } static void draw_bitmap(SkCanvas* canvas, const SkRect& r, sk_sp imf) { diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp index a494f4c28546..2585ea763c38 100644 --- a/gm/imagemagnifier.cpp +++ b/gm/imagemagnifier.cpp @@ -35,7 +35,7 @@ DEF_SIMPLE_GM_BG(imagemagnifier, canvas, WIDTH, HEIGHT, SK_ColorBLACK) { paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000)); paint.setTextSize(rand.nextRangeScalar(0, 300)); paint.setAntiAlias(true); - canvas->drawText(str, strlen(str), SkIntToScalar(x), + canvas->drawString(str, SkIntToScalar(x), SkIntToScalar(y), paint); } canvas->restore(); diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp index 9fa6be0cdd43..257e0b259c00 100644 --- a/gm/imageresizetiled.cpp +++ b/gm/imageresizetiled.cpp @@ -43,7 +43,7 @@ DEF_SIMPLE_GM(imageresizetiled, canvas, WIDTH, HEIGHT) { int posY = 0; for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) { posY += 100; - canvas->drawText(str[i], strlen(str[i]), SkIntToScalar(0), + canvas->drawString(str[i], SkIntToScalar(0), SkIntToScalar(posY), textPaint); } canvas->restore(); diff --git a/gm/internal_links.cpp b/gm/internal_links.cpp index c873754715e2..664b4117defa 100644 --- a/gm/internal_links.cpp +++ b/gm/internal_links.cpp @@ -64,7 +64,7 @@ class InternalLinksGM : public GM { sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(25)); paint.setColor(SK_ColorBLACK); - canvas->drawText(text, strlen(text), x, y, paint); + canvas->drawString(text, x, y, paint); } typedef GM INHERITED; diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp index 07b55c56feec..1345d2376274 100644 --- a/gm/lcdblendmodes.cpp +++ b/gm/lcdblendmodes.cpp @@ -133,7 +133,7 @@ class LcdBlendGM : public skiagm::GM { paint.setShader(make_shader(r)); } SkString string(SkBlendMode_Name(gModes[m])); - canvas->drawText(string.c_str(), string.size(), 0, y, paint); + canvas->drawString(string, 0, y, paint); y+=fTextHeight; } } diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp index 5a549eb74c7d..41e83d68fda4 100644 --- a/gm/lcdtext.cpp +++ b/gm/lcdtext.cpp @@ -58,7 +58,7 @@ class LcdTextGM : public skiagm::GM { 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 @@ class LcdTextSizeGM : public skiagm::GM { 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); diff --git a/gm/lightingshader2.cpp b/gm/lightingshader2.cpp index c6c246d35365..edec063dd184 100644 --- a/gm/lightingshader2.cpp +++ b/gm/lightingshader2.cpp @@ -171,25 +171,25 @@ class LightingShader2GM : public GM { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("useNormalSource: %d", useNormalSource); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("useDiffuseShader: %d", useDiffuseShader); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("useTranslucentPaint: %d", useTranslucentPaint); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("useTranslucentShader: %d", useTranslucentShader); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } canvas->restore(); diff --git a/gm/lightingshaderbevel.cpp b/gm/lightingshaderbevel.cpp index 5adf3b813184..9e15a8e7f103 100644 --- a/gm/lightingshaderbevel.cpp +++ b/gm/lightingshaderbevel.cpp @@ -182,13 +182,13 @@ class LightingShaderBevelGM : public GM { label.append("roundedOut"); break; } - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("bevelHeight: %.1f", bevelHeight); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } canvas->restore(); @@ -218,19 +218,19 @@ class LightingShaderBevelGM : public GM { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("bevelType: linear"); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("bevelHeight: %.1f", 7.0f); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } { canvas->translate(0.0f, LABEL_SIZE); SkString label; label.appendf("rotated"); - canvas->drawText(label.c_str(), label.size(), 0.0f, 0.0f, labelPaint); + canvas->drawString(label, 0.0f, 0.0f, labelPaint); } canvas->restore(); diff --git a/gm/linepaths.cpp b/gm/linepaths.cpp index 2583ff17c1f3..94a297922de9 100644 --- a/gm/linepaths.cpp +++ b/gm/linepaths.cpp @@ -83,10 +83,10 @@ static void draw(SkCanvas* canvas, bool doClose) { const char titleClose[] = "Line Closed Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, with stroke width 10"; const char* title = doClose ? titleClose : titleNoClose; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -125,18 +125,15 @@ static void draw(SkCanvas* canvas, bool doClose) { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(gCaps[cap].fName, - strlen(gCaps[cap].fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(gCaps[cap].fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); } canvas->restore(); } diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp index 7c1a2150db7b..4af12e172d09 100644 --- a/gm/matrixconvolution.cpp +++ b/gm/matrixconvolution.cpp @@ -46,7 +46,7 @@ class MatrixConvolutionGM : public GM { paint.setShader(SkGradientShader::MakeLinear( pts, fColors, pos, 2, SkShader::kClamp_TileMode)); const char* str = "e"; - canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80), paint); + canvas.drawString(str, SkIntToScalar(-10), SkIntToScalar(80), paint); // ... tag the data as sRGB, so color-aware devices do gamut adjustment, etc... fBitmap.setInfo(SkImageInfo::MakeS32(80, 80, kPremul_SkAlphaType)); diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp index 56a78f4890b5..9769cda3f5d1 100644 --- a/gm/mipmap.cpp +++ b/gm/mipmap.cpp @@ -38,7 +38,7 @@ DEF_SIMPLE_GM(mipmap, canvas, 400, 200) { paint.setTextSize(30); SkString str; str.printf("scale %g %g", dst.width() / img->width(), dst.height() / img->height()); -// canvas->drawText(str.c_str(), str.size(), 300, 100, paint); +// canvas->drawString(str, 300, 100, paint); canvas->translate(20, 20); for (int i = 0; i < 4; ++i) { diff --git a/gm/morphology.cpp b/gm/morphology.cpp index d1513c43d05a..99603c1ebc65 100644 --- a/gm/morphology.cpp +++ b/gm/morphology.cpp @@ -36,8 +36,8 @@ class MorphologyGM : public GM { const char* str2 = "XYZ"; paint.setColor(0xFFFFFFFF); paint.setTextSize(64); - canvas.drawText(str1, strlen(str1), 10, 55, paint); - canvas.drawText(str2, strlen(str2), 10, 110, paint); + canvas.drawString(str1, 10, 55, paint); + canvas.drawString(str2, 10, 110, paint); } SkISize onISize() override { diff --git a/gm/pdf_never_embed.cpp b/gm/pdf_never_embed.cpp index 4fba40e28245..ae63432c0854 100644 --- a/gm/pdf_never_embed.cpp +++ b/gm/pdf_never_embed.cpp @@ -53,5 +53,5 @@ DEF_SIMPLE_GM(pdf_never_embed, canvas, 512, 512) { canvas->scale(1.0, 0.5); p.setColor(0xF0000080); - canvas->drawText(text, strlen(text), 30, 700, p); + canvas->drawString(text, 30, 700, p); } diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp index aaec8505d304..587ed3733bc9 100644 --- a/gm/pictureimagefilter.cpp +++ b/gm/pictureimagefilter.cpp @@ -33,7 +33,7 @@ static sk_sp make_picture() { paint.setColor(0xFFFFFFFF); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; - canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint); + canvas->drawString(str, SkIntToScalar(20), SkIntToScalar(70), paint); return recorder.finishRecordingAsPicture(); } @@ -50,7 +50,7 @@ static sk_sp make_LCD_picture() { // this has to be small enough that it doesn't become a path paint.setTextSize(SkIntToScalar(36)); const char* str = "e"; - canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint); + canvas->drawString(str, SkIntToScalar(20), SkIntToScalar(70), paint); return recorder.finishRecordingAsPicture(); } diff --git a/gm/pixelsnap.cpp b/gm/pixelsnap.cpp index d664d973c97d..f4e45827c179 100644 --- a/gm/pixelsnap.cpp +++ b/gm/pixelsnap.cpp @@ -55,7 +55,7 @@ class PixelSnapGM : public skiagm::GM { canvas->translate(0, SkIntToScalar(kLabelOffsetY)); for (int i = 0; i <= kSubPixelSteps; ++i) { offset.printf("%d", i); - canvas->drawText(offset.c_str(), offset.size(), + canvas->drawString(offset, 0, i * kTrans + labelPaint.getTextSize(), labelPaint); } @@ -66,7 +66,7 @@ class PixelSnapGM : public skiagm::GM { canvas->translate(SkIntToScalar(kLabelOffsetX), 0); for (int i = 0; i <= kSubPixelSteps; ++i) { offset.printf("%d", i); - canvas->drawText(offset.c_str(), offset.size(), + canvas->drawString(offset, i * SkIntToScalar(kTrans), labelPaint.getTextSize(), labelPaint); } diff --git a/gm/poly2poly.cpp b/gm/poly2poly.cpp index 9434bf2658ac..2b9b390eb118 100644 --- a/gm/poly2poly.cpp +++ b/gm/poly2poly.cpp @@ -73,8 +73,7 @@ void SkJSCanvas::stroke() { } void SkJSCanvas::fillText(const char text[], double x, double y) { - fTarget->drawText(text, strlen(text), - SkDoubleToScalar(x), SkDoubleToScalar(y), fFillPaint); + fTarget->drawString(text, SkDoubleToScalar(x), SkDoubleToScalar(y), fFillPaint); } /////////////////////////////////////////////////////////////////////////////// diff --git a/gm/quadpaths.cpp b/gm/quadpaths.cpp index bac37b9234e8..fb106859a4b0 100644 --- a/gm/quadpaths.cpp +++ b/gm/quadpaths.cpp @@ -90,10 +90,10 @@ class QuadPathGM : public GM { titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Quad Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, with stroke width 10"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -132,18 +132,15 @@ class QuadPathGM : public GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(gCaps[cap].fName, - strlen(gCaps[cap].fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(gCaps[cap].fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); } canvas->restore(); } @@ -234,10 +231,10 @@ class QuadClosePathGM : public GM { titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Quad Closed Drawn Into Rectangle Clips With " "Indicated Style, Fill and Linecaps, with stroke width 10"; - canvas->drawText(title, strlen(title), - 20 * SK_Scalar1, - 20 * SK_Scalar1, - titlePaint); + canvas->drawString(title, + 20 * SK_Scalar1, + 20 * SK_Scalar1, + titlePaint); SkRandom rand; SkRect rect = SkRect::MakeWH(100*SK_Scalar1, 30*SK_Scalar1); @@ -276,18 +273,15 @@ class QuadClosePathGM : public GM { labelPaint.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(10 * SK_Scalar1); - canvas->drawText(gStyles[style].fName, - strlen(gStyles[style].fName), - 0, rect.height() + 12 * SK_Scalar1, - labelPaint); - canvas->drawText(gFills[fill].fName, - strlen(gFills[fill].fName), - 0, rect.height() + 24 * SK_Scalar1, - labelPaint); - canvas->drawText(gCaps[cap].fName, - strlen(gCaps[cap].fName), - 0, rect.height() + 36 * SK_Scalar1, - labelPaint); + canvas->drawString(gStyles[style].fName, + 0, rect.height() + 12 * SK_Scalar1, + labelPaint); + canvas->drawString(gFills[fill].fName, + 0, rect.height() + 24 * SK_Scalar1, + labelPaint); + canvas->drawString(gCaps[cap].fName, + 0, rect.height() + 36 * SK_Scalar1, + labelPaint); } canvas->restore(); } diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp index 67ffa9a08c90..5b3dc224e23c 100644 --- a/gm/rectangletexture.cpp +++ b/gm/rectangletexture.cpp @@ -138,7 +138,7 @@ class RectangleTexture : public GM { SkPaint paint; paint.setAntiAlias(true); const char* kMsg = "Could not create rectangle texture image."; - canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint); + canvas->drawString(kMsg, 10, 100, paint); return; } diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp index 63873499bc80..f3287437eeba 100644 --- a/gm/samplerstress.cpp +++ b/gm/samplerstress.cpp @@ -111,7 +111,7 @@ class SamplerStressGM : public GM { canvas->clipPath(path, true); // AA is on - canvas->drawText("M", 1, + canvas->drawString("M", SkIntToScalar(100), SkIntToScalar(100), paint); @@ -126,7 +126,7 @@ class SamplerStressGM : public GM { paint2.setStyle(SkPaint::kStroke_Style); paint2.setStrokeWidth(1); sk_tool_utils::set_portable_typeface(&paint2); - canvas->drawText("M", 1, + canvas->drawString("M", SkIntToScalar(100), SkIntToScalar(100), paint2); diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp index 9b585bf4d65e..d23409a5a523 100644 --- a/gm/shadertext2.cpp +++ b/gm/shadertext2.cpp @@ -107,14 +107,14 @@ DEF_SIMPLE_GM_BG(shadertext2, canvas, 1800, 900, canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f); constexpr char kLabelLabel[] = "localM / canvasM"; - canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint); + canvas->drawString(kLabelLabel, 0, 0, labelPaint); canvas->translate(0, 15.f); canvas->save(); SkScalar maxLabelW = 0; canvas->translate(0, kPadY / 2 + kPointSize); for (int lm = 0; lm < localMatrices.count(); ++lm) { - canvas->drawText(matrices[lm].fLabel, strlen(matrices[lm].fLabel), + canvas->drawString(matrices[lm].fLabel, 0, labelPaint.getTextSize() - 1, labelPaint); SkScalar labelW = labelPaint.measureText(matrices[lm].fLabel, strlen(matrices[lm].fLabel)); @@ -132,7 +132,7 @@ DEF_SIMPLE_GM_BG(shadertext2, canvas, 1800, 900, for (int m = 0; m < matrices.count(); ++m) { columnH = 0; canvas->save(); - canvas->drawText(matrices[m].fLabel, strlen(matrices[m].fLabel), + canvas->drawString(matrices[m].fLabel, 0, labelPaint.getTextSize() - 1, labelPaint); canvas->translate(0, kPadY / 2 + kPointSize); columnH += kPadY / 2 + kPointSize; @@ -178,8 +178,8 @@ DEF_SIMPLE_GM_BG(shadertext2, canvas, 1800, 900, SkScalar y = columnH + kPadY / 2; SkScalar fillX = -outlinePaint.measureText(kFillLabel, strlen(kFillLabel)) - kPadX; SkScalar strokeX = kPadX; - canvas->drawText(kFillLabel, strlen(kFillLabel), fillX, y, labelPaint); - canvas->drawText(kStrokeLabel, strlen(kStrokeLabel), strokeX, y, labelPaint); + canvas->drawString(kFillLabel, fillX, y, labelPaint); + canvas->drawString(kStrokeLabel, strokeX, y, labelPaint); } } } diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp index 4c7407dedb63..5e4067f966ef 100644 --- a/gm/simpleaaclip.cpp +++ b/gm/simpleaaclip.cpp @@ -162,7 +162,7 @@ class SimpleClipGM : public GM { int xOff = 0; for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) { - canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), + canvas->drawString(gOps[op].fName, SkIntToScalar(75), SkIntToScalar(50), textPaint); diff --git a/gm/skbug_257.cpp b/gm/skbug_257.cpp index fb77532fa1ca..91c0a1665ef3 100644 --- a/gm/skbug_257.cpp +++ b/gm/skbug_257.cpp @@ -66,7 +66,7 @@ static void test_text(SkCanvas* canvas, SkScalar size, sk_tool_utils::set_portable_typeface(&type); type.setColor(color); const char text[] = "HELLO WORLD"; - canvas->drawText(text, strlen(text), 32, size / 2 + Y, type); + canvas->drawString(text, 32, size / 2 + Y, type); SkScalar lineSpacing = type.getFontSpacing(); exercise_draw_pos_text(canvas, text, 32, size / 2 + Y + lineSpacing, type); exercise_draw_pos_text_h(canvas, text, 32, diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp index 75721f1de41f..e43933ce11a2 100644 --- a/gm/srcmode.cpp +++ b/gm/srcmode.cpp @@ -53,7 +53,7 @@ static void draw_oval(SkCanvas* canvas, const SkPaint& paint) { static void draw_text(SkCanvas* canvas, const SkPaint& paint) { SkPaint p(paint); p.setTextSize(H/4); - canvas->drawText("Hamburge", 8, 0, H*2/3, p); + canvas->drawString("Hamburge", 0, H*2/3, p); } class SrcModeGM : public skiagm::GM { diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp index f1bb32732a8f..ec939d193692 100644 --- a/gm/stroketext.cpp +++ b/gm/stroketext.cpp @@ -31,7 +31,7 @@ static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint, SkScalar s if (strokeWidth > 0) { p.setStyle(SkPaint::kFill_Style); - canvas->drawText("P", 1, loc.fX, loc.fY - 225, p); + canvas->drawString("P", loc.fX, loc.fY - 225, p); canvas->drawPosText("P", 1, &loc, p); } @@ -39,7 +39,7 @@ static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint, SkScalar s p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(strokeWidth); - canvas->drawText("P", 1, loc.fX, loc.fY - 225, p); + canvas->drawString("P", loc.fX, loc.fY - 225, p); canvas->drawPosText("P", 1, &loc, p); } diff --git a/gm/surface.cpp b/gm/surface.cpp index ee4deccacfe8..4b400caa4445 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -46,7 +46,7 @@ static void test_draw(SkCanvas* canvas, const char label[]) { paint.setTextSize(32); paint.setTextAlign(SkPaint::kCenter_Align); sk_tool_utils::set_portable_typeface(&paint); - canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint); + canvas->drawString(label, W / 2, H * 3 / 4, paint); } class SurfacePropsGM : public skiagm::GM { diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp index 5e0f189d6138..b98aea714e77 100644 --- a/gm/texteffects.cpp +++ b/gm/texteffects.cpp @@ -188,7 +188,7 @@ DEF_SIMPLE_GM(texteffects, canvas, 460, 680) { // paint.setMaskFilter(nullptr); // paint.setColor(SK_ColorBLACK); - canvas->drawText(str.c_str(), str.size(), x, y, paint); + canvas->drawString(str, x, y, paint); y += paint.getFontSpacing(); } diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp index 009ad6421d18..390ce4adcd3d 100644 --- a/gm/tilemodes.cpp +++ b/gm/tilemodes.cpp @@ -105,7 +105,7 @@ class TilingGM : public skiagm::GM { str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); p.setTextAlign(SkPaint::kCenter_Align); - 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; } @@ -142,7 +142,7 @@ class TilingGM : public skiagm::GM { p.setAntiAlias(true); sk_tool_utils::set_portable_typeface(&p); str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); - canvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p); + canvas->drawString(str, x, y + r.height() * 2 / 3, p); } y += r.height() * 4 / 3; @@ -224,7 +224,7 @@ class Tiling2GM : public skiagm::GM { 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; } @@ -235,7 +235,7 @@ class Tiling2GM : public skiagm::GM { 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++) { diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp index 807d63b369da..3833fa29436d 100644 --- a/gm/tilemodes_scaled.cpp +++ b/gm/tilemodes_scaled.cpp @@ -107,7 +107,7 @@ class ScaledTilingGM : public skiagm::GM { 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 @@ class ScaledTilingGM : public skiagm::GM { 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 @@ class ScaledTiling2GM : public skiagm::GM { 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 @@ class ScaledTiling2GM : public skiagm::GM { 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++) { diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp index 563d138fc7ed..c0f6cbf8c7e3 100644 --- a/gm/variedtext.cpp +++ b/gm/variedtext.cpp @@ -116,7 +116,7 @@ class VariedTextGM : public skiagm::GM { canvas->save(); canvas->clipRect(fClipRects[i]); canvas->translate(fPositions[i].fX, fPositions[i].fY); - canvas->drawText(fStrings[i].c_str(), fStrings[i].size(), 0, 0, fPaint); + canvas->drawString(fStrings[i], 0, 0, fPaint); canvas->restore(); } diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp index d7da041896d5..a0ebd01812dc 100644 --- a/gm/verttext2.cpp +++ b/gm/verttext2.cpp @@ -76,7 +76,7 @@ class VertText2GM : public GM { paint.setTypeface(std::move(family)); paint.setTextSize(textHeight); - canvas->drawText(string.c_str(), string.size(), y, + canvas->drawString(string, y, SkIntToScalar(alignment == SkPaint::kLeft_Align ? 10 : 240), paint); y += textHeight; diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp index 544f5e0c7161..708348799732 100644 --- a/gm/windowrectangles.cpp +++ b/gm/windowrectangles.cpp @@ -284,7 +284,7 @@ void WindowRectanglesMaskGM::fail(SkCanvas* canvas) { canvas->clipRect(SkRect::Make(kCoverRect)); canvas->clear(SK_ColorWHITE); - canvas->drawText(errorMsg.c_str(), errorMsg.size(), SkIntToScalar(kCoverRect.centerX()), + canvas->drawString(errorMsg, SkIntToScalar(kCoverRect.centerX()), SkIntToScalar(kCoverRect.centerY() - 10), paint); } diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp index 5d23104ad017..9bf46f6eb578 100644 --- a/gm/xfermodes.cpp +++ b/gm/xfermodes.cpp @@ -259,7 +259,7 @@ class XfermodesGM : public skiagm::GM { #if 1 const char* label = SkBlendMode_Name(gModes[i].fMode); - canvas->drawText(label, strlen(label), + canvas->drawString(label, x + w/2, y - labelP.getTextSize()/2, labelP); #endif x += w + SkIntToScalar(10); diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp index 891a864cf915..2db824d95b64 100644 --- a/gm/xfermodes2.cpp +++ b/gm/xfermodes2.cpp @@ -72,8 +72,8 @@ class Xfermodes2GM : public GM { canvas->restore(); #if 1 - canvas->drawText(SkBlendMode_Name(mode), strlen(SkBlendMode_Name(mode)), - x + w/2, y - labelP.getTextSize()/2, labelP); + canvas->drawString(SkBlendMode_Name(mode), + x + w/2, y - labelP.getTextSize()/2, labelP); #endif x += w + SkIntToScalar(10); if ((m % W) == W - 1) { diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp index 6e4d8b81bcfb..9c78658ae7a9 100644 --- a/gm/xfermodes3.cpp +++ b/gm/xfermodes3.cpp @@ -71,8 +71,7 @@ class Xfermodes3GM : public GM { for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) { for (size_t m = 0; m <= (size_t)SkBlendMode::kLastMode; ++m) { SkBlendMode mode = static_cast(m); - canvas->drawText(SkBlendMode_Name(mode), - strlen(SkBlendMode_Name(mode)), + canvas->drawString(SkBlendMode_Name(mode), SkIntToScalar(x), SkIntToScalar(y + kSize + 3) + labelP.getTextSize(), labelP); diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 33a51f7755f1..7b6ef7de68d0 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -950,6 +950,29 @@ class SK_API SkCanvas : SkNoncopyable { void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint); + /** Draw null-terminated UTF-8 string, with origin at (x,y), using the specified paint. + The origin is interpreted based on the Align setting in the paint. + @param string The null-terminated string to be drawn + @param x The x-coordinate of the origin of the string being drawn + @param y The y-coordinate of the origin of the string being drawn + @param paint The paint used for the string (e.g. color, size, style) + */ + void drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint) { + if (!string) { + return; + } + this->drawText(string, strlen(string), x, y, paint); + } + + /** Draw string, with origin at (x,y), using the specified paint. + The origin is interpreted based on the Align setting in the paint. + @param string The string to be drawn + @param x The x-coordinate of the origin of the string being drawn + @param y The y-coordinate of the origin of the string being drawn + @param paint The paint used for the string (e.g. color, size, style) + */ + void drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint); + /** Draw the text, with each character/glyph origin specified by the pos[] array. The origin is interpreted by the Align setting in the paint. @param text The text to be drawn diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp index 2721a5bd184d..959ac5094cc6 100644 --- a/samplecode/ClockFaceView.cpp +++ b/samplecode/ClockFaceView.cpp @@ -235,7 +235,7 @@ class ClockFaceView : public SkView { paint.setTypeface(fFace); apply_shader(&paint, SkScalarToFloat(fInterp)); - canvas->drawText(str.c_str(), str.size(), x, y, paint); + canvas->drawString(str, x, y, paint); // drawdots(canvas, paint); diff --git a/samplecode/OverView.cpp b/samplecode/OverView.cpp index 62e8c2aa19c7..cb56783a8b76 100644 --- a/samplecode/OverView.cpp +++ b/samplecode/OverView.cpp @@ -167,7 +167,7 @@ void OverView::onDraw(SkCanvas* canvas) { for (int i = 0; i < fCount; ++i) { if (draw_this_name(fNames[i], fMatchStr)) { canvas->drawRect(this->bounds(loc), paint); - canvas->drawText(fNames[i].c_str(), fNames[i].size(), loc.x(), loc.y(), fNamePaint); + canvas->drawString(fNames[i], loc.x(), loc.y(), fNamePaint); this->next(&loc); } } diff --git a/samplecode/SampleAAGeometry.cpp b/samplecode/SampleAAGeometry.cpp index 875db26ca28f..6f6541b0d92e 100644 --- a/samplecode/SampleAAGeometry.cpp +++ b/samplecode/SampleAAGeometry.cpp @@ -606,8 +606,8 @@ struct UniControl { canvas->drawLine(fBounds.fLeft - 5, fYLo, fBounds.fRight + 5, fYLo, paints.fIndicator); SkString label; label.printf("%0.3g", fValLo); - canvas->drawText(label.c_str(), label.size(), fBounds.fLeft + 5, fYLo - 5, paints.fValue); - canvas->drawText(fName.c_str(), fName.size(), fBounds.fLeft, fBounds.bottom() + 11, + canvas->drawString(label, fBounds.fLeft + 5, fYLo - 5, paints.fValue); + canvas->drawString(fName, fBounds.fLeft, fBounds.bottom() + 11, paints.fLabel); } }; @@ -634,7 +634,7 @@ struct BiControl : public UniControl { if (yPos < fYLo + 10) { yPos = fYLo + 10; } - canvas->drawText(label.c_str(), label.size(), fBounds.fLeft + 5, yPos - 5, paints.fValue); + canvas->drawString(label, fBounds.fLeft + 5, yPos - 5, paints.fValue); SkRect fill = { fBounds.fLeft, fYLo, fBounds.fRight, yPos }; canvas->drawRect(fill, paints.fFill); } @@ -1819,11 +1819,11 @@ void AAGeometryView::draw_legend(SkCanvas* canvas) { SkScalar bottomOffset = this->height() - 10; for (int index = kKeyCommandCount - 1; index >= 0; --index) { bottomOffset -= 15; - canvas->drawText(kKeyCommandList[index].fDescriptionL, - strlen(kKeyCommandList[index].fDescriptionL), this->width() - 160, bottomOffset, + canvas->drawString(kKeyCommandList[index].fDescriptionL, + this->width() - 160, bottomOffset, fLegendLeftPaint); - canvas->drawText(kKeyCommandList[index].fDescriptionR, - strlen(kKeyCommandList[index].fDescriptionR), this->width() - 20, bottomOffset, + canvas->drawString(kKeyCommandList[index].fDescriptionR, + this->width() - 20, bottomOffset, fLegendRightPaint); } } diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 37a0c4b8710a..a8d24589ce41 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -544,7 +544,7 @@ class DemoView : public SampleView { gLightingColors[index].fAdd)); #endif - canvas->drawText(str.c_str(), str.size(), x, y, paint); + canvas->drawString(str, x, y, paint); SkRect oval = { x, y - SkIntToScalar(40), x + SkIntToScalar(40), y }; paint.setStyle(SkPaint::kStroke_Style); canvas->drawOval(oval, paint); diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp index 2b047c2abe30..e70530ab96ad 100644 --- a/samplecode/SampleAnimatedText.cpp +++ b/samplecode/SampleAnimatedText.cpp @@ -126,8 +126,8 @@ class AnimatedTextView : public SampleView { canvas->restore(); paint.setTextSize(16); -// canvas->drawText(outString.c_str(), outString.size(), 512.f, 540.f, paint); - canvas->drawText(modeString.c_str(), modeString.size(), 768.f, 540.f, paint); +// canvas->drawString(outString, 512.f, 540.f, paint); + canvas->drawString(modeString, 768.f, 540.f, paint); } bool onAnimate(const SkAnimTimer& timer) override { diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp index f95833e83035..abdcdec2fdeb 100644 --- a/samplecode/SampleArc.cpp +++ b/samplecode/SampleArc.cpp @@ -127,7 +127,7 @@ class ArcsView : public SampleView { str.appendScalar(start); str.append(", "); str.appendScalar(sweep); - canvas->drawText(str.c_str(), str.size(), rect.centerX(), + canvas->drawString(str, rect.centerX(), rect.fBottom + paint.getTextSize() * 5/4, paint); } diff --git a/samplecode/SampleBevel.cpp b/samplecode/SampleBevel.cpp index fce8885c48db..3f193cfc45d2 100644 --- a/samplecode/SampleBevel.cpp +++ b/samplecode/SampleBevel.cpp @@ -90,7 +90,7 @@ class Control : public SkRefCnt { labelPaint.setColor(0xFFFFFFFF); labelPaint.setTextSize(12.0f); - canvas->drawText(label.c_str(), label.size(), 0, kLabelHeight - 6.0f, labelPaint); + canvas->drawString(label, 0, kLabelHeight - 6.0f, labelPaint); } SkString fName; diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp index ebfe3bbc6dae..ccf2d26fe91a 100644 --- a/samplecode/SampleBitmapRect.cpp +++ b/samplecode/SampleBitmapRect.cpp @@ -171,7 +171,7 @@ static void make_big_bitmap(SkBitmap* bm) { SkCanvas canvas(*bm); - canvas.drawText(gText, strlen(gText), 0, paint.getTextSize()*4/5, paint); + canvas.drawString(gText, 0, paint.getTextSize()*4/5, paint); } class BitmapRectView2 : public SampleView { diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp index 4c4082cea0b9..a2f90a7746b3 100644 --- a/samplecode/SampleBlur.cpp +++ b/samplecode/SampleBlur.cpp @@ -111,13 +111,13 @@ class BlurView : public SampleView { SkScalar x = SkIntToScalar(70); SkScalar y = SkIntToScalar(400); paint.setColor(SK_ColorBLACK); - canvas->drawText("Hamburgefons Style", 18, x, y, paint); - canvas->drawText("Hamburgefons Style", 18, x, y + SkIntToScalar(50), paint); + canvas->drawString("Hamburgefons Style", x, y, paint); + canvas->drawString("Hamburgefons Style", x, y + SkIntToScalar(50), paint); paint.setMaskFilter(nullptr); paint.setColor(SK_ColorWHITE); x -= SkIntToScalar(2); y -= SkIntToScalar(2); - canvas->drawText("Hamburgefons Style", 18, x, y, paint); + canvas->drawString("Hamburgefons Style", x, y, paint); } canvas->restore(); flags = SkBlurMaskFilter::kHighQuality_BlurFlag; diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp index 41192fbbc401..05b5a25e5b77 100644 --- a/samplecode/SampleClip.cpp +++ b/samplecode/SampleClip.cpp @@ -27,7 +27,7 @@ static void show_text(SkCanvas* canvas, bool doAA) { for (int i = 0; i < 200; ++i) { paint.setColor((SK_A32_MASK << SK_A32_SHIFT) | rand.nextU()); - canvas->drawText("Hamburgefons", 12, + canvas->drawString("Hamburgefons", rand.nextSScalar1() * W, rand.nextSScalar1() * H + 20, paint); } diff --git a/samplecode/SampleComplexClip.cpp b/samplecode/SampleComplexClip.cpp index b9c930742e2d..af7f38ede9fc 100644 --- a/samplecode/SampleComplexClip.cpp +++ b/samplecode/SampleComplexClip.cpp @@ -129,14 +129,14 @@ class ComplexClipView : public SampleView { SkScalar txtX = SkIntToScalar(55); paint.setColor(colorA); const char* aTxt = invA ? "InverseA " : "A "; - canvas->drawText(aTxt, strlen(aTxt), txtX, SkIntToScalar(220), paint); + canvas->drawString(aTxt, txtX, SkIntToScalar(220), paint); txtX += paint.measureText(aTxt, strlen(aTxt)); paint.setColor(SK_ColorBLACK); - canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), + canvas->drawString(gOps[op].fName, txtX, SkIntToScalar(220), paint); txtX += paint.measureText(gOps[op].fName, strlen(gOps[op].fName)); paint.setColor(colorB); - canvas->drawText("B", 1, txtX, SkIntToScalar(220), paint); + canvas->drawString("B", txtX, SkIntToScalar(220), paint); canvas->translate(SkIntToScalar(250),0); } diff --git a/samplecode/SampleDegenerateTwoPtRadials.cpp b/samplecode/SampleDegenerateTwoPtRadials.cpp index f1712022491e..cdd5e1c2d139 100644 --- a/samplecode/SampleDegenerateTwoPtRadials.cpp +++ b/samplecode/SampleDegenerateTwoPtRadials.cpp @@ -72,7 +72,7 @@ class DegenerateTwoPtRadialsView : public SampleView { SkPaint paint; paint.setAntiAlias(true); paint.setColor(SK_ColorBLACK); - canvas->drawText(txt.c_str(), txt.size(), l + w/2 + w*DELTA_SCALE*delta, t + h + SK_Scalar1 * 10, paint); + canvas->drawString(txt, l + w/2 + w*DELTA_SCALE*delta, t + h + SK_Scalar1 * 10, paint); } bool onAnimate(const SkAnimTimer& timer) override { diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp index c49cdadcb3fd..1acc1afa31b1 100644 --- a/samplecode/SampleFatBits.cpp +++ b/samplecode/SampleFatBits.cpp @@ -462,7 +462,7 @@ class DrawLineView : public SampleView { paint.setAntiAlias(true); paint.setTextSize(16); paint.setColor(SK_ColorBLUE); - canvas->drawText(str.c_str(), str.size(), 10, 16, paint); + canvas->drawString(str, 10, 16, paint); } } diff --git a/samplecode/SampleFilter.cpp b/samplecode/SampleFilter.cpp index 00f3853d4ef3..60dd7e090d1a 100644 --- a/samplecode/SampleFilter.cpp +++ b/samplecode/SampleFilter.cpp @@ -59,7 +59,7 @@ static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { paint.setAntiAlias(true); const char* name = sk_tool_utils::colortype_name(bm.colorType()); - canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8, + canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8, paint); canvas->translate(SkIntToScalar(48), 0); diff --git a/samplecode/SampleFilter2.cpp b/samplecode/SampleFilter2.cpp index 9b2298a0b467..e6134bdb2255 100644 --- a/samplecode/SampleFilter2.cpp +++ b/samplecode/SampleFilter2.cpp @@ -89,7 +89,7 @@ class Filter2View : public SampleView { s.appendS32(paint.isDither()); s.append(" filter="); s.appendS32(paint.getFilterQuality() != kNone_SkFilterQuality); - canvas->drawText(s.c_str(), s.size(), x + W/2, + canvas->drawString(s, x + W/2, y - p.getTextSize(), p); } if (k+j == 2) { @@ -99,7 +99,7 @@ class Filter2View : public SampleView { SkString s; s.append(" depth="); s.appendS32(fBitmaps[i].colorType() == kRGB_565_SkColorType ? 16 : 32); - canvas->drawText(s.c_str(), s.size(), x + W + SkIntToScalar(4), + canvas->drawString(s, x + W + SkIntToScalar(4), y + H/2, p); } } diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 5524f1e8520c..3690612870cc 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -257,7 +257,7 @@ static void make_g_bitmap(SkBitmap& bitmap) { paint.setColor(0xFF884422); paint.setTextSize(SkIntToScalar(kBitmapSize/2)); const char* str = "g"; - canvas.drawText(str, strlen(str), SkIntToScalar(kBitmapSize/8), + canvas.drawString(str, SkIntToScalar(kBitmapSize/8), SkIntToScalar(kBitmapSize/4), paint); } @@ -339,7 +339,7 @@ static void drawSomething(SkCanvas* canvas) { canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint); paint.setColor(SK_ColorBLACK); paint.setTextSize(SkIntToScalar(kBitmapSize/3)); - canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); + canvas->drawString("Picture", SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); } static void rand_color_table(uint8_t* table) { diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp index 78aa20e1bcc7..43cd5057213d 100644 --- a/samplecode/SampleFilterQuality.cpp +++ b/samplecode/SampleFilterQuality.cpp @@ -277,14 +277,14 @@ class FilterQualityView : public SampleView { paint.setTextSize(36); SkString str; str.appendScalar(fScale); - canvas->drawText(str.c_str(), str.size(), textX, 100, paint); + canvas->drawString(str, textX, 100, paint); str.reset(); str.appendScalar(fAngle); - canvas->drawText(str.c_str(), str.size(), textX, 150, paint); + canvas->drawString(str, textX, 150, paint); str.reset(); str.appendScalar(trans[0]); - canvas->drawText(str.c_str(), str.size(), textX, 200, paint); + canvas->drawString(str, textX, 200, paint); str.reset(); str.appendScalar(trans[1]); - canvas->drawText(str.c_str(), str.size(), textX, 250, paint); + canvas->drawString(str, textX, 250, paint); } bool onAnimate(const SkAnimTimer& timer) override { diff --git a/samplecode/SampleIdentityScale.cpp b/samplecode/SampleIdentityScale.cpp index 95970e7f45fc..5fbba699dfc4 100644 --- a/samplecode/SampleIdentityScale.cpp +++ b/samplecode/SampleIdentityScale.cpp @@ -71,7 +71,7 @@ class IdentityScaleView : public SampleView { } canvas->drawBitmap( fBM, 100, 100, &paint ); canvas->restore(); - canvas->drawText( text, strlen(text), 100, 400, paint ); + canvas->drawString(text, 100, 400, paint ); this->inval(nullptr); } diff --git a/samplecode/SamplePolyToPoly.cpp b/samplecode/SamplePolyToPoly.cpp index 8594c2b88f6c..f947251b5520 100644 --- a/samplecode/SamplePolyToPoly.cpp +++ b/samplecode/SamplePolyToPoly.cpp @@ -110,7 +110,7 @@ class PolyToPolyView : public SampleView { float y = D/2 - (fm.fAscent + fm.fDescent)/2; SkString str; str.appendS32(count); - canvas->drawText(str.c_str(), str.size(), + canvas->drawString(str, x, y, *paint); diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp index 30b8603bcf33..ea5f97fa2ac8 100644 --- a/samplecode/SampleQuadStroker.cpp +++ b/samplecode/SampleQuadStroker.cpp @@ -321,7 +321,7 @@ class QuadStrokerView : public SampleView { label.appendS32(index); SkRect dot = SkRect::MakeXYWH(pos.x() - 2, pos.y() - 2, 4, 4); canvas->drawRect(dot, labelP); - canvas->drawText(label.c_str(), label.size(), + canvas->drawString(label, pos.x() - tan.x() * 1.25f, pos.y() - tan.y() * 1.25f, labelP); } } @@ -381,7 +381,7 @@ class QuadStrokerView : public SampleView { if (0 == index % 10) { SkString label; label.appendS32(index); - canvas->drawText(label.c_str(), label.size(), + canvas->drawString(label, pos.x() + tan.x() * 1.25f, pos.y() + tan.y() * 1.25f, paint); } } @@ -509,9 +509,9 @@ class QuadStrokerView : public SampleView { paint.setColor(0xFF000000); paint.setTextSize(11.0f); paint.setStyle(SkPaint::kFill_Style); - canvas->drawText(label.c_str(), label.size(), bounds.fLeft + 5, yPos - 5, paint); + canvas->drawString(label, bounds.fLeft + 5, yPos - 5, paint); paint.setTextSize(13.0f); - canvas->drawText(name, strlen(name), bounds.fLeft, bounds.bottom() + 11, paint); + canvas->drawString(name, bounds.fLeft, bounds.bottom() + 11, paint); } void setForGeometry() { diff --git a/samplecode/SampleRectanizer.cpp b/samplecode/SampleRectanizer.cpp index 4ff28b2a6c91..0657464ef17d 100644 --- a/samplecode/SampleRectanizer.cpp +++ b/samplecode/SampleRectanizer.cpp @@ -119,13 +119,13 @@ class RectanizerView : public SampleView { 100.0f * totArea / ((float)kWidth*kHeight), fCurRandRect, kNumRandRects); - canvas->drawText(str.c_str(), str.size(), 50, kHeight + 50, blackBigFont); + canvas->drawString(str, 50, kHeight + 50, blackBigFont); str.printf("Press \'j\' to toggle rectanizer"); - canvas->drawText(str.c_str(), str.size(), 50, kHeight + 100, blackBigFont); + canvas->drawString(str, 50, kHeight + 100, blackBigFont); str.printf("Press \'h\' to toggle rects"); - canvas->drawText(str.c_str(), str.size(), 50, kHeight + 150, blackBigFont); + canvas->drawString(str, 50, kHeight + 150, blackBigFont); this->inval(nullptr); } diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp index 082ff222865e..1fee2fa7f9a6 100644 --- a/samplecode/SampleRegion.cpp +++ b/samplecode/SampleRegion.cpp @@ -226,7 +226,7 @@ class RegionView : public SampleView { paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(20)); paint.setColor(hilite ? SK_ColorRED : 0x40FF0000); - canvas->drawText(text, strlen(text), loc.fX, loc.fY, paint); + canvas->drawString(text, loc.fX, loc.fY, paint); } void drawPredicates(SkCanvas* canvas, const SkPoint pts[]) { @@ -373,7 +373,7 @@ class RegionView : public SampleView { canvas->translate(0, SkIntToScalar(200)); for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) { - canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), SkIntToScalar(75), SkIntToScalar(50), textPaint); + canvas->drawString(gOps[op].fName, SkIntToScalar(75), SkIntToScalar(50), textPaint); this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor); diff --git a/samplecode/SampleShip.cpp b/samplecode/SampleShip.cpp index 9d65b6f6903e..08f794ababf4 100644 --- a/samplecode/SampleShip.cpp +++ b/samplecode/SampleShip.cpp @@ -150,7 +150,7 @@ class DrawShipView : public SampleView { paint.setColor(SK_ColorBLACK); canvas->drawRect(SkRect::MakeXYWH(0, 0, 200, 24), paint); paint.setColor(SK_ColorWHITE); - canvas->drawText(outString.c_str(), outString.size(), 5, 15, paint); + canvas->drawString(outString, 5, 15, paint); this->inval(nullptr); } diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp index e69625e9bf2b..3f84482f4f0a 100644 --- a/samplecode/SampleStrokePath.cpp +++ b/samplecode/SampleStrokePath.cpp @@ -170,7 +170,7 @@ class StrokePathView : public SampleView { if (x) { paint.setMaskFilter(SkBlurMaskFilter::Make(gStyle[x - 1], sigma)); } - canvas->drawText("Title Bar", 9, x*SkIntToScalar(100), y*SkIntToScalar(30), paint); + canvas->drawString("Title Bar", x*SkIntToScalar(100), y*SkIntToScalar(30), paint); sigma *= 0.75f; } diff --git a/samplecode/SampleSubpixelTranslate.cpp b/samplecode/SampleSubpixelTranslate.cpp index 3bb90562fa9a..fd66de25ca33 100644 --- a/samplecode/SampleSubpixelTranslate.cpp +++ b/samplecode/SampleSubpixelTranslate.cpp @@ -71,7 +71,7 @@ class SubpixelTranslateView : public SampleView { canvas->drawBitmapRect( fBM, r, &paint ); } - canvas->drawText( "AA Scaled", strlen("AA Scaled"), fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fSize + 10), fCurPos.fY + fSize/2, paint ); + canvas->drawString( "AA Scaled", fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fSize + 10), fCurPos.fY + fSize/2, paint ); paint.setAntiAlias(false); for (size_t i = 0; i < SK_ARRAY_COUNT(gQualitys); ++i) { @@ -79,7 +79,7 @@ class SubpixelTranslateView : public SampleView { SkRect r = SkRect::MakeXYWH( fCurPos.fX + i * (fSize + 10), fCurPos.fY + fSize + 10, fSize, fSize ); canvas->drawBitmapRect( fBM, r, &paint ); } - canvas->drawText( "Scaled", strlen("Scaled"), fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fSize + 10), fCurPos.fY + fSize + 10 + fSize/2, paint ); + canvas->drawString( "Scaled", fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fSize + 10), fCurPos.fY + fSize + 10 + fSize/2, paint ); paint.setAntiAlias(true); for (size_t i = 0; i < SK_ARRAY_COUNT(gQualitys); ++i) { @@ -87,7 +87,7 @@ class SubpixelTranslateView : public SampleView { canvas->drawBitmap( fBM, fCurPos.fX + i * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10), &paint ); } - canvas->drawText( "AA No Scale", strlen("AA No Scale"), fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10) + fSize/2, paint ); + canvas->drawString( "AA No Scale", fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10) + fSize/2, paint ); paint.setAntiAlias(false); for (size_t i = 0; i < SK_ARRAY_COUNT(gQualitys); ++i) { @@ -95,7 +95,7 @@ class SubpixelTranslateView : public SampleView { canvas->drawBitmap( fBM, fCurPos.fX + i * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10) + fBM.height() + 10, &paint ); } - canvas->drawText( "No Scale", strlen("No Scale"), fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10) + fBM.height() + 10 + fSize/2, paint ); + canvas->drawString( "No Scale", fCurPos.fX + SK_ARRAY_COUNT(gQualitys) * (fBM.width() + 10), fCurPos.fY + 2*(fSize + 10) + fBM.height() + 10 + fSize/2, paint ); fCurPos.fX += fHorizontalVelocity; diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp index 8325cd775546..12f345cd330e 100644 --- a/samplecode/SampleText.cpp +++ b/samplecode/SampleText.cpp @@ -95,7 +95,7 @@ class TextSpeedView : public SampleView { paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag | SkPaint::kDevKernText_Flag); paint.setTextSize(SkIntToScalar(14)); - canvas.drawText(s, strlen(s), SkIntToScalar(8), SkIntToScalar(14), paint); + canvas.drawString(s, SkIntToScalar(8), SkIntToScalar(14), paint); } static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) { @@ -119,7 +119,7 @@ class TextSpeedView : public SampleView { // canvas->translate(0, SkIntToScalar(50)); - // canvas->drawText(style, strlen(style), SkIntToScalar(20), SkIntToScalar(20), paint); + // canvas->drawString(style, SkIntToScalar(20), SkIntToScalar(20), paint); paint.setTypeface(SkTypeface::MakeFromFile("/skimages/samplefont.ttf")); paint.setAntiAlias(true); diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp index 8286177ae7a9..c357e6d8c263 100644 --- a/samplecode/SampleTextAlpha.cpp +++ b/samplecode/SampleTextAlpha.cpp @@ -59,7 +59,7 @@ class TextAlphaView : public SampleView { paint.setColor(rand.nextU() | (0xFF << 24)); paint.setTextSize(SkIntToScalar(ps)); paint.setTextSize(SkIntToScalar(24)); - canvas->drawText(str, strlen(str), x, y, paint); + canvas->drawString(str, x, y, paint); y += paint.getFontMetrics(nullptr); } } diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp index 84346b0f7286..e09354ec7211 100644 --- a/samplecode/SampleTiling.cpp +++ b/samplecode/SampleTiling.cpp @@ -111,7 +111,7 @@ class TilingView : public SampleView { str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); p.setTextAlign(SkPaint::kCenter_Align); - textCanvas->drawText(str.c_str(), str.size(), x + r.width()/2, y, p); + textCanvas->drawString(str, x + r.width()/2, y, p); x += r.width() * 4 / 3; } @@ -143,7 +143,7 @@ class TilingView : public SampleView { p.setAntiAlias(true); p.setLooper(fLooper); str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); - textCanvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p); + textCanvas->drawString(str, x, y + r.height() * 2 / 3, p); } y += r.height() * 4 / 3; diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp index be42d23bbd7b..cd05fcffd448 100644 --- a/samplecode/SampleUnpremul.cpp +++ b/samplecode/SampleUnpremul.cpp @@ -93,7 +93,7 @@ class UnpremulView : public SampleView { } else { failure.printf("Failed to decode %s", fCurrFile.c_str()); } - canvas->drawText(failure.c_str(), failure.size(), 0, height, paint); + canvas->drawString(failure, 0, height, paint); return; } @@ -101,16 +101,16 @@ class UnpremulView : public SampleView { SkString header(SkOSPath::Basename(fCurrFile.c_str())); header.appendf(" [%dx%d] %s", fBitmap.width(), fBitmap.height(), (fPremul ? "premultiplied" : "unpremultiplied")); - canvas->drawText(header.c_str(), header.size(), 0, height, paint); + canvas->drawString(header, 0, height, paint); canvas->translate(0, height); // Help messages header.printf("Press '%c' to move to the next image.'", fNextImageChar); - canvas->drawText(header.c_str(), header.size(), 0, height, paint); + canvas->drawString(header, 0, height, paint); canvas->translate(0, height); header.printf("Press '%c' to toggle premultiplied decode.", fTogglePremulChar); - canvas->drawText(header.c_str(), header.size(), 0, height, paint); + canvas->drawString(header, 0, height, paint); // Now draw the image itself. canvas->translate(height * 2, height * 2); diff --git a/samplecode/SampleXfer.cpp b/samplecode/SampleXfer.cpp index 9ca2e78c0c1c..87427fc8f311 100644 --- a/samplecode/SampleXfer.cpp +++ b/samplecode/SampleXfer.cpp @@ -75,7 +75,7 @@ class PushButtonWig : public HasEventWig { paint.setTextSize(16); paint.setTextAlign(SkPaint::kCenter_Align); paint.setLCDRenderText(true); - canvas->drawText(fLabel.c_str(), fLabel.size(), r.centerX(), r.fTop + 0.68f * r.height(), paint); + canvas->drawString(fLabel, r.centerX(), r.fTop + 0.68f * r.height(), paint); } Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override { diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index 2a17e6b1b85c..ff198bcf8b2b 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -160,7 +160,7 @@ class XfermodesBlurView : public SampleView { canvas->drawRect(r, p); const char* label = SkBlendMode_Name(gModes[i]); - canvas->drawText(label, strlen(label), + canvas->drawString(label, x + w/2, y - labelP.getTextSize()/2, labelP); x += w + SkIntToScalar(10); if ((i % W) == W - 1) { diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index dc5f68fb808f..f339338f0c90 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -35,6 +35,7 @@ #include "SkShadowPaintFilterCanvas.h" #include "SkShadowShader.h" #include "SkSpecialImage.h" +#include "SkString.h" #include "SkSurface_Base.h" #include "SkTextBlob.h" #include "SkTextFormatParams.h" @@ -2575,6 +2576,10 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, fMCRec->fFilter = drawFilter; } +void SkCanvas::drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint) { + this->drawText(string.c_str(), string.size(), x, y, paint); +} + // These will become non-virtual, so they always call the (virtual) onDraw... method void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint) { diff --git a/src/gpu/ops/GrAAConvexTessellator.cpp b/src/gpu/ops/GrAAConvexTessellator.cpp index 5fa07fbcf969..aea7ce72aeb6 100644 --- a/src/gpu/ops/GrAAConvexTessellator.cpp +++ b/src/gpu/ops/GrAAConvexTessellator.cpp @@ -1049,7 +1049,7 @@ void GrAAConvexTessellator::Ring::draw(SkCanvas* canvas, const GrAAConvexTessell SkString num; num.printf("%d", this->origEdgeID(cur)); - canvas->drawText(num.c_str(), num.size(), mid.fX, mid.fY, paint); + canvas->drawString(num, mid.fX, mid.fY, paint); if (fPts.count()) { draw_arrow(canvas, tess.point(fPts[cur].fIndex), fPts[cur].fBisector, @@ -1094,7 +1094,7 @@ void GrAAConvexTessellator::draw(SkCanvas* canvas) const { SkString num; num.printf("%d", i); - canvas->drawText(num.c_str(), num.size(), + canvas->drawString(num, this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f), paint); } diff --git a/tests/DrawTextTest.cpp b/tests/DrawTextTest.cpp index a98b36f32102..2f8fe056eb5e 100644 --- a/tests/DrawTextTest.cpp +++ b/tests/DrawTextTest.cpp @@ -120,11 +120,11 @@ DEF_TEST(DrawText_weirdCoordinates, r) { SkScalar oddballs[] = { 0.0f, (float)INFINITY, (float)NAN, 34359738368.0f }; for (auto x : oddballs) { - canvas->drawText("a", 1, +x, 0.0f, SkPaint()); - canvas->drawText("a", 1, -x, 0.0f, SkPaint()); + canvas->drawString("a", +x, 0.0f, SkPaint()); + canvas->drawString("a", -x, 0.0f, SkPaint()); } for (auto y : oddballs) { - canvas->drawText("a", 1, 0.0f, +y, SkPaint()); - canvas->drawText("a", 1, 0.0f, -y, SkPaint()); + canvas->drawString("a", 0.0f, +y, SkPaint()); + canvas->drawString("a", 0.0f, -y, SkPaint()); } } diff --git a/tests/FlattenDrawableTest.cpp b/tests/FlattenDrawableTest.cpp index d8f5142867e5..9df8ba0b5b24 100644 --- a/tests/FlattenDrawableTest.cpp +++ b/tests/FlattenDrawableTest.cpp @@ -257,7 +257,7 @@ DEF_TEST(FlattenRecordedDrawable, r) { canvas->drawPaint(paint); SkPaint textPaint; textPaint.setColor(SK_ColorBLUE); - canvas->drawText("TEXT", 4, 467.0f, 100.0f, textPaint); + canvas->drawString("TEXT", 467.0f, 100.0f, textPaint); // Draw some drawables as well sk_sp drawable(new IntDrawable(1, 2, 3, 4)); diff --git a/tests/FontHostStreamTest.cpp b/tests/FontHostStreamTest.cpp index 2bb439b7915b..c3bc878da8c1 100644 --- a/tests/FontHostStreamTest.cpp +++ b/tests/FontHostStreamTest.cpp @@ -82,7 +82,7 @@ DEF_TEST(FontHostStream, reporter) { // Test: origTypeface and streamTypeface from orig data draw the same drawBG(&origCanvas); - origCanvas.drawText("A", 1, point.fX, point.fY, paint); + origCanvas.drawString("A", point.fX, point.fY, paint); sk_sp typeface(paint.getTypeface() ? paint.refTypeface() : SkTypeface::MakeDefault()); diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 8a19a226c6df..d8846448939d 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -738,14 +738,14 @@ DEF_TEST(ImageFilterDrawTiled, reporter) { SkScalar ypos = SkIntToScalar(height); untiledCanvas.save(); untiledCanvas.scale(SkIntToScalar(scale), SkIntToScalar(scale)); - untiledCanvas.drawText(text, strlen(text), 0, ypos, paint); + untiledCanvas.drawString(text, 0, ypos, paint); untiledCanvas.restore(); for (int y = 0; y < height; y += tileSize) { for (int x = 0; x < width; x += tileSize) { tiledCanvas.save(); tiledCanvas.clipRect(SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, tileSize))); tiledCanvas.scale(SkIntToScalar(scale), SkIntToScalar(scale)); - tiledCanvas.drawText(text, strlen(text), 0, ypos, paint); + tiledCanvas.drawString(text, 0, ypos, paint); tiledCanvas.restore(); } } diff --git a/tests/PDFDocumentTest.cpp b/tests/PDFDocumentTest.cpp index b3200156c617..f01d0f97f365 100644 --- a/tests/PDFDocumentTest.cpp +++ b/tests/PDFDocumentTest.cpp @@ -161,7 +161,7 @@ DEF_TEST(SkPDF_document_skbug_4734, r) { canvas->translate(20.0f, 10.0f); canvas->rotate(30.0f); const char text[] = "HELLO"; - canvas->drawText(text, strlen(text), 0, 0, SkPaint()); + canvas->drawString(text, 0, 0, SkPaint()); } static bool contains(const uint8_t* result, size_t size, const char expectation[]) { diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index fd4bf4ef78eb..0dc3bfe7b637 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -850,7 +850,7 @@ static void test_typeface(skiatest::Reporter* reporter) { SkPaint paint; paint.setTypeface(SkTypeface::MakeFromName("Arial", SkFontStyle::FromOldStyle(SkTypeface::kItalic))); - canvas->drawText("Q", 1, 0, 10, paint); + canvas->drawString("Q", 0, 10, paint); sk_sp picture(recorder.finishRecordingAsPicture()); SkDynamicMemoryWStream stream; picture->serialize(&stream); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index 10aec539fa2f..bb49df052822 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -438,7 +438,7 @@ static void draw_something(SkCanvas* canvas) { canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint); paint.setColor(SK_ColorBLACK); paint.setTextSize(SkIntToScalar(kBitmapSize/3)); - canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); + canvas->drawString("Picture", SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint); } DEF_TEST(Serialization, reporter) { diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 58ced7ebc0ab..aa351edf5641 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -332,7 +332,7 @@ static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface) EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0)) EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, testRect, nullptr)) EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, nullptr)) - EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testPaint)) + EXPECT_COPY_ON_WRITE(drawString(testText, 0, 1, testPaint)) EXPECT_COPY_ON_WRITE(drawPosText(testText.c_str(), testText.size(), testPoints2, \ testPaint)) EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testPath, nullptr, \ diff --git a/tools/colorspaceinfo.cpp b/tools/colorspaceinfo.cpp index 30880b9b254f..d605d507cae1 100644 --- a/tools/colorspaceinfo.cpp +++ b/tools/colorspaceinfo.cpp @@ -252,9 +252,9 @@ static void draw_gamut(SkCanvas* canvas, const SkMatrix44& xyz, const char* name paint.setTextSize(75.0f); canvas->drawPoints(SkCanvas::kPolygon_PointMode, 4, rgb, paint); if (label) { - canvas->drawText("R", 1, rgb[0].fX + 5.0f, rgb[0].fY + 75.0f, paint); - canvas->drawText("G", 1, rgb[1].fX + 5.0f, rgb[1].fY - 5.0f, paint); - canvas->drawText("B", 1, rgb[2].fX - 75.0f, rgb[2].fY - 5.0f, paint); + canvas->drawString("R", rgb[0].fX + 5.0f, rgb[0].fY + 75.0f, paint); + canvas->drawString("G", rgb[1].fX + 5.0f, rgb[1].fY - 5.0f, paint); + canvas->drawString("B", rgb[2].fX - 75.0f, rgb[2].fY - 5.0f, paint); } } diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index c69b17d72094..95f4cb1a6ea8 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -269,7 +269,7 @@ SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y, paint.setTextSize(SkIntToScalar(textSize)); canvas.clear(0x00000000); - canvas.drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint); + canvas.drawString(str, SkIntToScalar(x), SkIntToScalar(y), paint); // Tag data as sRGB (without doing any color space conversion). Color-space aware configs // will process this correctly but legacy configs will render as if this returned N32. diff --git a/tools/viewer/sk_app/CommandSet.cpp b/tools/viewer/sk_app/CommandSet.cpp index 689b97f86431..d0154d6e6178 100644 --- a/tools/viewer/sk_app/CommandSet.cpp +++ b/tools/viewer/sk_app/CommandSet.cpp @@ -138,14 +138,14 @@ void CommandSet::drawHelp(SkCanvas* canvas) { if (kGrouped_HelpMode == fHelpMode && lastGroup != cmd.fGroup) { // Group change. Advance and print header: y += paint.getTextSize(); - canvas->drawText(cmd.fGroup.c_str(), cmd.fGroup.size(), x, y, groupPaint); + canvas->drawString(cmd.fGroup, x, y, groupPaint); y += groupPaint.getTextSize() + 2; lastGroup = cmd.fGroup; } - canvas->drawText(cmd.fKeyName.c_str(), cmd.fKeyName.size(), x, y, paint); + canvas->drawString(cmd.fKeyName, x, y, paint); SkString text = SkStringPrintf(": %s", cmd.fDescription.c_str()); - canvas->drawText(text.c_str(), text.size(), x + keyWidth, y, paint); + canvas->drawString(text, x + keyWidth, y, paint); y += paint.getTextSize() + 2; } }