Remove mutex for retrieving default typeface.

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.",
0265707c19).

Review-Url: https://codereview.chromium.org/1994703003
This commit is contained in:
bungeman 2016-05-19 11:23:55 -07:00 committed by Commit bot
parent 66a96d07d5
commit c989e1851e

View File

@ -78,19 +78,12 @@ protected:
} }
SK_DECLARE_STATIC_MUTEX(gCreateDefaultMutex);
SkTypeface* SkTypeface::GetDefaultTypeface(Style style) { SkTypeface* SkTypeface::GetDefaultTypeface(Style style) {
static SkOnce once[4]; static SkOnce once[4];
static SkTypeface* defaults[4]; static SkTypeface* defaults[4];
SkASSERT((int)style < 4); SkASSERT((int)style < 4);
once[style]([style] { 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()); SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
SkTypeface* t = fm->legacyCreateTypeface(nullptr, SkFontStyle::FromOldStyle(style)); SkTypeface* t = fm->legacyCreateTypeface(nullptr, SkFontStyle::FromOldStyle(style));
defaults[style] = t ? t : SkEmptyTypeface::Create(); defaults[style] = t ? t : SkEmptyTypeface::Create();