update more gms to use textutils

Bug: skia:
Change-Id: I90f434b56e07c88b9de58be531c7a73fe385ca05
Reviewed-on: https://skia-review.googlesource.com/c/165140
Commit-Queue: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Mike Reed 2018-10-25 16:12:39 -04:00 committed by Skia Commit-Bot
parent 2cf29ce4db
commit 71f5a0b56d
8 changed files with 21 additions and 19 deletions

View File

@ -20,6 +20,7 @@
#include "SkShader.h"
#include "SkSize.h"
#include "SkString.h"
#include "SkTextUtils.h"
#include "SkTypeface.h"
#include "SkTypes.h"
#include "SkUTF.h"
@ -116,7 +117,6 @@ protected:
SkPaint labelP;
labelP.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&labelP);
labelP.setTextAlign(SkPaint::kCenter_Align);
SkPaint textP;
textP.setAntiAlias(true);
@ -154,7 +154,8 @@ protected:
}
#if 1
const char* label = SkBlendMode_Name(gModes[i]);
canvas->drawString(label, x + w/2, y - labelP.getTextSize()/2, labelP);
SkTextUtils::DrawString(canvas, label, x + w/2, y - labelP.getTextSize()/2, labelP,
SkPaint::kCenter_Align);
#endif
x += w + SkIntToScalar(10);
if ((i % W) == W - 1) {

View File

@ -8,9 +8,9 @@
#include "gm.h"
#include "sk_tool_utils.h"
#include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h"
#include "SkDropShadowImageFilter.h"
#include "SkTextUtils.h"
///////////////////////////////////////////////////////////////////////////////
@ -42,10 +42,10 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> im
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(r.height()/2);
paint.setTextAlign(SkPaint::kCenter_Align);
canvas->save();
canvas->clipRect(r);
canvas->drawString("Text", r.centerX(), r.centerY(), paint);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), paint,
SkPaint::kCenter_Align);
canvas->restore();
}

View File

@ -12,6 +12,7 @@
#include "SkColorPriv.h"
#include "SkImageFilterPriv.h"
#include "SkShader.h"
#include "SkTextUtils.h"
#include "SkBlurImageFilter.h"
#include "SkColorFilterImageFilter.h"
@ -129,8 +130,8 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> im
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(r.height()/2);
paint.setTextAlign(SkPaint::kCenter_Align);
canvas->drawString("Text", r.centerX(), r.centerY(), paint);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), paint,
SkPaint::kCenter_Align);
}
static void draw_bitmap(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {

View File

@ -11,6 +11,7 @@
#include "SkColorFilter.h"
#include "SkColorPriv.h"
#include "SkShader.h"
#include "SkTextUtils.h"
#include "SkBlurImageFilter.h"
#include "SkMorphologyImageFilter.h"
@ -45,8 +46,8 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> im
paint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&paint);
paint.setTextSize(r.height()/2);
paint.setTextAlign(SkPaint::kCenter_Align);
canvas->drawString("Text", r.centerX(), r.centerY(), paint);
SkTextUtils::DrawString(canvas, "Text", r.centerX(), r.centerY(), paint,
SkPaint::kCenter_Align);
}
static void draw_bitmap(SkCanvas* canvas, const SkRect& r, sk_sp<SkImageFilter> imf) {

View File

@ -72,8 +72,6 @@ protected:
paint.setAntiAlias(true);
paint.setStrokeWidth(10);
paint.setStyle(SkPaint::kStroke_Style);
paint.setTextSize(48);
paint.setTextAlign(SkPaint::kCenter_Align);
for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) {
canvas->translate(0, margin);

View File

@ -9,6 +9,7 @@
#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkPath.h"
#include "SkTextUtils.h"
#include "SkTypeface.h"
class SkJSCanvas {
@ -219,7 +220,8 @@ protected:
SkScalar x = D/2;
SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
uint16_t glyphID = 3; // X
canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint);
SkTextUtils::DrawText(canvas, &glyphID, sizeof(glyphID), x, y, *paint,
SkPaint::kCenter_Align);
canvas->restore();
}
@ -236,7 +238,6 @@ protected:
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setStrokeWidth(SkIntToScalar(4));
paint.setTextSize(SkIntToScalar(40));
paint.setTextAlign(SkPaint::kCenter_Align);
canvas->save();
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));

View File

@ -6,13 +6,13 @@
*/
#include "gm.h"
#include "SkTextUtils.h"
// http://bug.skia.org/7315
DEF_SIMPLE_GM(text_scale_skew, canvas, 256, 128) {
SkPaint p;
p.setTextSize(18.0f);
p.setAntiAlias(true);
p.setTextAlign(SkPaint::kCenter_Align);
float y = 10.0f;
for (float scale : { 0.5f, 0.71f, 1.0f, 1.41f, 2.0f }) {
p.setTextScaleX(scale);
@ -20,7 +20,7 @@ DEF_SIMPLE_GM(text_scale_skew, canvas, 256, 128) {
float x = 50.0f;
for (float skew : { -0.5f, 0.0f, 0.5f }) {
p.setTextSkewX(skew);
canvas->drawString("Skia", x, y, p);
SkTextUtils::DrawString(canvas, "Skia", x, y, p, SkPaint::kCenter_Align);
x += 78.0f;
}
}

View File

@ -11,6 +11,7 @@
#include "SkColorPriv.h"
#include "SkImageGenerator.h"
#include "SkPath.h"
#include "SkTextUtils.h"
#include "SkYUVAIndex.h"
#if SK_SUPPORT_GPU
@ -621,7 +622,6 @@ static void draw_col_label(SkCanvas* canvas, int x, int yuvColorSpace, bool opaq
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVColorSpaceNames) == kLastEnum_SkYUVColorSpace+1);
SkPaint textPaint;
textPaint.setTextAlign(SkPaint::kCenter_Align);
sk_tool_utils::set_portable_typeface(&textPaint, nullptr, SkFontStyle::Bold());
textPaint.setTextSize(16);
@ -632,13 +632,14 @@ static void draw_col_label(SkCanvas* canvas, int x, int yuvColorSpace, bool opaq
textPaint.measureText(colLabel.c_str(), colLabel.size(), &textRect);
int y = textRect.height();
canvas->drawText(colLabel.c_str(), colLabel.size(), x, y, textPaint);
SkTextUtils::DrawString(canvas, colLabel, x, y, textPaint, SkPaint::kCenter_Align);
colLabel.printf("%s", opaque ? "Opaque" : "Transparent");
textPaint.measureText(colLabel.c_str(), colLabel.size(), &textRect);
y += textRect.height();
canvas->drawText(colLabel.c_str(), colLabel.size(), x, y, textPaint);
SkTextUtils::DrawString(canvas, colLabel, x, y, textPaint, SkPaint::kCenter_Align);
}
static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) {
@ -646,7 +647,6 @@ static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) {
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kYUVFormatNames) == kLast_YUVFormat+1);
SkPaint textPaint;
textPaint.setTextAlign(SkPaint::kLeft_Align);
sk_tool_utils::set_portable_typeface(&textPaint, nullptr, SkFontStyle::Bold());
textPaint.setTextSize(16);