drawText Cleanup, part 2
Change-Id: I6765d623924d12c6eea2c402dd27eade61b73b66
Reviewed-on: https://skia-review.googlesource.com/c/182151
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp
index 78c7641..9366927 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -77,6 +77,9 @@
}
void onDraw(SkCanvas* canvas) override {
+ SkPaint textPaint;
+ SkFont font(sk_tool_utils::create_portable_typeface(), 12);
+
float scale = 32.f/kPOTSize;
int size = fPowerOfTwoSize ? kPOTSize : kNPOTSize;
@@ -99,7 +102,6 @@
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(10)/scale;
- SkFont font(sk_tool_utils::create_portable_typeface());
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
SkString str;
@@ -138,14 +140,8 @@
x += r.width() * 4 / 3;
}
}
- {
- SkPaint p;
- SkString str;
- p.setAntiAlias(true);
- sk_tool_utils::set_portable_typeface(&p);
- str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]);
- canvas->drawString(str, scale*x, scale*(y + r.height() * 2 / 3), p);
- }
+ canvas->drawString(SkStringPrintf("%s, %s", gColorTypeNames[i], gFilterNames[j]),
+ scale * x, scale * (y + r.height() * 2 / 3), font, textPaint);
y += r.height() * 4 / 3;
}