Index: src/core/SkGlyphCache.h |
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h |
index b335d29d2d8a8acf2005213bd11bf7f27a82a4ca..a97a153c0122b96be860cc74f6a47c31c1604d03 100644 |
--- a/src/core/SkGlyphCache.h |
+++ b/src/core/SkGlyphCache.h |
@@ -14,18 +14,15 @@ |
#include "SkDescriptor.h" |
#include "SkGlyph.h" |
#include "SkScalerContext.h" |
-#include "SkTemplates.h" |
#include "SkTDArray.h" |
+#include "SkTHash.h" |
+#include "SkTemplates.h" |
struct SkDeviceProperties; |
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, |
@@ -195,38 +192,17 @@ private: |
SkScalerContext* fScalerContext; |
SkPaint::FontMetrics fFontMetrics; |
- enum { |
- kHashBits = 8, |
- kHashCount = 1 << kHashBits, |
- kHashMask = kHashCount - 1 |
- }; |
- SkGlyph* fGlyphHash[kHashCount]; |
- SkTDArray<SkGlyph*> fGlyphArray; |
- SkChunkAlloc fGlyphAlloc; |
+ static uint32_t HashGlyphID(uint32_t glyphID) { return SkChecksum::CheapMix(glyphID); } |
+ static uint32_t HashUnichar(SkUnichar unichar) { return SkChecksum::CheapMix(unichar); } |
- struct CharGlyphRec { |
- uint32_t fID; // unichar + subpixel |
- SkGlyph* fGlyph; |
- }; |
- // no reason to use the same kHashCount as fGlyphHash, but we do for now |
- // Dynamically allocated when chars are encountered. |
- SkAutoTArray<CharGlyphRec> fCharToGlyphHash; |
- |
- CharGlyphRec* getCharGlyphRec(uint32_t id); |
- |
- static inline unsigned ID2HashIndex(uint32_t h) { |
- return SkChecksum::CheapMix(h) & kHashMask; |
- } |
+ SkTHashMap<uint32_t, SkGlyph, HashGlyphID> fGlyphs; |
+ SkTHashMap<SkUnichar, uint16_t, HashUnichar> fCharToGlyphID; |
+ |
+ SkChunkAlloc fAlloc; |
// 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*); |