aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_win_dw.cpp
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-04 17:00:35 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-04 17:00:35 +0000
commit86dd752bd5c42352b7acb05551070da8d609c563 (patch)
tree194bfc8fab3866a5e587d5668667c14b1aca6426 /src/ports/SkFontHost_win_dw.cpp
parent86490573b5cba554a27637e22485455a7b133de7 (diff)
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
Diffstat (limited to 'src/ports/SkFontHost_win_dw.cpp')
-rw-r--r--src/ports/SkFontHost_win_dw.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index cc9674e946..1ab0b7e92b 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/ports/SkFontHost_win_dw.cpp
@@ -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;