[Fuchsia] Add cache mutex in SkFontMgr_Fuchsia
SkFontMgr_Fuchsia::GetOrCreateTypeface() may be called from multiple threads, but it wasn't thread-safe. Added a mutex that's used to synchronize access to fTypefaceCache. Bug: chromium:1316932 Change-Id: Ic6c0f4c4af01a8630cece3e6864a3cb304d8ef63 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541078 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
3b4f862d05
commit
13980102a5
@ -304,7 +304,9 @@ private:
|
||||
mutable fuchsia::fonts::ProviderSyncPtr fFontProvider;
|
||||
|
||||
sk_sp<SkFuchsiaFontDataCache> fBufferCache;
|
||||
mutable SkTypefaceCache fTypefaceCache;
|
||||
|
||||
mutable SkMutex fCacheMutex;
|
||||
mutable SkTypefaceCache fTypefaceCache SK_GUARDED_BY(fCacheMutex);
|
||||
};
|
||||
|
||||
class SkFontStyleSet_Fuchsia : public SkFontStyleSet {
|
||||
@ -494,6 +496,8 @@ static bool FindByTypefaceId(SkTypeface* cachedTypeface, void* ctx) {
|
||||
|
||||
sk_sp<SkTypeface> SkFontMgr_Fuchsia::GetOrCreateTypeface(TypefaceId id,
|
||||
const fuchsia::mem::Buffer& buffer) const {
|
||||
SkAutoMutexExclusive mutexLock(fCacheMutex);
|
||||
|
||||
sk_sp<SkTypeface> cached = fTypefaceCache.findByProcAndRef(FindByTypefaceId, &id);
|
||||
if (cached) return cached;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user