Revert of Fix race condition in parallel font initialization. (https://codereview.chromium.org/355573006/)

Reason for revert:
canaries still slightly broken

Original issue's description:
> Fix race condition in parallel font initialization.
>
> Uses a mutex to guard construction of the singleton, which initialies
> the non-threadsafe libfontconfig.  Without this change, the parallel
> path ops test runner crashes 6/10 and hangs 2/10 on startup; with this
> change, 0/10 problems.
>
> BUG=skia:2693
> R=mtklein@google.com,bungeman@google.com
>
> Committed: https://skia.googlesource.com/skia/+/df022f5972ae6a2a1d96d15c50eca52cade3abd8
>
> Committed: https://skia.googlesource.com/skia/+/60b08a0adfe73f593af62c8d3f55958438360e1b

R=bungeman@google.com, reed@google.com, tomhudson@google.com, tomhudson@chromium.org
TBR=bungeman@google.com, reed@google.com, tomhudson@chromium.org, tomhudson@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2693

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/354133004
This commit is contained in:
mtklein 2014-07-01 13:33:32 -07:00 committed by Commit bot
parent f0aed97aec
commit e41f3886ea
4 changed files with 6 additions and 14 deletions

View File

@ -14,8 +14,6 @@
#include "SkTArray.h"
#include "SkTypeface.h"
struct SkBaseMutex;
/**
* \class SkFontConfigInterface
*
@ -97,9 +95,8 @@ public:
/**
* Return a singleton instance of a direct subclass that calls into
* libfontconfig. This does not affect the refcnt of the returned instance.
* The mutex may be used to guarantee the singleton is only constructed once.
*/
static SkFontConfigInterface* GetSingletonDirectInterface(SkBaseMutex* mutex);
static SkFontConfigInterface* GetSingletonDirectInterface();
// New APIS, which have default impls for now (which do nothing)

View File

@ -155,8 +155,7 @@ static SkFontConfigInterfaceAndroid* getSingletonInterface() {
return gFontConfigInterface;
}
SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBaseMutex*) {
// Doesn't need passed-in mutex because getSingletonInterface() uses one
SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
return getSingletonInterface();
}

View File

@ -124,13 +124,9 @@ private:
SkMutex mutex_;
};
SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface(SkBaseMutex* mutex) {
SkAutoMutexAcquire ac(mutex);
static SkFontConfigInterfaceDirect* singleton = NULL;
if (singleton == NULL) {
singleton = SkNEW(SkFontConfigInterfaceDirect);
}
return singleton;
SkFontConfigInterface* SkFontConfigInterface::GetSingletonDirectInterface() {
SK_DECLARE_STATIC_LAZY_PTR(SkFontConfigInterfaceDirect, direct);
return direct.get();
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -50,7 +50,7 @@ static SkFontConfigInterface* RefFCI() {
if (fci) {
return fci;
}
fci = SkFontConfigInterface::GetSingletonDirectInterface(&gFontConfigInterfaceMutex);
fci = SkFontConfigInterface::GetSingletonDirectInterface();
SkFontConfigInterface::SetGlobal(fci);
}
}