Bug 705594. Add cmapdata logging. r=roc

This commit is contained in:
John Daggett 2012-03-09 11:05:14 +09:00
parent 4514064c4d
commit e2eedda75a
7 changed files with 97 additions and 1 deletions

View File

@ -68,6 +68,10 @@ using namespace mozilla;
gfxPlatform::GetLog(eGfxLog_fontinit), \
PR_LOG_DEBUG)
#define LOG_CMAPDATA_ENABLED() PR_LOG_TEST( \
gfxPlatform::GetLog(eGfxLog_cmapdata), \
PR_LOG_DEBUG)
// font info loader constants
// avoid doing this during startup even on slow machines but try to start
@ -371,6 +375,16 @@ gfxDWriteFontEntry::ReadCMAP()
rv = gfxFontUtils::ReadCMAP(cmap, buffer.Length(),
mCharacterMap, mUVSOffset,
unicodeFont, symbolFont);
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
NS_ConvertUTF16toUTF8(mName).get());
mCharacterMap.Dump(prefix, eGfxLog_cmapdata);
}
#endif
mHasCmapTable = NS_SUCCEEDED(rv);
return rv;
}
@ -411,6 +425,12 @@ gfxDWriteFontEntry::ReadCMAP()
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
NS_ConvertUTF16toUTF8(mName).get());
mCharacterMap.Dump(prefix, eGfxLog_cmapdata);
}
#endif
mHasCmapTable = NS_SUCCEEDED(rv);

View File

@ -37,6 +37,11 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_LOGGING
#define FORCE_PR_LOG /* Allow logging in the release build */
#endif
#include "prlog.h"
#include "mozilla/Util.h"
#include "gfxFontUtils.h"
@ -51,6 +56,7 @@
#include "nsICharsetConverterManager.h"
#include "plbase64.h"
#include "prlog.h"
#include "woff.h"
@ -58,6 +64,13 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
#ifdef PR_LOGGING
#define LOG(log, args) PR_LOG(gfxPlatform::GetLog(log), \
PR_LOG_DEBUG, args)
#endif // PR_LOGGING
#define NO_RANGE_FOUND 126 // bit 126 in the font unicode ranges is required to be 0
#define UNICODE_BMP_LIMIT 0x10000
@ -269,6 +282,37 @@ typedef struct {
#pragma pack()
#if PR_LOGGING
void
gfxSparseBitSet::Dump(const char* aPrefix, eGfxLog aWhichLog) const
{
NS_ASSERTION(mBlocks.DebugGetHeader(), "mHdr is null, this is bad");
PRUint32 b, numBlocks = mBlocks.Length();
for (b = 0; b < numBlocks; b++) {
Block *block = mBlocks[b];
if (!block) continue;
char outStr[256];
int index = 0;
index += sprintf(&outStr[index], "%s u+%6.6x [", aPrefix, (b << BLOCK_INDEX_SHIFT));
for (int i = 0; i < 32; i += 4) {
for (int j = i; j < i + 4; j++) {
PRUint8 bits = block->mBits[j];
PRUint8 flip1 = ((bits & 0xaa) >> 1) | ((bits & 0x55) << 1);
PRUint8 flip2 = ((flip1 & 0xcc) >> 2) | ((flip1 & 0x33) << 2);
PRUint8 flipped = ((flip2 & 0xf0) >> 4) | ((flip2 & 0x0f) << 4);
index += sprintf(&outStr[index], "%2.2x", flipped);
}
if (i + 4 != 32) index += sprintf(&outStr[index], " ");
}
index += sprintf(&outStr[index], "]");
LOG(aWhichLog, ("%s", outStr));
}
}
#endif
nsresult
gfxFontUtils::ReadCMAPTableFormat12(const PRUint8 *aBuf, PRUint32 aLength,
gfxSparseBitSet& aCharacterMap)

View File

@ -41,6 +41,7 @@
#define GFX_FONT_UTILS_H
#include "gfxTypes.h"
#include "gfxPlatform.h"
#include "prtypes.h"
#include "nsAlgorithm.h"
@ -97,6 +98,11 @@ public:
return ((block->mBits[(aIndex>>3) & (BLOCK_SIZE - 1)]) & (1 << (aIndex & 0x7))) != 0;
}
#if PR_LOGGING
// dump out contents of bitmap
void Dump(const char* aPrefix, eGfxLog aWhichLog) const;
#endif
bool TestRange(PRUint32 aStart, PRUint32 aEnd) {
PRUint32 startBlock, endBlock, blockLen;

View File

@ -83,6 +83,10 @@ using namespace mozilla;
gfxPlatform::GetLog(eGfxLog_fontlist), \
PR_LOG_DEBUG)
#define LOG_CMAPDATA_ENABLED() PR_LOG_TEST( \
gfxPlatform::GetLog(eGfxLog_cmapdata), \
PR_LOG_DEBUG)
#endif // PR_LOGGING
// font info loader constants
@ -227,6 +231,12 @@ GDIFontEntry::ReadCMAP()
#ifdef PR_LOGGING
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(), mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
NS_ConvertUTF16toUTF8(mName).get());
mCharacterMap.Dump(prefix, eGfxLog_cmapdata);
}
#endif
return rv;
}

