зеркало из https://github.com/mozilla/pjs.git
Bug 412859. Some code to dump the contents of the textrun word cache. debug only. r=pavlov
This commit is contained in:
Родитель
f19a1226d8
Коммит
6539671b66
|
@ -52,6 +52,10 @@
|
|||
#include "nsMathUtils.h"
|
||||
#include "nsBidiUtils.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
class gfxContext;
|
||||
class gfxTextRun;
|
||||
class nsIAtom;
|
||||
|
@ -1260,6 +1264,8 @@ public:
|
|||
#ifdef DEBUG
|
||||
// number of entries referencing this textrun in the gfxTextRunWordCache
|
||||
PRUint32 mCachedWords;
|
||||
|
||||
void Dump(FILE* aOutput);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1979,3 +1979,36 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
gfxTextRun::Dump(FILE* aOutput) {
|
||||
if (!aOutput) {
|
||||
aOutput = stdout;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
fputc('"', aOutput);
|
||||
for (i = 0; i < mCharacterCount; ++i) {
|
||||
PRUnichar ch = GetChar(i);
|
||||
if (ch >= 32 && ch < 128) {
|
||||
fputc(ch, aOutput);
|
||||
} else {
|
||||
fprintf(aOutput, "\\u%4x", ch);
|
||||
}
|
||||
}
|
||||
fputs("\" [", aOutput);
|
||||
for (i = 0; i < mGlyphRuns.Length(); ++i) {
|
||||
if (i > 0) {
|
||||
fputc(',', aOutput);
|
||||
}
|
||||
gfxFont* font = mGlyphRuns[i].mFont;
|
||||
const gfxFontStyle* style = font->GetStyle();
|
||||
NS_ConvertUTF16toUTF8 fontName(font->GetName());
|
||||
fprintf(aOutput, "%d: %s %f/%d/%d/%s", mGlyphRuns[i].mCharacterOffset,
|
||||
fontName.get(), style->size,
|
||||
style->weight, style->style, style->langGroup.get());
|
||||
}
|
||||
fputc(']', aOutput);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
|
||||
#include "gfxTextRunWordCache.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Cache individual "words" (strings delimited by white-space or white-space-like
|
||||
* characters that don't involve kerning or ligatures) in textruns.
|
||||
|
@ -83,6 +87,10 @@ public:
|
|||
*/
|
||||
void RemoveTextRun(gfxTextRun *aTextRun);
|
||||
|
||||
#ifdef DEBUG
|
||||
void Dump();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
struct CacheHashKey {
|
||||
void *mFontOrGroup;
|
||||
|
@ -158,6 +166,10 @@ protected:
|
|||
PRUint32 aEnd, PRUint32 aHash);
|
||||
|
||||
nsTHashtable<CacheHashEntry> mCache;
|
||||
|
||||
#ifdef DEBUG
|
||||
static PLDHashOperator PR_CALLBACK CacheDumpEntry(CacheHashEntry* aEntry, void* userArg);
|
||||
#endif
|
||||
};
|
||||
|
||||
static PRLogModuleInfo *gWordCacheLog = PR_NewLogModule("wordCache");
|
||||
|
@ -660,6 +672,28 @@ TextRunWordCache::CacheHashEntry::HashKey(const KeyTypePointer aKey)
|
|||
aKey->mOptimizeSpeed*8;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
PLDHashOperator PR_CALLBACK
|
||||
TextRunWordCache::CacheDumpEntry(CacheHashEntry* aEntry, void* userArg)
|
||||
{
|
||||
FILE* output = static_cast<FILE*>(userArg);
|
||||
if (!aEntry->mTextRun) {
|
||||
fprintf(output, "<EMPTY>\n");
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
fprintf(output, "Word at %x:%d => ", aEntry->mTextRun, aEntry->mWordOffset);
|
||||
aEntry->mTextRun->Dump(output);
|
||||
fprintf(output, " (hashed by %s)\n", aEntry->mHashedByFont ? "font" : "fontgroup");
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
TextRunWordCache::Dump()
|
||||
{
|
||||
mCache.EnumerateEntries(CacheDumpEntry, stdout);
|
||||
}
|
||||
#endif
|
||||
|
||||
static TextRunWordCache *gTextRunWordCache = nsnull;
|
||||
|
||||
nsresult
|
||||
|
|
Загрузка…
Ссылка в новой задаче