From: yangsu@google.com Date: Fri, 24 Jun 2011 18:54:08 +0000 (+0000) Subject: Added mutex in GetDefaultFont and added the default font to the FontCache when it... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~18164 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57d73d628dad2e1a67532d7153603662ec91741d;p=platform%2Fupstream%2FlibSkiaSharp.git Added mutex in GetDefaultFont and added the default font to the FontCache when it's first created git-svn-id: http://skia.googlecode.com/svn/trunk@1711 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp index a48c365..d6b1ecb 100644 --- a/src/ports/SkFontHost_mac_coretext.cpp +++ b/src/ports/SkFontHost_mac_coretext.cpp @@ -21,6 +21,7 @@ #ifdef SK_BUILD_FOR_IOS #include #include +#include #endif #include "SkFontHost.h" @@ -30,6 +31,7 @@ #include "SkPaint.h" #include "SkString.h" #include "SkStream.h" +#include "SkThread.h" #include "SkTypeface_mac.h" #include "SkUtils.h" #include "SkTypefaceCache.h" @@ -155,10 +157,14 @@ static CTFontRef GetFontRefFromFontID(SkFontID fontID) { } static SkTypeface* GetDefaultFace() { + static SkMutex gMutex; + SkAutoMutexAcquire ma(gMutex); + static SkTypeface* gDefaultFace; if (NULL == gDefaultFace) { gDefaultFace = NewFromName(FONT_DEFAULT_NAME, SkTypeface::kNormal); + SkTypefaceCache::Add(gDefaultFace, SkTypeface::kNormal); } return gDefaultFace; }