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

Unified Diff: src/core/SkGlyphCache.h

Issue 877113002: use murmur3 finisher to improve font hash efficiency (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: init to 0, and check for div-by-zero Created 5 years, 11 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 | « samplecode/SamplePictFile.cpp ('k') | 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 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 22:28:22 SkChecksum::MixLess?
reed1 2015/01/28 21:22:39 Done.
+ // 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*);
« no previous file with comments | « samplecode/SamplePictFile.cpp ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698