Index: src/gpu/GrResourceCache.h |
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h |
index 15a6da2910f97b60fb7a157df1a962731eb769b2..d24d28d3e4c742afc58840c27cb82ca1cd5063aa 100644 |
--- a/src/gpu/GrResourceCache.h |
+++ b/src/gpu/GrResourceCache.h |
@@ -13,9 +13,9 @@ |
#include "GrConfig.h" |
#include "GrTypes.h" |
-#include "GrTHashTable.h" |
#include "GrBinHashKey.h" |
#include "SkMessageBus.h" |
+#include "SkTDynamicHash.h" |
#include "SkTInternalLList.h" |
class GrResource; |
@@ -23,12 +23,6 @@ class GrResourceEntry; |
class GrResourceKey { |
public: |
- enum { |
- kHashBits = 7, |
- kHashCount = 1 << kHashBits, |
- kHashMask = kHashCount - 1 |
- }; |
- |
static GrCacheID::Domain ScratchDomain() { |
static const GrCacheID::Domain gDomain = GrCacheID::GenerateDomain(); |
return gDomain; |
@@ -61,9 +55,8 @@ public: |
this->init(id.getDomain(), id.getKey(), type, flags); |
} |
- //!< returns hash value [0..kHashMask] for the key |
- int getHash() const { |
- return fKey.getHash() & kHashMask; |
+ uint32_t getHash() const { |
+ return fKey.getHash(); |
} |
bool isScratch() const { |
@@ -83,14 +76,6 @@ public: |
} |
bool operator==(const GrResourceKey& other) const { return fKey == other.fKey; } |
- bool operator<(const GrResourceKey& other) const { return fKey < other.fKey; } |
- |
- static bool lessThan(const GrResourceEntry& entry, const GrResourceKey& key); |
- static bool equals(const GrResourceEntry& entry, const GrResourceKey& key); |
-#ifdef SK_DEBUG |
- static bool lessThan(const GrResourceEntry& a, const GrResourceEntry& b); |
- static bool equals(const GrResourceEntry& a, const GrResourceEntry& b); |
-#endif |
private: |
enum { |
@@ -135,6 +120,12 @@ public: |
GrResource* resource() const { return fResource; } |
const GrResourceKey& key() const { return fKey; } |
+ static const GrResourceKey& GetKey(const GrResourceEntry& e) { return e.key(); } |
+ static uint32_t GetKeyHash(const GrResourceKey& key) { return key.getHash(); } |
+ static bool EqualsKey(const GrResourceEntry& a, const GrResourceKey& b) { |
+ return a.key() == b; |
+ } |
+ |
#ifdef SK_DEBUG |
void validate() const; |
#else |
@@ -152,27 +143,8 @@ private: |
SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceEntry); |
friend class GrResourceCache; |
- friend class GrDLinkedList; |
}; |
-inline bool GrResourceKey::lessThan(const GrResourceEntry& entry, const GrResourceKey& key) { |
- return entry.key() < key; |
-} |
- |
-inline bool GrResourceKey::equals(const GrResourceEntry& entry, const GrResourceKey& key) { |
- return entry.key() == key; |
-} |
- |
-#ifdef SK_DEBUG |
-inline bool GrResourceKey::lessThan(const GrResourceEntry& a, const GrResourceEntry& b) { |
- return a.key() < b.key(); |
-} |
- |
-inline bool GrResourceKey::equals(const GrResourceEntry& a, const GrResourceEntry& b) { |
- return a.key() == b.key(); |
-} |
-#endif |
- |
/////////////////////////////////////////////////////////////////////////////// |
/** |
@@ -192,7 +164,7 @@ inline bool GrResourceKey::equals(const GrResourceEntry& a, const GrResourceEntr |
* |
* For even faster searches, a hash is computed from the Key. If there is |
* a collision between two keys with the same hash, we fall back on the |
- * bsearch, and update the hash to reflect the most recent Key requested. |
+ * bsearch, and update the hash to reflect the most recent Key roequested. |
* |
* It is a goal to make the GrResourceCache the central repository and bookkeeper |
* of all resources. It should replace the linked list of GrResources that |
@@ -348,7 +320,11 @@ private: |
void removeInvalidResource(GrResourceEntry* entry); |
- GrTHashTable<GrResourceEntry, GrResourceKey, 8> fCache; |
+ SkTDynamicHash<GrResourceEntry, |
+ GrResourceKey, |
+ GrResourceEntry::GetKey, |
+ GrResourceEntry::GetKeyHash, |
+ GrResourceEntry::EqualsKey> fCache; |
// We're an internal doubly linked list |
typedef SkTInternalLList<GrResourceEntry> EntryList; |