mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
bug 699331 - pt 1 - replace hardcoded font-loader constants with prefs to allow easier tuning. r=jdaggett
This commit is contained in:
parent
4af0b9382d
commit
f168126c35
@ -40,13 +40,6 @@ using namespace mozilla;
|
||||
gfxPlatform::GetLog(eGfxLog_cmapdata), \
|
||||
PR_LOG_DEBUG)
|
||||
|
||||
// font info loader constants
|
||||
|
||||
// avoid doing this during startup even on slow machines but try to start
|
||||
// it soon enough so that system fallback doesn't happen first
|
||||
static const uint32_t kDelayBeforeLoadingFonts = 120 * 1000; // 2 minutes after init
|
||||
static const uint32_t kIntervalBetweenLoadingFonts = 2000; // every 2 seconds until complete
|
||||
|
||||
static __inline void
|
||||
BuildKeyNameFromFontName(nsAString &aName)
|
||||
{
|
||||
@ -997,7 +990,7 @@ gfxDWriteFontList::DelayedInitFontList()
|
||||
Preferences::GetInt("gfx.font_rendering.cleartype_params.force_gdi_classic_max_size",
|
||||
mForceGDIClassicMaxFontSize);
|
||||
|
||||
StartLoader(kDelayBeforeLoadingFonts, kIntervalBetweenLoadingFonts);
|
||||
GetPrefsAndStartLoader();
|
||||
|
||||
LOGREGISTRY(L"DelayedInitFontList end");
|
||||
|
||||
|
@ -54,13 +54,6 @@ using namespace mozilla;
|
||||
|
||||
#endif // PR_LOGGING
|
||||
|
||||
// font info loader constants
|
||||
|
||||
// avoid doing this during startup even on slow machines but try to start
|
||||
// it soon enough so that system fallback doesn't happen first
|
||||
static const uint32_t kDelayBeforeLoadingFonts = 120 * 1000; // 2 minutes after init
|
||||
static const uint32_t kIntervalBetweenLoadingFonts = 2000; // every 2 seconds until complete
|
||||
|
||||
static __inline void
|
||||
BuildKeyNameFromFontName(nsAString &aName)
|
||||
{
|
||||
@ -711,7 +704,7 @@ gfxGDIFontList::InitFontList()
|
||||
|
||||
GetFontSubstitutes();
|
||||
|
||||
StartLoader(kDelayBeforeLoadingFonts, kIntervalBetweenLoadingFonts);
|
||||
GetPrefsAndStartLoader();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -85,11 +85,6 @@ private:
|
||||
NSAutoreleasePool *mLocalPool;
|
||||
};
|
||||
|
||||
// font info loader constants
|
||||
static const uint32_t kDelayBeforeLoadingCmaps = 8 * 1000; // 8secs
|
||||
static const uint32_t kIntervalBetweenLoadingCmaps = 150; // 150ms
|
||||
static const uint32_t kNumFontsPerSlice = 10; // read in info 10 fonts at a time
|
||||
|
||||
// indexes into the NSArray objects that the Cocoa font manager returns
|
||||
// as the available members of a family
|
||||
#define INDEX_FONT_POSTSCRIPT_NAME 0
|
||||
@ -742,7 +737,7 @@ gfxMacPlatformFontList::InitFontList()
|
||||
PreloadNamesList();
|
||||
|
||||
// start the delayed cmap loader
|
||||
StartLoader(kDelayBeforeLoadingCmaps, kIntervalBetweenLoadingCmaps);
|
||||
GetPrefsAndStartLoader();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -22,11 +22,6 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
// font info loader constants
|
||||
static const uint32_t kDelayBeforeLoadingCmaps = 8 * 1000; // 8secs
|
||||
static const uint32_t kIntervalBetweenLoadingCmaps = 150; // 150ms
|
||||
static const uint32_t kNumFontsPerSlice = 10; // read in info 10 fonts at a time
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
|
||||
#define LOG_FONTLIST(args) PR_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
|
||||
@ -39,6 +34,10 @@ static const uint32_t kNumFontsPerSlice = 10; // read in info 10 fonts at a time
|
||||
|
||||
gfxPlatformFontList *gfxPlatformFontList::sPlatformFontList = nullptr;
|
||||
|
||||
// prefs for the font info loader
|
||||
#define FONT_LOADER_FAMILIES_PER_SLICE_PREF "gfx.font_loader.families_per_slice"
|
||||
#define FONT_LOADER_DELAY_PREF "gfx.font_loader.delay"
|
||||
#define FONT_LOADER_INTERVAL_PREF "gfx.font_loader.interval"
|
||||
|
||||
static const char* kObservedPrefs[] = {
|
||||
"font.",
|
||||
@ -122,7 +121,7 @@ gfxPlatformFontList::MemoryReporter::CollectReports
|
||||
|
||||
gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
|
||||
: mNeedFullnamePostscriptNames(aNeedFullnamePostscriptNames),
|
||||
mStartIndex(0), mIncrement(kNumFontsPerSlice), mNumFamilies(0)
|
||||
mStartIndex(0), mIncrement(1), mNumFamilies(0)
|
||||
{
|
||||
mFontFamilies.Init(100);
|
||||
mOtherFamilyNames.Init(30);
|
||||
@ -747,6 +746,20 @@ gfxPlatformFontList::FinishLoader()
|
||||
mNumFamilies = 0;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::GetPrefsAndStartLoader()
|
||||
{
|
||||
mIncrement =
|
||||
std::max(1u, Preferences::GetUint(FONT_LOADER_FAMILIES_PER_SLICE_PREF));
|
||||
|
||||
uint32_t delay =
|
||||
std::max(1u, Preferences::GetUint(FONT_LOADER_DELAY_PREF));
|
||||
uint32_t interval =
|
||||
std::max(1u, Preferences::GetUint(FONT_LOADER_INTERVAL_PREF));
|
||||
|
||||
StartLoader(delay, interval);
|
||||
}
|
||||
|
||||
// Support for memory reporting
|
||||
|
||||
static size_t
|
||||
|
@ -245,6 +245,9 @@ protected:
|
||||
virtual bool RunLoader();
|
||||
virtual void FinishLoader();
|
||||
|
||||
// read the loader initialization prefs, and start it
|
||||
void GetPrefsAndStartLoader();
|
||||
|
||||
// used by memory reporter to accumulate sizes of family names in the hash
|
||||
static size_t
|
||||
SizeOfFamilyNameEntryExcludingThis(const nsAString& aKey,
|
||||
|
@ -239,6 +239,17 @@ pref("gfx.downloadable_fonts.fallback_delay", 3000);
|
||||
|
||||
pref("gfx.filter.nearest.force-enabled", false);
|
||||
|
||||
// prefs controlling the font (name/cmap) loader that runs shortly after startup
|
||||
#ifdef XP_WIN
|
||||
pref("gfx.font_loader.families_per_slice", 10); // read in info 10 families at a time
|
||||
pref("gfx.font_loader.delay", 120000); // 2 minutes after startup
|
||||
pref("gfx.font_loader.interval", 2000); // every 2 seconds until complete
|
||||
#else
|
||||
pref("gfx.font_loader.families_per_slice", 10); // read in info 10 families at a time
|
||||
pref("gfx.font_loader.delay", 8000); // 8 secs after startup
|
||||
pref("gfx.font_loader.interval", 150); // run every 150 ms
|
||||
#endif
|
||||
|
||||
// whether to always search all font cmaps during system font fallback
|
||||
pref("gfx.font_rendering.fallback.always_use_cmaps", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user