Backout 1152d14294df, 18c70ab50559, dbd51616925a, 730c2e84247f, and 7beb8fd46629 due to perma-hangs on WinXP debug moth. (test_memoryReporters.xul | application timed out after 330 seconds with no output)

This commit is contained in:
Ryan VanderMeulen 2012-03-23 17:04:28 -04:00
parent 13edde4d5e
commit 554919925b
23 changed files with 66 additions and 759 deletions

View File

@ -249,23 +249,6 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName)
aLocalizedName = nsDependentString(famName.Elements());
}
void
gfxDWriteFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
gfxFontFamily::SizeOfExcludingThis(aMallocSizeOf, aSizes);
// TODO:
// This doesn't currently account for |mDWFamily|
}
void
gfxDWriteFontFamily::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
////////////////////////////////////////////////////////////////////////////////
// gfxDWriteFontEntry
@ -394,8 +377,7 @@ gfxDWriteFontEntry::ReadCMAP()
unicodeFont, symbolFont);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(),
mCharacterMap.SizeOfExcludingThis(moz_malloc_size_of)));
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
@ -442,8 +424,7 @@ gfxDWriteFontEntry::ReadCMAP()
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(),
mCharacterMap.SizeOfExcludingThis(moz_malloc_size_of)));
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
@ -563,23 +544,6 @@ gfxDWriteFontEntry::IsCJKFont()
return mIsCJK;
}
void
gfxDWriteFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes);
// TODO:
// This doesn't currently account for the |mFont| and |mFontFile| members
}
void
gfxDWriteFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
////////////////////////////////////////////////////////////////////////////////
// gfxDWriteFontList
@ -623,6 +587,7 @@ gfxFontEntry *
gfxDWriteFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
const nsAString& aFullname)
{
bool found;
gfxFontEntry *lookup;
// initialize name lookup tables if needed
@ -631,8 +596,8 @@ gfxDWriteFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
}
// lookup in name lookup tables, return null if not found
if (!(lookup = mPostscriptNames.GetWeak(aFullname)) &&
!(lookup = mFullnames.GetWeak(aFullname)))
if (!(lookup = mPostscriptNames.GetWeak(aFullname, &found)) &&
!(lookup = mFullnames.GetWeak(aFullname, &found)))
{
return nsnull;
}
@ -1217,8 +1182,8 @@ gfxDWriteFontList::ResolveFontName(const nsAString& aFontName,
nsAutoString keyName(aFontName);
BuildKeyNameFromFontName(keyName);
gfxFontFamily *ff = mFontSubstitutes.GetWeak(keyName);
if (ff) {
nsRefPtr<gfxFontFamily> ff;
if (mFontSubstitutes.Get(keyName, &ff)) {
aResolvedFontName = ff->Name();
return true;
}
@ -1230,32 +1195,6 @@ gfxDWriteFontList::ResolveFontName(const nsAString& aFontName,
return gfxPlatformFontList::ResolveFontName(aFontName, aResolvedFontName);
}
void
gfxDWriteFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontListSize +=
mFontSubstitutes.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
aMallocSizeOf);
aSizes->mFontListSize +=
mNonExistingFonts.SizeOfExcludingThis(aMallocSizeOf);
for (PRUint32 i = 0; i < mNonExistingFonts.Length(); ++i) {
aSizes->mFontListSize +=
mNonExistingFonts[i].SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
}
void
gfxDWriteFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
static nsresult GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
{
HRESULT hr;

View File

@ -79,11 +79,6 @@ public:
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
/** This font family's directwrite fontfamily object */
nsRefPtr<IDWriteFontFamily> mDWFamily;
@ -184,11 +179,6 @@ public:
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
bool GetForceGDIClassic() { return mForceGDIClassic; }
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
friend class gfxDWriteFont;
friend class gfxDWriteFontList;
@ -390,11 +380,6 @@ public:
gfxFloat GetForceGDIClassicMaxFontSize() { return mForceGDIClassicMaxFontSize; }
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
private:
friend class gfxDWriteFontFamily;
@ -416,7 +401,7 @@ private:
*/
nsTArray<nsString> mNonExistingFonts;
typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontTable;
typedef nsDataHashtable<nsStringHashKey, nsRefPtr<gfxFontFamily> > FontTable;
/**
* Table of font substitutes, we grab this from the registry to get

View File

@ -762,20 +762,3 @@ gfxDWriteFont::MeasureGlyphWidth(PRUint16 aGlyph)
}
return 0;
}
void
gfxDWriteFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontInstances += aMallocSizeOf(mMetrics) +
mGlyphWidths.SizeOfExcludingThis(nsnull, aMallocSizeOf);
}
void
gfxDWriteFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -92,11 +92,6 @@ public:
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions();
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
friend class gfxDWriteShaper;

View File

@ -389,23 +389,6 @@ FT2FontEntry::GetFontTable(PRUint32 aTableTag,
return NS_OK;
}
void
FT2FontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontListSize +=
mFilename.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
void
FT2FontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
/*
* FT2FontFamily
* A standard gfxFontFamily; just adds a method used to support sending

View File

@ -102,11 +102,6 @@ public:
nsresult ReadCMAP();
nsresult GetFontTable(PRUint32 aTableTag, FallibleTArray<PRUint8>& aBuffer);
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
FT_Face mFTFace;
cairo_font_face_t *mFontFace;

View File

@ -661,20 +661,3 @@ gfxFT2Font::FillGlyphDataForChar(PRUint32 ch, CachedGlyphData *gd)
gd->rsbDelta = face->glyph->rsb_delta;
gd->xAdvance = face->glyph->advance.x;
}
void
gfxFT2Font::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontInstances +=
mCharGlyphCache.SizeOfExcludingThis(nsnull, aMallocSizeOf);
}
void
gfxFT2Font::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -96,11 +96,6 @@ public: // new functions
return &entry->mData;
}
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
virtual bool ShapeWord(gfxContext *aContext,
gfxShapedWord *aShapedWord,

View File

@ -47,6 +47,7 @@
#include "nsReadableUtils.h"
#include "nsExpirationTracker.h"
#include "nsILanguageAtomService.h"
#include "nsIMemoryReporter.h"
#include "nsITimer.h"
#include "gfxFont.h"
@ -401,44 +402,6 @@ gfxFontEntry::CheckForGraphiteTables()
}
#endif
/* static */ size_t
gfxFontEntry::FontTableHashEntry::SizeOfEntryExcludingThis
(FontTableHashEntry *aEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
if (aEntry->mBlob) {
FontListSizes *sizes = static_cast<FontListSizes*>(aUserArg);
sizes->mFontTableCacheSize += aMallocSizeOf(aEntry->mBlob);
sizes->mFontTableCacheSize +=
aMallocSizeOf(hb_blob_get_data(aEntry->mBlob, NULL));
}
// the size of the blob is recorded in the FontListSizes record,
// so we return 0 here for the function result
return 0;
}
void
gfxFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
aSizes->mCharMapsSize += mCharacterMap.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontTableCacheSize +=
mFontTableCache.SizeOfExcludingThis(
FontTableHashEntry::SizeOfEntryExcludingThis,
aMallocSizeOf, aSizes);
}
void
gfxFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
//////////////////////////////////////////////////////////////////////////////
//
// class gfxFontFamily
@ -1013,32 +976,6 @@ gfxFontFamily::FindFont(const nsAString& aPostscriptName)
return nsnull;
}
void
gfxFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize +=
mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
aSizes->mCharMapsSize += mCharacterMap.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontListSize +=
mAvailableFonts.SizeOfExcludingThis(aMallocSizeOf);
for (PRUint32 i = 0; i < mAvailableFonts.Length(); ++i) {
gfxFontEntry *fe = mAvailableFonts[i];
if (fe) {
fe->SizeOfIncludingThis(aMallocSizeOf, aSizes);
}
}
}
void
gfxFontFamily::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
/*
* gfxFontCache - global cache of gfxFont instances.
* Expires unused fonts after a short interval;
@ -1047,52 +984,6 @@ gfxFontFamily::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
* shaped-word caches to free up memory.
*/
NS_IMPL_ISUPPORTS1(gfxFontCache::MemoryReporter, nsIMemoryMultiReporter)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(FontCacheMallocSizeOf, "font-cache")
NS_IMETHODIMP
gfxFontCache::MemoryReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("font-cache");
return NS_OK;
}
NS_IMETHODIMP
gfxFontCache::MemoryReporter::CollectReports
(nsIMemoryMultiReporterCallback* aCb,
nsISupports* aClosure)
{
FontCacheSizes sizes;
gfxFontCache::GetCache()->SizeOfIncludingThis(&FontCacheMallocSizeOf,
&sizes);
aCb->Callback(EmptyCString(),
NS_LITERAL_CSTRING("explicit/gfx/font-cache"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
sizes.mFontInstances,
NS_LITERAL_CSTRING("Memory used for active font instances."),
aClosure);
aCb->Callback(EmptyCString(),
NS_LITERAL_CSTRING("explicit/gfx/font-shaped-words"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
sizes.mShapedWords,
NS_LITERAL_CSTRING("Memory used to cache shaped glyph data."),
aClosure);
return NS_OK;
}
NS_IMETHODIMP
gfxFontCache::MemoryReporter::GetExplicitNonHeap(PRInt64* aAmount)
{
// This reporter only measures heap memory.
*aAmount = 0;
return NS_OK;
}
// Observer for the memory-pressure notification, to trigger
// flushing of the shaped-word caches
class MemoryPressureObserver : public nsIObserver,
@ -1124,11 +1015,7 @@ gfxFontCache::Init()
{
NS_ASSERTION(!gGlobalCache, "Where did this come from?");
gGlobalCache = new gfxFontCache();
if (!gGlobalCache) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_RegisterMemoryMultiReporter(new MemoryReporter);
return NS_OK;
return gGlobalCache ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
void
@ -1289,39 +1176,6 @@ gfxFontCache::ClearCachedWordsForFont(HashEntry* aHashEntry, void* aUserData)
return PL_DHASH_NEXT;
}
/*static*/
size_t
gfxFontCache::SizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
HashEntry *entry = static_cast<HashEntry*>(aHashEntry);
FontCacheSizes *sizes = static_cast<FontCacheSizes*>(aUserArg);
entry->mFont->SizeOfExcludingThis(aMallocSizeOf, sizes);
// The font records its size in the |sizes| parameter, so we return zero
// here to the hashtable enumerator.
return 0;
}
void
gfxFontCache::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
// TODO: add the overhead of the expiration tracker (generation arrays)
mFonts.SizeOfExcludingThis(SizeOfFontEntryExcludingThis,
aMallocSizeOf, aSizes);
}
void
gfxFontCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
void
gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, bool aOtherIsOnLeft)
{
@ -2081,10 +1935,6 @@ gfxFont::GetShapedWord(gfxContext *aContext,
aFlags);
CacheHashEntry *entry = mWordCache.PutEntry(key);
if (!entry) {
NS_WARNING("failed to create word cache entry - expect missing text");
return nsnull;
}
gfxShapedWord *sw = entry->mShapedWord;
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_LEN, aLength);
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_SCRIPT, aRunScript);
@ -2100,21 +1950,20 @@ gfxFont::GetShapedWord(gfxContext *aContext,
aRunScript,
aAppUnitsPerDevUnit,
aFlags);
NS_ASSERTION(sw != nsnull,
"failed to create gfxShapedWord - expect missing text");
if (!sw) {
NS_WARNING("failed to create gfxShapedWord - expect missing text");
return nsnull;
}
bool ok = false;
bool ok;
if (sizeof(T) == sizeof(PRUnichar)) {
ok = ShapeWord(aContext, sw, (const PRUnichar*)aText);
} else {
nsAutoString utf16;
AppendASCIItoUTF16(nsDependentCSubstring((const char*)aText, aLength),
utf16);
if (utf16.Length() == aLength) {
ok = ShapeWord(aContext, sw, utf16.BeginReading());
}
ok = ShapeWord(aContext, sw, utf16.BeginReading());
}
NS_WARN_IF_FALSE(ok, "failed to shape word - expect garbled text");
@ -2671,40 +2520,10 @@ gfxFont::SynthesizeSpaceWidth(PRUint32 aCh)
}
}
/*static*/ size_t
gfxFont::WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
return aMallocSizeOf(aHashEntry->mShapedWord.get());
}
void
gfxFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
for (PRUint32 i = 0; i < mGlyphExtentsArray.Length(); ++i) {
aSizes->mFontInstances +=
mGlyphExtentsArray[i]->SizeOfIncludingThis(aMallocSizeOf);
}
aSizes->mShapedWords +=
mWordCache.SizeOfExcludingThis(WordCacheEntrySizeOfExcludingThis,
aMallocSizeOf);
}
void
gfxFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
gfxGlyphExtents::~gfxGlyphExtents()
{
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
gGlyphExtentsWidthsTotalSize +=
mContainedGlyphWidths.SizeOfExcludingThis(&FontCacheMallocSizeOf);
gGlyphExtentsWidthsTotalSize += mContainedGlyphWidths.ComputeSize();
gGlyphExtentsCount++;
#endif
MOZ_COUNT_DTOR(gfxGlyphExtents);
@ -2748,19 +2567,21 @@ gfxGlyphExtents::GlyphWidths::~GlyphWidths()
}
}
#ifdef DEBUG
PRUint32
gfxGlyphExtents::GlyphWidths::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
gfxGlyphExtents::GlyphWidths::ComputeSize()
{
PRUint32 i;
PRUint32 size = mBlocks.SizeOfExcludingThis(aMallocSizeOf);
PRUint32 size = mBlocks.Capacity()*sizeof(PtrBits);
for (i = 0; i < mBlocks.Length(); ++i) {
PtrBits bits = mBlocks[i];
if (bits && !(bits & 0x1)) {
size += aMallocSizeOf(reinterpret_cast<void*>(bits));
size += BLOCK_SIZE*sizeof(PRUint16);
}
}
return size;
}
#endif
void
gfxGlyphExtents::GlyphWidths::Set(PRUint32 aGlyphID, PRUint16 aWidth)
@ -2812,19 +2633,6 @@ gfxGlyphExtents::SetTightGlyphExtents(PRUint32 aGlyphID, const gfxRect& aExtents
entry->height = aExtentsAppUnits.Height();
}
size_t
gfxGlyphExtents::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return mContainedGlyphWidths.SizeOfExcludingThis(aMallocSizeOf) +
mTightGlyphExtents.SizeOfExcludingThis(nsnull, aMallocSizeOf);
}
size_t
gfxGlyphExtents::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
gfxFontGroup::gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyle, gfxUserFontSet *aUserFontSet)
: mFamilies(aFamilies), mStyle(*aStyle), mUnderlineOffset(UNDERLINE_OFFSET_NOT_SET)
{

View File

@ -59,7 +59,6 @@
#include "nsISupportsImpl.h"
#include "gfxPattern.h"
#include "mozilla/HashFunctions.h"
#include "nsIMemoryReporter.h"
typedef struct _cairo_scaled_font cairo_scaled_font_t;
@ -91,8 +90,6 @@ struct THEBES_API gfxFontFeature {
// to features that select among multiple alternatives
};
struct FontListSizes;
inline bool
operator<(const gfxFontFeature& a, const gfxFontFeature& b)
{
@ -316,12 +313,6 @@ public:
hb_blob_t *ShareFontTableAndGetBlob(PRUint32 aTag,
FallibleTArray<PRUint8>* aTable);
// For memory reporting
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
nsString mName;
bool mItalic : 1;
@ -476,11 +467,6 @@ private:
void Clear();
static size_t
SizeOfEntryExcludingThis(FontTableHashEntry *aEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg);
private:
static void DeleteFontTableBlobData(void *aBlobData);
// not implemented
@ -647,12 +633,6 @@ public:
// if so set the mIsSimpleFamily flag (defaults to False before we've checked)
void CheckForSimpleFamily();
// For memory reporter
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
// fills in an array with weights of faces that match style,
// returns whether any matching entries found
@ -743,15 +723,6 @@ struct gfxTextRange {
* completely, with all its words, and avoid the cost of aging the words
* individually. That only happens with longer-lived fonts.
*/
struct FontCacheSizes {
FontCacheSizes()
: mFontInstances(0), mShapedWords(0)
{ }
size_t mFontInstances; // memory used by instances of gfxFont subclasses
size_t mShapedWords; // memory used by the per-font shapedWord caches
};
class THEBES_API gfxFontCache MOZ_FINAL : public nsExpirationTracker<gfxFont,3> {
public:
enum {
@ -805,20 +776,7 @@ public:
mFonts.EnumerateEntries(ClearCachedWordsForFont, nsnull);
}
void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
class MemoryReporter
: public nsIMemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYMULTIREPORTER
};
void DestroyFont(gfxFont *aFont);
static gfxFontCache *gGlobalCache;
@ -851,10 +809,6 @@ protected:
gfxFont* mFont;
};
static size_t SizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg);
nsTHashtable<HashEntry> mFonts;
static PLDHashOperator ClearCachedWordsForFont(HashEntry* aHashEntry, void*);
@ -1026,9 +980,6 @@ public:
PRUint32 GetAppUnitsPerDevUnit() { return mAppUnitsPerDevUnit; }
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
private:
class HashEntry : public nsUint32HashKey {
public:
@ -1065,7 +1016,9 @@ private:
return widths[indexInBlock];
}
PRUint32 SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
#ifdef DEBUG
PRUint32 ComputeSize();
#endif
~GlyphWidths();
@ -1084,7 +1037,7 @@ private:
nsTArray<PtrBits> mBlocks;
};
GlyphWidths mContainedGlyphWidths;
nsTHashtable<HashEntry> mTightGlyphExtents;
PRUint32 mAppUnitsPerDevUnit;
@ -1521,11 +1474,6 @@ public:
}
}
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
// Call the appropriate shaper to generate glyphs for aText and store
// them into aShapedWord.
@ -1610,11 +1558,6 @@ protected:
nsAutoPtr<gfxShapedWord> mShapedWord;
};
static size_t
WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg);
nsTHashtable<CacheHashEntry> mWordCache;
static PLDHashOperator AgeCacheEntry(CacheHashEntry *aEntry, void *aUserData);

