diff --git a/gn/skia.gni b/gn/skia.gni index b0d46a5e12..09283d5963 100644 --- a/gn/skia.gni +++ b/gn/skia.gni @@ -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 diff --git a/modules/skshaper/BUILD.gn b/modules/skshaper/BUILD.gn index 431f7af9f7..198c037fa9 100644 --- a/modules/skshaper/BUILD.gn +++ b/modules/skshaper/BUILD.gn @@ -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") { diff --git a/modules/skshaper/src/SkUnicode_icu.cpp b/modules/skshaper/src/SkUnicode_icu.cpp index ce420d80dd..c62f2ef893 100644 --- a/modules/skshaper/src/SkUnicode_icu.cpp +++ b/modules/skshaper/src/SkUnicode_icu.cpp @@ -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 using void_t = void; +template +struct SkUbrkClone { + UBreakIterator* operator()(T bi, UErrorCode* status) { + return ubrk_safeClone(bi, nullptr, nullptr, status); + } +}; +template +struct SkUbrkClone(), nullptr))>> { + UBreakIterator* operator()(T bi, UErrorCode* status) { + return ubrk_clone(bi, status); + } +}; + using SkUnicodeBidi = std::unique_ptr>; using ICUUText = std::unique_ptr>; using ICUBreakIterator = std::unique_ptr>; @@ -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()(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 {