Revert the workaround for missing ICU API ubrk_safeClone

Bug: skia:11315
Change-Id: Iee619517b687dc722d99e73821954cadb790d98a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378977
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
This commit is contained in:
Julia Lavrova 2021-03-03 10:19:41 -05:00 committed by Skia Commit-Bot
parent 3fa0cdada7
commit 4414f87fa1
3 changed files with 17 additions and 21 deletions

View File

@ -20,7 +20,6 @@ declare_args() {
skia_enable_fontmgr_fuchsia = is_fuchsia
skia_enable_fontmgr_win = is_win
skia_enable_gpu = true
skia_enable_icu_ubrk_safeclone = false
skia_enable_pdf = true
skia_enable_skottie = !(is_win && is_component_build)
skia_enable_skrive = true

View File

@ -20,9 +20,6 @@ if (skia_enable_skshaper) {
defines += [ "SK_SHAPER_HARFBUZZ_AVAILABLE" ]
defines += [ "SK_UNICODE_AVAILABLE" ]
}
if (skia_enable_icu_ubrk_safeclone) {
defines += [ "SK_ENABLE_ICU_UBRK_SAFECLONE" ]
}
}
component("skshaper") {

View File

@ -24,6 +24,22 @@
#include "SkLoadICU.h"
#endif
// ubrk_clone added as draft in ICU69 and Android API 31 (first ICU NDK).
// ubrk_safeClone deprecated in ICU69 and not exposed by Android.
template<typename...> using void_t = void;
template<typename T, typename = void>
struct SkUbrkClone {
UBreakIterator* operator()(T bi, UErrorCode* status) {
return ubrk_safeClone(bi, nullptr, nullptr, status);
}
};
template<typename T>
struct SkUbrkClone<T, void_t<decltype(ubrk_clone(std::declval<T>(), nullptr))>> {
UBreakIterator* operator()(T bi, UErrorCode* status) {
return ubrk_clone(bi, status);
}
};
using SkUnicodeBidi = std::unique_ptr<UBiDi, SkFunctionWrapper<decltype(ubidi_close), ubidi_close>>;
using ICUUText = std::unique_ptr<UText, SkFunctionWrapper<decltype(utext_close), utext_close>>;
using ICUBreakIterator = std::unique_ptr<UBreakIterator, SkFunctionWrapper<decltype(ubrk_close), ubrk_close>>;
@ -179,8 +195,6 @@ class SkIcuBreakIteratorCache {
return instance;
}
#ifdef SK_ENABLE_ICU_UBRK_SAFECLONE
ICUBreakIterator makeBreakIterator(SkUnicode::BreakType type) {
UErrorCode status = U_ZERO_ERROR;
ICUBreakIterator* cachedIterator;
@ -198,27 +212,13 @@ class SkIcuBreakIteratorCache {
}
ICUBreakIterator iterator;
if (cachedIterator) {
iterator.reset(ubrk_safeClone(cachedIterator->get(), nullptr, nullptr, &status));
iterator.reset(SkUbrkClone<const UBreakIterator*>()(cachedIterator->get(), &status));
if (U_FAILURE(status)) {
SkDEBUGF("Break error: %s", u_errorName(status));
}
}
return iterator;
}
#else // SK_ENABLE_ICU_UBRK_SAFECLONE
ICUBreakIterator makeBreakIterator(SkUnicode::BreakType type) {
UErrorCode status = U_ZERO_ERROR;
ICUBreakIterator iterator(ubrk_open(convertType(type), uloc_getDefault(), nullptr, 0, &status));
if (U_FAILURE(status)) {
SkDEBUGF("Break error: %s", u_errorName(status));
}
return iterator;
}
#endif // SK_ENABLE_ICU_UBRK_SAFECLONE
};
class SkScriptIterator_icu : public SkScriptIterator {