From f107a2fd014cd39c489060f2cd1b99cd49c7d0be Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Wed, 25 Jul 2018 16:52:48 -0400 Subject: 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 Commit-Queue: Hal Canary --- samplecode/SampleRectanizer.cpp | 4 ++-- samplecode/SampleUnpremul.cpp | 4 ++-- samplecode/SampleXfermodesBlur.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'samplecode') diff --git a/samplecode/SampleRectanizer.cpp b/samplecode/SampleRectanizer.cpp index 752d5b7136..d402416ca5 100644 --- a/samplecode/SampleRectanizer.cpp +++ b/samplecode/SampleRectanizer.cpp @@ -59,8 +59,8 @@ protected: } SkUnichar uni; if (SampleCode::CharQ(*evt, &uni)) { - char utf8[kMaxBytesInUTF8Sequence]; - size_t size = SkUTF8_FromUnichar(uni, utf8); + char utf8[SkUTF::kMaxBytesInUTF8Sequence]; + size_t size = SkUTF::ToUTF8(uni, utf8); // Only consider events for single char keys if (1 == size) { switch (utf8[0]) { diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp index 108d70914f..4f41418158 100644 --- a/samplecode/SampleUnpremul.cpp +++ b/samplecode/SampleUnpremul.cpp @@ -53,8 +53,8 @@ protected: } SkUnichar uni; if (SampleCode::CharQ(*evt, &uni)) { - char utf8[kMaxBytesInUTF8Sequence]; - size_t size = SkUTF8_FromUnichar(uni, utf8); + char utf8[SkUTF::kMaxBytesInUTF8Sequence]; + size_t size = SkUTF::ToUTF8(uni, utf8); // Only consider events for single char keys if (1 == size) { switch (utf8[0]) { diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index 37b859288b..0ef144ef18 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -90,7 +90,7 @@ protected: paint.setTextSize(50); paint.setTypeface(SkTypeface::MakeFromName("Arial Unicode MS", SkFontStyle())); char buffer[10]; - size_t len = SkUTF8_FromUnichar(0x8500, buffer); + size_t len = SkUTF::ToUTF8(0x8500, buffer); canvas->drawText(buffer, len, 40, 40, paint); return; } -- cgit v1.2.3