From 2ed78209704418aebfb99e858866af249da594c7 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Wed, 21 Nov 2018 15:10:08 -0500 Subject: use SkFont in a lot of places Bug: skia: Change-Id: I86df3f650eb5bb0219b3251ef5f8e95403838bba Reviewed-on: https://skia-review.googlesource.com/c/172482 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- bench/TextBlobBench.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'bench/TextBlobBench.cpp') diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp index b517d26848..d0d9b0412a 100644 --- a/bench/TextBlobBench.cpp +++ b/bench/TextBlobBench.cpp @@ -8,6 +8,7 @@ #include "Benchmark.h" #include "Resources.h" #include "SkCanvas.h" +#include "SkFont.h" #include "SkPaint.h" #include "SkRandom.h" #include "SkStream.h" @@ -26,22 +27,19 @@ public: SkTextBlobBench() {} void onDelayedSetup() override { - fPaint.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle())); - fPaint.setTextEncoding(SkPaint::kUTF8_TextEncoding); + fFont.setTypeface(sk_tool_utils::create_portable_typeface("serif", SkFontStyle())); + fFont.setSubpixel(true); // This text seems representative in both length and letter frequency. const char* text = "Keep your sentences short, but not overly so."; - fGlyphs.setCount(fPaint.textToGlyphs(text, strlen(text), nullptr)); - fPaint.textToGlyphs(text, strlen(text), fGlyphs.begin()); - - fPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); - fPaint.setSubpixelText(true); + fGlyphs.setCount(fFont.countText(text, strlen(text), kUTF8_SkTextEncoding)); + fFont.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count()); } sk_sp makeBlob() { const SkTextBlobBuilder::RunBuffer& run = - fBuilder.allocRunPosH(fPaint, fGlyphs.count(), 10, nullptr); + fBuilder.allocRunPosH(fFont, fGlyphs.count(), 10, nullptr); for (int i = 0; i < fGlyphs.count(); i++) { run.glyphs[i] = fGlyphs[i]; run. pos[i] = (i+1) * 10.125; @@ -50,9 +48,9 @@ public: } private: - SkTextBlobBuilder fBuilder; - SkPaint fPaint; - SkTDArray fGlyphs; + SkTextBlobBuilder fBuilder; + SkFont fFont; + SkTDArray fGlyphs; typedef Benchmark INHERITED; }; -- cgit v1.2.3