Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: src/core/SkGlyphCache.h

Issue 912983002: Use SkTHashMap in SkGlyphCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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*);
« no previous file with comments | « no previous file | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698