зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1554183: Save font data to startup cache immediately r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D33245 --HG-- extra : rebase_source : 53851b4761013c0c65e5e173e8367852729fd0c3
This commit is contained in:
Родитель
11703ca543
Коммит
1c5db230d6
|
@ -707,11 +707,14 @@ class FontNameCache {
|
|||
mCache = mozilla::scache::StartupCache::GetSingleton();
|
||||
}
|
||||
|
||||
~FontNameCache() {
|
||||
~FontNameCache() { WriteCache(); }
|
||||
|
||||
void WriteCache() {
|
||||
if (!mWriteNeeded || !mCache) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("Writing FontNameCache:"));
|
||||
nsAutoCString buf;
|
||||
for (auto iter = mMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<FNCMapEntry*>(iter.Get());
|
||||
|
@ -729,8 +732,11 @@ class FontNameCache {
|
|||
buf.Append(';');
|
||||
}
|
||||
|
||||
LOG(("putting FontNameCache to " CACHE_KEY ", length %u",
|
||||
buf.Length() + 1));
|
||||
mCache->PutBuffer(CACHE_KEY, UniquePtr<char[]>(ToNewCString(buf)),
|
||||
buf.Length() + 1);
|
||||
mWriteNeeded = false;
|
||||
}
|
||||
|
||||
// This may be called more than once (if we re-load the font list).
|
||||
|
@ -742,10 +748,11 @@ class FontNameCache {
|
|||
uint32_t size;
|
||||
UniquePtr<char[]> buf;
|
||||
if (NS_FAILED(mCache->GetBuffer(CACHE_KEY, &buf, &size))) {
|
||||
LOG(("no cache of " CACHE_KEY));
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("got: %s from the cache", nsDependentCString(buf.get(), size).get()));
|
||||
LOG(("got: %u bytes from the cache " CACHE_KEY, size));
|
||||
|
||||
mMap.Clear();
|
||||
mWriteNeeded = false;
|
||||
|
@ -1338,6 +1345,25 @@ void gfxFT2FontList::FindFonts() {
|
|||
RefPtr<gfxFontFamily>& family = iter.Data();
|
||||
FinalizeFamilyMemberList(key, family, /* aSortFaces */ true);
|
||||
}
|
||||
// Write out FontCache data if needed
|
||||
WriteCache();
|
||||
}
|
||||
|
||||
void gfxFT2FontList::WriteCache() {
|
||||
if (mFontNameCache) {
|
||||
mFontNameCache->WriteCache();
|
||||
}
|
||||
mozilla::scache::StartupCache* cache =
|
||||
mozilla::scache::StartupCache::GetSingleton();
|
||||
if (cache && mJarModifiedTime > 0) {
|
||||
const size_t bufSize = sizeof(mJarModifiedTime);
|
||||
auto buf = MakeUnique<char[]>(bufSize);
|
||||
memcpy(buf.get(), &mJarModifiedTime, bufSize);
|
||||
|
||||
LOG(("WriteCache: putting Jar, length %zu", bufSize));
|
||||
cache->PutBuffer(JAR_LAST_MODIFED_TIME, std::move(buf), bufSize);
|
||||
}
|
||||
LOG(("Done with writecache"));
|
||||
}
|
||||
|
||||
void gfxFT2FontList::FindFontsInDir(const nsCString& aDir,
|
||||
|
@ -1548,14 +1574,7 @@ gfxFontFamily* gfxFT2FontList::CreateFontFamily(const nsACString& aName) const {
|
|||
}
|
||||
|
||||
void gfxFT2FontList::WillShutdown() {
|
||||
mozilla::scache::StartupCache* cache =
|
||||
mozilla::scache::StartupCache::GetSingleton();
|
||||
if (cache && mJarModifiedTime > 0) {
|
||||
const size_t bufSize = sizeof(mJarModifiedTime);
|
||||
auto buf = MakeUnique<char[]>(bufSize);
|
||||
memcpy(buf.get(), &mJarModifiedTime, bufSize);
|
||||
|
||||
cache->PutBuffer(JAR_LAST_MODIFED_TIME, std::move(buf), bufSize);
|
||||
}
|
||||
LOG(("WillShutdown"));
|
||||
WriteCache();
|
||||
mFontNameCache = nullptr;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,8 @@ class gfxFT2FontList : public gfxPlatformFontList {
|
|||
const uint8_t* aFontData,
|
||||
uint32_t aLength) override;
|
||||
|
||||
void WriteCache();
|
||||
|
||||
void GetSystemFontList(InfallibleTArray<FontListEntry>* retValue);
|
||||
|
||||
static gfxFT2FontList* PlatformFontList() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче