Revert "Hold onto FcConfig in SkFontConfigInterface_direct."
This reverts commit 35e0a58278
.
Reason for revert: Breaking g3 roll
Unfortunately, the g3 tests call FcFini at the end, but FcFini asserts
that everything is really no longer in use (it doesn't just unref the
current FcConfig). This means that all local FcConfig references must
be destroyed before calling FcFini. However, one of these will be
rooted with a global, leading to destructor ordering issues.
Will need to see how to handle this.
Original change's description:
> Hold onto FcConfig in SkFontConfigInterface_direct.
>
> It is possible that some other thread will change the default FcConfig
> out from under one of this classes own calls, which is a terrible race.
> Prevent this by taking a reference to the default FcConfig at creation
> time and keeping it alive.
>
> Bug: chromium:1004254
> Change-Id: I23338c72e0b93859beae465cb6d48e87b3928ed3
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/245720
> Reviewed-by: Etienne Bergeron <etienneb@chromium.org>
> Reviewed-by: Herb Derby <herb@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
TBR=bungeman@google.com,herb@google.com,etienneb@chromium.org
Change-Id: If0f90c9060ff5c7a486f6d7ffe2b7b52a7ae31a4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1004254
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/246078
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
a975ef3b2f
commit
3b5e8ab20b
@ -510,7 +510,8 @@ const char* kFontFormatCFF = "CFF";
|
||||
|
||||
SkFontConfigInterfaceDirect::SkFontConfigInterfaceDirect() {
|
||||
FCLocker lock;
|
||||
fcConfig.reset(FcConfigReference(nullptr));
|
||||
|
||||
FcInit();
|
||||
|
||||
SkDEBUGCODE(fontconfiginterface_unittest();)
|
||||
}
|
||||
@ -541,7 +542,7 @@ bool SkFontConfigInterfaceDirect::isValidPattern(FcPattern* pattern) {
|
||||
if (!c_filename) {
|
||||
return false;
|
||||
}
|
||||
const char* sysroot = (const char*)FcConfigGetSysRoot(fcConfig.get());
|
||||
const char* sysroot = (const char*)FcConfigGetSysRoot(nullptr);
|
||||
SkString resolvedFilename;
|
||||
if (sysroot) {
|
||||
resolvedFilename = sysroot;
|
||||
@ -612,7 +613,7 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
|
||||
|
||||
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
|
||||
|
||||
FcConfigSubstitute(fcConfig.get(), pattern, FcMatchPattern);
|
||||
FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(pattern);
|
||||
|
||||
// Font matching:
|
||||
@ -651,7 +652,7 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
|
||||
}
|
||||
|
||||
FcResult result;
|
||||
FcFontSet* font_set = FcFontSort(fcConfig.get(), pattern, 0, nullptr, &result);
|
||||
FcFontSet* font_set = FcFontSort(nullptr, pattern, 0, nullptr, &result);
|
||||
if (!font_set) {
|
||||
FcPatternDestroy(pattern);
|
||||
return false;
|
||||
@ -679,7 +680,7 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
|
||||
FcFontSetDestroy(font_set);
|
||||
return false;
|
||||
}
|
||||
const char* sysroot = (const char*)FcConfigGetSysRoot(fcConfig.get());
|
||||
const char* sysroot = (const char*)FcConfigGetSysRoot(nullptr);
|
||||
SkString resolvedFilename;
|
||||
if (sysroot) {
|
||||
resolvedFilename = sysroot;
|
||||
|
@ -30,7 +30,6 @@ protected:
|
||||
virtual bool isAccessible(const char* filename);
|
||||
|
||||
private:
|
||||
std::unique_ptr<FcConfig,SkFunctionWrapper<decltype(FcConfigDestroy),FcConfigDestroy>> fcConfig;
|
||||
bool isValidPattern(FcPattern* pattern);
|
||||
FcPattern* MatchFont(FcFontSet* font_set, const char* post_config_family,
|
||||
const SkString& family);
|
||||
|
Loading…
Reference in New Issue
Block a user