diff options
author | Seigo Nonaka <nona@google.com> | 2021-04-17 22:43:45 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-04-17 22:43:45 +0000 |
commit | e15a7768ae2230afd48d7a0359f221ddcdc7d0dd (patch) | |
tree | 7719cfa78b77359036ab330e1ffe1b11f324cf4b | |
parent | 03d9007a6915c20fe226d6e7f42aae910a3662b3 (diff) | |
parent | b67f9c4a19d87a49501765ffdc1cfca1457c003d (diff) | |
download | minikin-e15a7768ae2230afd48d7a0359f221ddcdc7d0dd.tar.gz |
Update native font API to read updated font files am: b67f9c4a19
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/minikin/+/14193063
Change-Id: I5a939934bc4f802f2d4c68992ceeeb5bf3750a48
-rw-r--r-- | include/minikin/SystemFonts.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/minikin/SystemFonts.h b/include/minikin/SystemFonts.h index 686f32e..616997d 100644 --- a/include/minikin/SystemFonts.h +++ b/include/minikin/SystemFonts.h @@ -43,6 +43,18 @@ public: return getInstance().registerDefaultInternal(fc); } + using FontMapDeleter = std::function<void()>; + + static void addFontMap(std::shared_ptr<FontCollection>&& collections) { + return getInstance().addFontMapInternal(std::move(collections)); + } + + // This obtains a mutex inside, so do not call this method inside callback. + static void getFontMap( + std::function<void(const std::vector<std::shared_ptr<FontCollection>>&)> func) { + return getInstance().getFontMapInternal(func); + } + protected: // Visible for testing purposes. SystemFonts() {} @@ -60,11 +72,24 @@ protected: mDefaultFallback = fc; } + void addFontMapInternal(std::shared_ptr<FontCollection>&& collections) { + std::lock_guard<std::mutex> lock(mMutex); + mCollections.emplace_back(std::move(collections)); + } + + void getFontMapInternal( + std::function<void(const std::vector<std::shared_ptr<FontCollection>>&)> func) { + std::lock_guard<std::mutex> lock(mMutex); + func(mCollections); + } + private: static SystemFonts& getInstance(); std::map<std::string, std::shared_ptr<FontCollection>> mSystemFallbacks GUARDED_BY(mMutex); std::shared_ptr<FontCollection> mDefaultFallback GUARDED_BY(mMutex); + std::vector<std::shared_ptr<FontCollection>> mCollections GUARDED_BY(mMutex); + std::mutex mMutex; }; |