diff options
author | Hal Canary <halcanary@google.com> | 2018-07-25 16:52:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-31 20:11:19 +0000 |
commit | f107a2fd014cd39c489060f2cd1b99cd49c7d0be (patch) | |
tree | 5c324821344901869203bbe055be8d3f69f696cb /gm | |
parent | 1935aa3d27cd4ed4aef2dc04360f247a541d4b00 (diff) |
SkUTF
Create new header and namespace, `SkUTF` where we are putting all of our
robust, well documented UTF-8, UTF-16, and UTF-32 functions:
`SkUTF::{Count,Next,To}UTF{8,16,32}()`.
SkUTF.h and SkUTF.cpp do not depend on the rest of Skia and are suitable
for re-use in other modules.
Some of the old UTF-{8,16} functions still live in SkUtils.h; their use
will be phased out in future CLs.
Also added more unit testing and cleaned up old tests.
Removed functions that were unused outside of tests or used only once.
Change-Id: Iaa59b8705abccf9c4ba082f855da368a0bad8380
Reviewed-on: https://skia-review.googlesource.com/143306
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/atlastext.cpp | 2 | ||||
-rw-r--r-- | gm/coloremoji_blendmodes.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/gm/atlastext.cpp b/gm/atlastext.cpp index 859b4c356f..e3fed2ee06 100644 --- a/gm/atlastext.cpp +++ b/gm/atlastext.cpp @@ -30,7 +30,7 @@ static SkScalar draw_string(SkAtlasTextTarget* target, const SkString& text, SkS return x; } auto font = SkAtlasTextFont::Make(typeface, size); - int cnt = SkUTF8_CountUnichars(text.c_str(), text.size()); + int cnt = SkUTF::CountUTF8(text.c_str(), text.size()); std::unique_ptr<SkGlyphID[]> glyphs(new SkGlyphID[cnt]); typeface->charsToGlyphs(text.c_str(), SkTypeface::Encoding::kUTF8_Encoding, glyphs.get(), cnt); diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp index 872527404c..46ba67ec90 100644 --- a/gm/coloremoji_blendmodes.cpp +++ b/gm/coloremoji_blendmodes.cpp @@ -148,7 +148,8 @@ protected: textP.setBlendMode(gModes[i]); textP.setTextEncoding(SkPaint::kUTF32_TextEncoding); const char* text = sk_tool_utils::emoji_sample_text(); - SkUnichar unichar = SkUTF8_NextUnichar(&text, text + strlen(text)); + SkUnichar unichar = SkUTF::NextUTF8(&text, text + strlen(text)); + SkASSERT(unichar >= 0); canvas->drawText(&unichar, 4, x+ w/10.f, y + 7.f*h/8.f, textP); } #if 1 |