Remove mutex for retrieving default typeface.
authorbungeman <bungeman@google.com>
Thu, 19 May 2016 18:23:55 +0000 (11:23 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 19 May 2016 18:23:55 +0000 (11:23 -0700)
This mutex was added due to FontConfigTypeface::LegacyCreateTypeface
being non-thread safe. This method no longer exists and the logic was
moved to SkFontMgr_FCI::onLegacyCreateTypeface which has access to an
appropriate mutex ("Clean up SkFontConfigInterface implementation.",
0265707c191a31dfde08dd1cd7011c1fe5b8e643).

Review-Url: https://codereview.chromium.org/1994703003

src/core/SkTypeface.cpp

index 3c15878..ba9e765 100644 (file)
@@ -78,19 +78,12 @@ protected:
 
 }
 
-SK_DECLARE_STATIC_MUTEX(gCreateDefaultMutex);
-
 SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
     static SkOnce once[4];
     static SkTypeface* defaults[4];
 
     SkASSERT((int)style < 4);
     once[style]([style] {
-        // It is not safe to call FontConfigTypeface::LegacyCreateTypeface concurrently.
-        // To be safe, we serialize here with a mutex so only one call to
-        // CreateTypeface is happening at any given time.
-        // TODO(bungeman, mtklein): This is sad.  Make our fontconfig code safe?
-        SkAutoMutexAcquire lock(&gCreateDefaultMutex);
         SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
         SkTypeface* t = fm->legacyCreateTypeface(nullptr, SkFontStyle::FromOldStyle(style));
         defaults[style] = t ? t : SkEmptyTypeface::Create();