Index: src/core/SkGlyphCache.h |
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h |
index bb34a7d977411784971c9658793ad787e7197237..fc19ba0e7d82b2e8f92edc0ac77bd891960462a4 100644 |
--- a/src/core/SkGlyphCache.h |
+++ b/src/core/SkGlyphCache.h |
@@ -23,6 +23,10 @@ class SkPaint; |
class SkGlyphCache_Globals; |
+// Enable this locally to add stats for hash-table hit rates. It also extends the dump() |
+// output to show those stats. |
+//#define SK_GLYPHCACHE_TRACK_HASH_STATS |
+ |
/** \class SkGlyphCache |
This class represents a strike: a specific combination of typeface, size, |
@@ -101,6 +105,8 @@ public: |
return fScalerContext->isSubpixel(); |
} |
+ void dump() const; |
+ |
/* AuxProc/Data allow a client to associate data with this cache entry. |
Multiple clients can use this, as their data is keyed with a function |
pointer. In addition to serving as a key, the function pointer is called |
@@ -145,6 +151,8 @@ public: |
return VisitCache(typeface, desc, DetachProc, NULL); |
} |
+ static void Dump(); |
+ |
#ifdef SK_DEBUG |
void validate() const; |
#else |
@@ -204,15 +212,29 @@ private: |
// no reason to use the same kHashCount as fGlyphHash, but we do for now |
CharGlyphRec fCharToGlyphHash[kHashCount]; |
- static inline unsigned ID2HashIndex(uint32_t id) { |
- id ^= id >> 16; |
- id ^= id >> 8; |
- return id & kHashMask; |
+ static inline unsigned ID2HashIndex(uint32_t h) { |
mtklein
2015/01/27 17:10:12
Call SkChecksum::Mix()?
reed1
2015/01/27 18:33:33
I think its slight overkill (as the comment below
|
+ // apply (partial) Murmur3 finisher |
+ h ^= h >> 16; |
+ h *= 0x85ebca6b; |
+#if 0 |
+ // This part of the Murmur3 finisher does not seems necessary, i.e. it does not seem |
+ // to measurably improve our hash-hit efficiency, so we leave it out. |
+ h ^= h >> 13; |
+ h *= 0xc2b2ae35; |
+#endif |
+ h ^= h >> 16; |
+ return h & kHashMask; |
} |
// used to track (approx) how much ram is tied-up in this cache |
size_t fMemoryUsed; |
+ |
+#ifdef SK_GLYPHCACHE_TRACK_HASH_STATS |
+ int fHashHitCount; |
+ int fHashMissCount; |
+#endif |
+ |
struct AuxProcRec { |
AuxProcRec* fNext; |
void (*fProc)(void*); |