Mutex protect SkFontMgr_DirectWrite cache.
SkFontMgr_DirectWrite is constant, except for its typeface cache. Protect this cache in the face of multiple threads. R=robertphillips@google.com Review URL: https://codereview.chromium.org/26023002 git-svn-id: http://skia.googlecode.com/svn/trunk@11615 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
86490573b5
commit
86dd752bd5
@ -113,6 +113,18 @@ protected:
|
||||
unsigned styleBits) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkMutex fTFCacheMutex;
|
||||
void Add(SkTypeface* face, SkTypeface::Style requestedStyle, bool strong) {
|
||||
SkAutoMutexAcquire ama(fTFCacheMutex);
|
||||
fTFCache.add(face, requestedStyle, strong);
|
||||
}
|
||||
|
||||
SkTypeface* FindByProcAndRef(SkTypefaceCache::FindProc proc, void* ctx) {
|
||||
SkAutoMutexAcquire ama(fTFCacheMutex);
|
||||
SkTypeface* typeface = fTFCache.findByProcAndRef(proc, ctx);
|
||||
return typeface;
|
||||
}
|
||||
|
||||
friend class SkFontStyleSet_DirectWrite;
|
||||
SkTScopedComPtr<IDWriteFontCollection> fFontCollection;
|
||||
SkSMallocWCHAR fLocaleName;
|
||||
@ -1710,12 +1722,12 @@ SkTypeface* SkFontMgr_DirectWrite::createTypefaceFromDWriteFont(
|
||||
IDWriteFontFamily* fontFamily,
|
||||
StreamFontFileLoader* fontFileLoader,
|
||||
IDWriteFontCollectionLoader* fontCollectionLoader) {
|
||||
SkTypeface* face = fTFCache.findByProcAndRef(FindByDWriteFont, font);
|
||||
SkTypeface* face = FindByProcAndRef(FindByDWriteFont, font);
|
||||
if (NULL == face) {
|
||||
face = DWriteFontTypeface::Create(fontFace, font, fontFamily,
|
||||
fontFileLoader, fontCollectionLoader);
|
||||
if (face) {
|
||||
fTFCache.add(face, get_style(font), fontCollectionLoader != NULL);
|
||||
Add(face, get_style(font), fontCollectionLoader != NULL);
|
||||
}
|
||||
}
|
||||
return face;
|
||||
|
Loading…
Reference in New Issue
Block a user