diff options
author | Mike Reed <reed@google.com> | 2018-11-21 15:10:08 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-11-21 20:44:03 +0000 |
commit | 2ed78209704418aebfb99e858866af249da594c7 (patch) | |
tree | 46541338da544799cbbb27c4c0be5fbd379eb65b /bench | |
parent | 3065b5223dc44050753d973d77fbc8e6429f0649 (diff) | |
download | skqp-2ed78209704418aebfb99e858866af249da594c7.tar.gz |
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 <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'bench')
-rw-r--r-- | bench/TextBlobBench.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
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<SkTextBlob> 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<uint16_t> fGlyphs; + SkTextBlobBuilder fBuilder; + SkFont fFont; + SkTDArray<uint16_t> fGlyphs; typedef Benchmark INHERITED; }; |