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

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: add CheapMix helper" 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 | « src/core/SkChecksum.h ('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..e11a46025e1d7d5223f348ab04a4929b5069c57a 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,11 +5,11 @@
* found in the LICENSE file.
*/
-
#ifndef SkGlyphCache_DEFINED
#define SkGlyphCache_DEFINED
#include "SkBitmap.h"
+#include "SkChecksum.h"
#include "SkChunkAlloc.h"
#include "SkDescriptor.h"
#include "SkGlyph.h"
@@ -23,6 +22,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 +104,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 +150,8 @@ public:
return VisitCache(typeface, desc, DetachProc, NULL);
}
+ static void Dump();
+
#ifdef SK_DEBUG
void validate() const;
#else
@@ -204,15 +211,19 @@ 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) {
+ return SkChecksum::CheapMix(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 | « src/core/SkChecksum.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698