clean up debug diagnostics in SkTestFont
We're going to be using this more often to the point that the extra SkDebugf() calls are going to be annoying. May also fix a crash? Change-Id: I796037568cce720ecb3d0b4f4272af5d700760ea Reviewed-on: https://skia-review.googlesource.com/70180 Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
63b8a434dc
commit
8675f9b5eb
@ -30,10 +30,6 @@ SkTestFont::SkTestFont(const SkTestFontData& fontData)
|
||||
, fPaths(nullptr)
|
||||
{
|
||||
init(fontData.fPoints, fontData.fVerbs);
|
||||
#ifdef SK_DEBUG
|
||||
sk_bzero(fDebugBits, sizeof(fDebugBits));
|
||||
sk_bzero(fDebugOverage, sizeof(fDebugOverage));
|
||||
#endif
|
||||
}
|
||||
|
||||
SkTestFont::~SkTestFont() {
|
||||
@ -43,42 +39,12 @@ SkTestFont::~SkTestFont() {
|
||||
delete[] fPaths;
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
|
||||
#include "SkMutex.h"
|
||||
SK_DECLARE_STATIC_MUTEX(gUsedCharsMutex);
|
||||
|
||||
#endif
|
||||
|
||||
int SkTestFont::codeToIndex(SkUnichar charCode) const {
|
||||
#ifdef SK_DEBUG // detect missing test font data
|
||||
{
|
||||
SkAutoMutexAcquire ac(gUsedCharsMutex);
|
||||
if (charCode >= ' ' && charCode <= '~') {
|
||||
int bitOffset = charCode - ' ';
|
||||
fDebugBits[bitOffset >> 3] |= 1 << (bitOffset & 7);
|
||||
} else {
|
||||
int index = 0;
|
||||
while (fDebugOverage[index] != 0 && fDebugOverage[index] != charCode
|
||||
&& index < (int) sizeof(fDebugOverage)) {
|
||||
++index;
|
||||
}
|
||||
SkASSERT(index < (int) sizeof(fDebugOverage));
|
||||
if (fDebugOverage[index] == 0) {
|
||||
fDebugOverage[index] = charCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (unsigned index = 0; index < fCharCodesCount; ++index) {
|
||||
if (fCharCodes[index] == (unsigned) charCode) {
|
||||
return (int) index;
|
||||
}
|
||||
}
|
||||
|
||||
SkDEBUGF(("missing '%c' (%d) from %s (weight %d, width %d, slant %d)\n",
|
||||
(char) charCode, charCode, fDebugName,
|
||||
fDebugStyle.weight(), fDebugStyle.width(), fDebugStyle.slant()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,6 @@ public:
|
||||
virtual ~SkTestFont();
|
||||
int codeToIndex(SkUnichar charCode) const;
|
||||
void init(const SkScalar* pts, const unsigned char* verbs);
|
||||
#ifdef SK_DEBUG // detect missing test font data
|
||||
mutable unsigned char fDebugBits[16];
|
||||
mutable SkUnichar fDebugOverage[8];
|
||||
const char* fDebugName;
|
||||
SkFontStyle fDebugStyle;
|
||||
const char* debugFontName() const { return fName; }
|
||||
#endif
|
||||
private:
|
||||
const unsigned* fCharCodes;
|
||||
const size_t fCharCodesCount;
|
||||
|
@ -61,8 +61,6 @@ sk_sp<SkTypeface> create_font(const char* name, SkFontStyle style) {
|
||||
font = fontData->fCachedFont;
|
||||
} else {
|
||||
font = sk_make_sp<SkTestFont>(*fontData);
|
||||
SkDEBUGCODE(font->fDebugName = sub->fName);
|
||||
SkDEBUGCODE(font->fDebugStyle = sub->fStyle);
|
||||
fontData->fCachedFont = font;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user