diff options
author | robertphillips <robertphillips@google.com> | 2014-07-20 09:40:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-20 09:40:00 -0700 |
commit | 3d533ac917eaadf2fb3561f57d7266d8c0e665fd (patch) | |
tree | e1a710cf8756032da254ec484a4bb6128e61086d /src/gpu/effects | |
parent | 249171e7d29b5559f3eefe9dbd437030bfad3fda (diff) |
Replace GrTHash with SkTDynamicHash
Mike: SkTDynamicHash changes
Brian: Ganesh changes
This removes three instances of GrTHash leaving the ones in GrTextStrike.h
R=mtklein@google.com, bsalomon@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/402693003
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.cpp | 18 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.h | 31 |
2 files changed, 20 insertions, 29 deletions
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 0aa9dc3514..e3927c0d1f 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -17,17 +17,17 @@ #define VALIDATE #endif +class GrTextureStripAtlas::Hash : public SkTDynamicHash<GrTextureStripAtlas::AtlasEntry, + GrTextureStripAtlas::AtlasEntry::Key> {}; + int32_t GrTextureStripAtlas::gCacheCount = 0; -GrTHashTable<GrTextureStripAtlas::AtlasEntry, - GrTextureStripAtlas::AtlasHashKey, 8>* - GrTextureStripAtlas::gAtlasCache = NULL; +GrTextureStripAtlas::Hash* GrTextureStripAtlas::gAtlasCache = NULL; -GrTHashTable<GrTextureStripAtlas::AtlasEntry, GrTextureStripAtlas::AtlasHashKey, 8>* -GrTextureStripAtlas::GetCache() { +GrTextureStripAtlas::Hash* GrTextureStripAtlas::GetCache() { if (NULL == gAtlasCache) { - gAtlasCache = SkNEW((GrTHashTable<AtlasEntry, AtlasHashKey, 8>)); + gAtlasCache = SkNEW(Hash); } return gAtlasCache; @@ -40,7 +40,7 @@ void GrTextureStripAtlas::CleanUp(const GrContext*, void* info) { AtlasEntry* entry = static_cast<AtlasEntry*>(info); // remove the cache entry - GetCache()->remove(entry->fKey, entry); + GetCache()->remove(entry->fKey); // remove the actual entry SkDELETE(entry); @@ -52,7 +52,7 @@ void GrTextureStripAtlas::CleanUp(const GrContext*, void* info) { } GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::Desc& desc) { - AtlasHashKey key; + AtlasEntry::Key key; key.setKeyData(desc.asKey()); AtlasEntry* entry = GetCache()->find(key); if (NULL == entry) { @@ -63,7 +63,7 @@ GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::De desc.fContext->addCleanUp(CleanUp, entry); - GetCache()->insert(key, entry); + GetCache()->add(entry); } return entry->fAtlas; diff --git a/src/gpu/effects/GrTextureStripAtlas.h b/src/gpu/effects/GrTextureStripAtlas.h index 5227cc38bd..6d2fb8fdf8 100644 --- a/src/gpu/effects/GrTextureStripAtlas.h +++ b/src/gpu/effects/GrTextureStripAtlas.h @@ -9,10 +9,10 @@ #define GrTextureStripAtlas_DEFINED #include "GrBinHashKey.h" -#include "GrTHashTable.h" #include "SkBitmap.h" #include "SkGr.h" #include "SkTDArray.h" +#include "SkTDynamicHash.h" #include "SkTypes.h" /** @@ -135,23 +135,24 @@ private: static void CleanUp(const GrContext* context, void* info); // Hash table entry for atlases - class AtlasEntry; - class AtlasHashKey : public GrBinHashKey<sizeof(GrTextureStripAtlas::Desc)> { - public: - static bool Equals(const AtlasEntry& entry, const AtlasHashKey& key); - static bool LessThan(const AtlasEntry& entry, const AtlasHashKey& key); - }; class AtlasEntry : public ::SkNoncopyable { public: + // for SkTDynamicHash + class Key : public GrMurmur3HashKey<sizeof(GrTextureStripAtlas::Desc)> {}; + static const Key& GetKey(const AtlasEntry& entry) { return entry.fKey; } + static uint32_t Hash(const Key& key) { return key.getHash(); } + + // AtlasEntry proper AtlasEntry() : fAtlas(NULL) {} ~AtlasEntry() { SkDELETE(fAtlas); } - AtlasHashKey fKey; + Key fKey; GrTextureStripAtlas* fAtlas; }; - static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* gAtlasCache; + class Hash; + static Hash* gAtlasCache; - static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* GetCache(); + static Hash* GetCache(); // We increment gCacheCount for each atlas static int32_t gCacheCount; @@ -181,14 +182,4 @@ private: SkTDArray<AtlasRow*> fKeyTable; }; -inline bool GrTextureStripAtlas::AtlasHashKey::Equals(const AtlasEntry& entry, - const AtlasHashKey& key) { - return entry.fKey == key; -} - -inline bool GrTextureStripAtlas::AtlasHashKey::LessThan(const AtlasEntry& entry, - const AtlasHashKey& key) { - return entry.fKey < key; -} - #endif |