Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Unified Diff: src/ports/SkFontHost_win_dw.cpp

Issue 26023002: Mutex protect SkFontMgr_DirectWrite cache. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win_dw.cpp
===================================================================
--- src/ports/SkFontHost_win_dw.cpp (revision 11593)
+++ src/ports/SkFontHost_win_dw.cpp (working copy)
@@ -113,6 +113,18 @@
unsigned styleBits) SK_OVERRIDE;
private:
robertphillips 2013/10/04 16:34:50 make fTFCacheMutex?
bungeman-skia 2013/10/04 17:00:14 Done.
+ SkMutex tfMutex;
+ void Add(SkTypeface* face, SkTypeface::Style requestedStyle, bool strong) {
+ SkAutoMutexAcquire ama(tfMutex);
+ fTFCache.add(face, requestedStyle, strong);
+ }
+
+ SkTypeface* FindByProcAndRef(SkTypefaceCache::FindProc proc, void* ctx) {
+ SkAutoMutexAcquire ama(tfMutex);
+ SkTypeface* typeface = fTFCache.findByProcAndRef(proc, ctx);
+ return typeface;
+ }
+
friend class SkFontStyleSet_DirectWrite;
SkTScopedComPtr<IDWriteFontCollection> fFontCollection;
SkSMallocWCHAR fLocaleName;
@@ -1710,12 +1722,12 @@
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698