View File

@ -264,18 +264,14 @@ public:
}
}
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
size_t total = mBlocks.SizeOfExcludingThis(aMallocSizeOf);
PRUint32 GetSize() {
PRUint32 size = 0;
for (PRUint32 i = 0; i < mBlocks.Length(); i++) {
if (mBlocks[i]) {
total += aMallocSizeOf(mBlocks[i]);
}
if (mBlocks[i])
size += sizeof(Block);
size += sizeof(nsAutoPtr<Block>);
}
return total;
}
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
return size;
}
// clear out all blocks in the array

View File

@ -560,20 +560,3 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
return -1;
}
void
gfxGDIFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontInstances += aMallocSizeOf(mMetrics) +
mGlyphWidths.SizeOfExcludingThis(nsnull, aMallocSizeOf);
}
void
gfxGDIFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -88,11 +88,6 @@ public:
// get hinted glyph width in pixels as 16.16 fixed-point value
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
virtual void CreatePlatformShaper();

View File

@ -246,8 +246,7 @@ GDIFontEntry::ReadCMAP()
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(),
mCharacterMap.SizeOfExcludingThis(moz_malloc_size_of)));
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
@ -460,14 +459,6 @@ GDIFontEntry::CreateFontEntry(const nsAString& aName,
return fe;
}
void
GDIFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
/***************************************************************
*
* GDIFontFamily
@ -667,7 +658,7 @@ gfxGDIFontList::GetFontSubstitutes()
nsAutoString substituteName;
substituteName.AssignLiteral("Courier");
BuildKeyNameFromFontName(substituteName);
if (!mFontSubstitutes.GetWeak(substituteName)) {
if (!mFontSubstitutes.Get(substituteName)) {
gfxFontFamily *ff;
nsAutoString actualFontName;
actualFontName.AssignLiteral("Courier New");
@ -752,6 +743,7 @@ gfxFontEntry*
gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
const nsAString& aFullname)
{
bool found;
gfxFontEntry *lookup;
// initialize name lookup tables if needed
@ -760,8 +752,8 @@ gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
}
// lookup in name lookup tables, return null if not found
if (!(lookup = mPostscriptNames.GetWeak(aFullname)) &&
!(lookup = mFullnames.GetWeak(aFullname)))
if (!(lookup = mPostscriptNames.GetWeak(aFullname, &found)) &&
!(lookup = mFullnames.GetWeak(aFullname, &found)))
{
return nsnull;
}
@ -1046,8 +1038,8 @@ gfxGDIFontList::ResolveFontName(const nsAString& aFontName, nsAString& aResolved
nsAutoString keyName(aFontName);
BuildKeyNameFromFontName(keyName);
gfxFontFamily *ff = mFontSubstitutes.GetWeak(keyName);
if (ff) {
nsRefPtr<gfxFontFamily> ff;
if (mFontSubstitutes.Get(keyName, &ff)) {
aResolvedFontName = ff->Name();
return true;
}
@ -1060,27 +1052,3 @@ gfxGDIFontList::ResolveFontName(const nsAString& aFontName, nsAString& aResolved
return false;
}
void
gfxGDIFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes);
aSizes->mFontListSize +=
mFontSubstitutes.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
aMallocSizeOf);
aSizes->mFontListSize +=
mNonExistingFonts.SizeOfExcludingThis(aMallocSizeOf);
for (PRUint32 i = 0; i < mNonExistingFonts.Length(); ++i) {
aSizes->mFontListSize +=
mNonExistingFonts[i].SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
}
void
gfxGDIFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -274,9 +274,6 @@ public:
virtual bool TestCharacterMap(PRUint32 aCh);
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
// create a font entry for a font with a given name
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
gfxWindowsFontType aFontType,
@ -350,11 +347,6 @@ public:
virtual bool ResolveFontName(const nsAString& aFontName,
nsAString& aResolvedFontName);
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
private:
friend class gfxWindowsPlatform;
@ -369,7 +361,7 @@ private:
DWORD fontType,
LPARAM lParam);
typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontTable;
typedef nsDataHashtable<nsStringHashKey, nsRefPtr<gfxFontFamily> > FontTable;
FontTable mFontSubstitutes;
nsTArray<nsString> mNonExistingFonts;

View File

@ -509,19 +509,3 @@ gfxMacFont::GetScaledFont()
return mAzureFont;
}
void
gfxMacFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes);
// mCGFont is shared with the font entry, so not counted here;
// and we don't have APIs to measure the cairo mFontFace object
}
void
gfxMacFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const
{
aSizes->mFontInstances += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -81,11 +81,6 @@ public:
mozilla::RefPtr<mozilla::gfx::ScaledFont> GetScaledFont();
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontCacheSizes* aSizes) const;
protected:
virtual void CreatePlatformShaper();

View File

@ -111,9 +111,6 @@ public:
virtual nsresult GetFontTable(PRUint32 aTableTag,
FallibleTArray<PRUint8>& aBuffer);
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
virtual bool HasFontTable(PRUint32 aTableTag);
@ -137,9 +134,6 @@ public:
virtual nsresult GetFontTable(PRUint32 aTableTag,
FallibleTArray<PRUint8>& aBuffer);
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
virtual bool HasFontTable(PRUint32 aTableTag);
};

View File

@ -270,7 +270,7 @@ MacOSFontEntry::ReadCMAP()
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(),
mCharacterMap.SizeOfExcludingThis(moz_malloc_size_of)));
mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
@ -398,14 +398,6 @@ ATSFontEntry::HasFontTable(PRUint32 aTableTag)
(::ATSFontGetTable(fontRef, aTableTag, 0, 0, 0, &size) == noErr);
}
void
ATSFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
/* CGFontEntry - used on Mac OS X 10.6+ */
#pragma mark-
@ -494,14 +486,6 @@ CGFontEntry::HasFontTable(PRUint32 aTableTag)
return true;
}
void
CGFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}
/* gfxMacFontFamily */
#pragma mark-
@ -827,9 +811,10 @@ gfxMacPlatformFontList::InitSingleFaceList()
#endif
// add only if doesn't exist already
if (!mFontFamilies.GetWeak(key)) {
gfxFontFamily *familyEntry =
new gfxSingleFaceMacFontFamily(familyName);
bool found;
gfxFontFamily *familyEntry;
if (!(familyEntry = mFontFamilies.GetWeak(key, &found))) {
familyEntry = new gfxSingleFaceMacFontFamily(familyName);
familyEntry->AddFontEntry(fontEntry);
familyEntry->SetHasStyles(true);
mFontFamilies.Put(key, familyEntry);

View File

@ -130,60 +130,6 @@ gfxFontListPrefObserver::Observe(nsISupports *aSubject,
return NS_OK;
}
NS_IMPL_ISUPPORTS1(gfxPlatformFontList::MemoryReporter, nsIMemoryMultiReporter)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(FontListMallocSizeOf, "font-list")
NS_IMETHODIMP
gfxPlatformFontList::MemoryReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("font-list");
return NS_OK;
}
NS_IMETHODIMP
gfxPlatformFontList::MemoryReporter::CollectReports
(nsIMemoryMultiReporterCallback* aCb,
nsISupports* aClosure)
{
FontListSizes sizes;
gfxPlatformFontList::PlatformFontList()->SizeOfIncludingThis(&FontListMallocSizeOf,
&sizes);
aCb->Callback(EmptyCString(),
NS_LITERAL_CSTRING("explicit/gfx/font-list"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
sizes.mFontListSize,
NS_LITERAL_CSTRING("Memory used to manage the list of font families and faces."),
aClosure);
aCb->Callback(EmptyCString(),
NS_LITERAL_CSTRING("explicit/gfx/font-charmaps"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
sizes.mCharMapsSize,
NS_LITERAL_CSTRING("Memory used to record the character coverage of individual fonts."),
aClosure);
if (sizes.mFontTableCacheSize) {
aCb->Callback(EmptyCString(),
NS_LITERAL_CSTRING("explicit/gfx/font-tables"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
sizes.mFontTableCacheSize,
NS_LITERAL_CSTRING("Memory used for cached font metrics and layout tables."),
aClosure);
}
return NS_OK;
}
NS_IMETHODIMP
gfxPlatformFontList::MemoryReporter::GetExplicitNonHeap(PRInt64* aAmount)
{
// This reporter only measures heap memory.
*aAmount = 0;
return NS_OK;
}
gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
: mNeedFullnamePostscriptNames(aNeedFullnamePostscriptNames),
@ -238,8 +184,6 @@ gfxPlatformFontList::InitFontList()
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
NS_RegisterMemoryMultiReporter(new MemoryReporter);
sPlatformFontList = this;
return NS_OK;
@ -300,11 +244,12 @@ gfxPlatformFontList::PreloadNamesList()
PRUint32 numFonts = preloadFonts.Length();
for (PRUint32 i = 0; i < numFonts; i++) {
bool found;
nsAutoString key;
GenerateFontListKey(preloadFonts[i], key);
// only search canonical names!
gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key, &found);
if (familyEntry) {
familyEntry->ReadOtherFamilyNames(this);
}
@ -604,17 +549,18 @@ gfxPlatformFontList::FindFamily(const nsAString& aFamily)
{
nsAutoString key;
gfxFontFamily *familyEntry;
bool found;
GenerateFontListKey(aFamily, key);
NS_ASSERTION(mFontFamilies.Count() != 0, "system font list was not initialized correctly");
// lookup in canonical (i.e. English) family name list
if ((familyEntry = mFontFamilies.GetWeak(key))) {
if ((familyEntry = mFontFamilies.GetWeak(key, &found))) {
return familyEntry;
}
// lookup in other family names list (mostly localized names)
if ((familyEntry = mOtherFamilyNames.GetWeak(key)) != nsnull) {
if ((familyEntry = mOtherFamilyNames.GetWeak(key, &found)) != nsnull) {
return familyEntry;
}
@ -625,7 +571,7 @@ gfxPlatformFontList::FindFamily(const nsAString& aFamily)
// in practice so avoid pulling in names at startup
if (!mOtherFamilyNamesInitialized && !IsASCII(aFamily)) {
InitOtherFamilyNames();
if ((familyEntry = mOtherFamilyNames.GetWeak(key)) != nsnull) {
if ((familyEntry = mOtherFamilyNames.GetWeak(key, &found)) != nsnull) {
return familyEntry;
}
}
@ -662,9 +608,10 @@ void
gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName)
{
nsAutoString key;
bool found;
GenerateFontListKey(aOtherFamilyName, key);
if (!mOtherFamilyNames.GetWeak(key)) {
if (!mOtherFamilyNames.GetWeak(key, &found)) {
mOtherFamilyNames.Put(key, aFamilyEntry);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-otherfamily) canonical family: %s, "
@ -680,7 +627,9 @@ gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString&
void
gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
{
if (!mFullnames.GetWeak(aFullname)) {
bool found;
if (!mFullnames.GetWeak(aFullname, &found)) {
mFullnames.Put(aFullname, aFontEntry);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-fullname) name: %s, fullname: %s\n",
@ -693,7 +642,9 @@ gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
void
gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName)
{
if (!mPostscriptNames.GetWeak(aPostscriptName)) {
bool found;
if (!mPostscriptNames.GetWeak(aPostscriptName, &found)) {
mPostscriptNames.Put(aPostscriptName, aFontEntry);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-postscript) name: %s, psname: %s\n",
@ -763,111 +714,3 @@ gfxPlatformFontList::FinishLoader()
mFontFamiliesToLoad.Clear();
mNumFamilies = 0;
}
// Support for memory reporting
static size_t
SizeOfFamilyEntryExcludingThis(const nsAString& aKey,
const nsRefPtr<gfxFontFamily>& aFamily,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
FontListSizes *sizes = static_cast<FontListSizes*>(aUserArg);
aFamily->SizeOfExcludingThis(aMallocSizeOf, sizes);
sizes->mFontListSize += aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
// we return zero here because the measurements have been added directly
// to the relevant fields of the FontListSizes record
return 0;
}
// this is also used by subclasses that hold additional hashes of family names
/*static*/ size_t
gfxPlatformFontList::SizeOfFamilyNameEntryExcludingThis
(const nsAString& aKey,
const nsRefPtr<gfxFontFamily>& aFamily,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
// we don't count the size of the family here, because this is an *extra*
// reference to a family that will have already been counted in the main list
return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
static size_t
SizeOfFontNameEntryExcludingThis(const nsAString& aKey,
const nsRefPtr<gfxFontEntry>& aFont,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
// the font itself is counted by its owning family; here we only care about
// the name stored in the hashtable key
return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
static size_t
SizeOfPrefFontEntryExcludingThis
(const PRUint32& aKey,
const nsTArray<nsRefPtr<gfxFontFamily> >& aList,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
// again, we only care about the size of the array itself; we don't follow
// the refPtrs stored in it, because they point to entries already owned
// and accounted-for by the main font list
return aList.SizeOfExcludingThis(aMallocSizeOf);
}
static size_t
SizeOfStringEntryExcludingThis(nsStringHashKey* aHashEntry,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg)
{
return aHashEntry->GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
void
gfxPlatformFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize +=
mFontFamilies.SizeOfExcludingThis(SizeOfFamilyEntryExcludingThis,
aMallocSizeOf, aSizes);
aSizes->mFontListSize +=
mOtherFamilyNames.SizeOfExcludingThis(SizeOfFamilyNameEntryExcludingThis,
aMallocSizeOf);
if (mNeedFullnamePostscriptNames) {
aSizes->mFontListSize +=
mFullnames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
aMallocSizeOf);
aSizes->mFontListSize +=
mPostscriptNames.SizeOfExcludingThis(SizeOfFontNameEntryExcludingThis,
aMallocSizeOf);
}
aSizes->mFontListSize +=
mCodepointsWithNoFonts.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontListSize +=
mReplacementCharFallbackFamily.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
aSizes->mFontListSize +=
mFontFamiliesToLoad.SizeOfExcludingThis(aMallocSizeOf);
aSizes->mFontListSize +=
mPrefFonts.SizeOfExcludingThis(SizeOfPrefFontEntryExcludingThis,
aMallocSizeOf);
aSizes->mFontListSize +=
mBadUnderlineFamilyNames.SizeOfExcludingThis(SizeOfStringEntryExcludingThis,
aMallocSizeOf);
}
void
gfxPlatformFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const
{
aSizes->mFontListSize += aMallocSizeOf(this);
SizeOfExcludingThis(aMallocSizeOf, aSizes);
}

View File

@ -47,7 +47,6 @@
#include "gfxFont.h"
#include "gfxPlatform.h"
#include "nsIMemoryReporter.h"
#include "mozilla/FunctionTimer.h"
// gfxPlatformFontList is an abstract class for the global font list on the system;
@ -58,18 +57,6 @@
// Much of this is based on the old gfxQuartzFontCache, but adapted for use on all platforms.
struct FontListSizes {
FontListSizes()
: mFontListSize(0), mFontTableCacheSize(0), mCharMapsSize(0)
{ }
size_t mFontListSize; // size of the font list and dependent objects
// (font family and face names, etc), but NOT
// including the font table cache and the cmaps
size_t mFontTableCacheSize; // memory used for the gfxFontEntry table caches
size_t mCharMapsSize; // memory used for cmap coverage info
};
class gfxPlatformFontList : protected gfxFontInfoLoader
{
public:
@ -154,20 +141,7 @@ public:
// (platforms may override, eg Mac)
virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
FontListSizes* aSizes) const;
protected:
class MemoryReporter
: public nsIMemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYMULTIREPORTER
};
gfxPlatformFontList(bool aNeedFullnamePostscriptNames = true);
static gfxPlatformFontList *sPlatformFontList;
@ -226,13 +200,6 @@ protected:
virtual bool RunLoader();
virtual void FinishLoader();
// used by memory reporter to accumulate sizes of family names in the hash
static size_t
SizeOfFamilyNameEntryExcludingThis(const nsAString& aKey,
const nsRefPtr<gfxFontFamily>& aFamily,
nsMallocSizeOfFun aMallocSizeOf,
void* aUserArg);
// canonical family name ==> family entry (unique, one name per family entry)
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mFontFamilies;

View File

@ -272,17 +272,16 @@ public:
* @return the summed size of all the entries
*/
size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
nsMallocSizeOfFun mallocSizeOf, void *userArg = nsnull) const
nsMallocSizeOfFun mallocSizeOf, void *userArg = nsnull)
{
if (!IsInitialized()) {
return 0;
}
if (sizeOfEntryExcludingThis) {
if (IsInitialized()) {
s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
return PL_DHashTableSizeOfExcludingThis(&this->mTable, s_SizeOfStub,
mallocSizeOf, &args);
return PL_DHashTableSizeOfExcludingThis(&this->mTable,
s_SizeOfStub,
mallocSizeOf,
&args);
}
return PL_DHashTableSizeOfExcludingThis(&this->mTable, NULL, mallocSizeOf);
return 0;
}
protected:

View File

@ -288,14 +288,11 @@ public:
size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
nsMallocSizeOfFun mallocSizeOf, void *userArg = NULL) const
{
if (!IsInitialized()) {
return 0;
}
if (sizeOfEntryExcludingThis) {
if (IsInitialized()) {
s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
return PL_DHashTableSizeOfExcludingThis(&mTable, s_SizeOfStub, mallocSizeOf, &args);
}
return PL_DHashTableSizeOfExcludingThis(&mTable, NULL, mallocSizeOf);
return 0;
}
#ifdef DEBUG