skia2/third_party/icu/SkLoadICU.h
Florin Malita 0c2add016d Revert "third_party/icu: use upstream"
This reverts commit e6cfe77185.

Reason for revert: Android & Win7 perf/test failures.


Original change's description:
> third_party/icu:  use upstream
> 
>     Change DEPS to point at upstream, not chromium's fork.
>     `skia_use_icu` defaults to true everywhere but iOS
>     Clean up SkLoadICU:  use U_ICUDATA_ENTRY_POINT, no DLL.
>     Add data dep to icu/icu.gni
>     Scripts: icu/{make_data_assembly.py,make_data_obj_win.py}
>     Scripts: icu/{update_icu.sh,build_icu_data_file.py} for rebuilding
>     document process in icu/README.md
> 
> Bug: skia:8702
> Change-Id: I99789749ba84ae737f6c62475d0d676cd36715bb
> Reviewed-on: https://skia-review.googlesource.com/c/186870
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Ben Wagner <bungeman@google.com>

TBR=halcanary@google.com,bungeman@google.com,fmalita@chromium.org,fmalita@google.com

Change-Id: Id379bc2be7d53eca67b2c557ac20bd44073a6258
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8702
Reviewed-on: https://skia-review.googlesource.com/c/189647
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-02-06 02:28:30 +00:00

53 lines
1.4 KiB
C

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef load_icu_DEFINED
#define load_icu_DEFINED
#include "SkTypes.h"
#ifdef SK_BUILD_FOR_WIN
#include "../private/SkLeanWindows.h"
#include "unicode/uvernum.h"
#include "unicode/udata.h"
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
inline void SkLoadICU() {
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) {
SK_ABORT("Failed to load " ICU_UTIL_DATA_SHARED_MODULE_NAME "\n");
}
FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
if (!addr) {
SK_ABORT("Symbol " ICU_UTIL_DATA_SYMBOL " missing in "
ICU_UTIL_DATA_SHARED_MODULE_NAME ".\n");
}
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setCommonData() returned %d.\n", (int)err);
SK_ABORT("");
}
udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setFileAccess() returned %d.\n", (int)err);
SK_ABORT("");
}
}
#undef ICU_UTIL_DATA_SHARED_MODULE_NAME
#undef ICU_UTIL_DATA_SYMBOL
#else
inline void SkLoadICU() {}
#endif // SK_BUILD_FOR_WIN
#endif // load_icu_DEFINED