View File

@ -136,6 +136,9 @@ static NSString* GetNSStringForString(const nsAString& aSrc)
#define LOG_FONTLIST_ENABLED() PR_LOG_TEST( \
gfxPlatform::GetLog(eGfxLog_fontlist), \
PR_LOG_DEBUG)
#define LOG_CMAPDATA_ENABLED() PR_LOG_TEST( \
gfxPlatform::GetLog(eGfxLog_cmapdata), \
PR_LOG_DEBUG)
#endif // PR_LOGGING
@ -267,6 +270,12 @@ MacOSFontEntry::ReadCMAP()
LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d\n",
NS_ConvertUTF16toUTF8(mName).get(),
mCharacterMap.GetSize()));
if (LOG_CMAPDATA_ENABLED()) {
char prefix[256];
sprintf(prefix, "(cmapdata) name: %.220s",
NS_ConvertUTF16toUTF8(mName).get());
mCharacterMap.Dump(prefix, eGfxLog_cmapdata);
}
#endif
return rv;

View File

@ -118,6 +118,7 @@ static PRLogModuleInfo *sFontlistLog = nsnull;
static PRLogModuleInfo *sFontInitLog = nsnull;
static PRLogModuleInfo *sTextrunLog = nsnull;
static PRLogModuleInfo *sTextrunuiLog = nsnull;
static PRLogModuleInfo *sCmapDataLog = nsnull;
#endif
/* Class to listen for pref changes so that chrome code can dynamically
@ -268,6 +269,7 @@ gfxPlatform::Init()
sFontInitLog = PR_NewLogModule("fontinit");;
sTextrunLog = PR_NewLogModule("textrun");;
sTextrunuiLog = PR_NewLogModule("textrunui");;
sCmapDataLog = PR_NewLogModule("cmapdata");;
#endif
@ -1397,6 +1399,9 @@ gfxPlatform::GetLog(eGfxLog aWhichLog)
case eGfxLog_textrunui:
return sTextrunuiLog;
break;
case eGfxLog_cmapdata:
return sCmapDataLog;
break;
default:
break;
}

View File

@ -136,7 +136,9 @@ enum eGfxLog {
// dump text runs, font matching, system fallback for content
eGfxLog_textrun = 2,
// dump text runs, font matching, system fallback for chrome
eGfxLog_textrunui = 3
eGfxLog_textrunui = 3,
// dump cmap coverage data as they are loaded
eGfxLog_cmapdata = 4
};
// when searching through pref langs, max number of pref langs