Refactor GrTextBlobCache

Instead of a single-level cache with blob-id-derived key, refactor GrTextBlobCache
as a two-level cache with a direct blob-id key (to support efficient lookup by id in
future CLs).

Change-Id: Idf29c05224faeb04919610a3935572773d5aba03
Reviewed-on: https://skia-review.googlesource.com/9400
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index ce74977..f6dac69 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -12,15 +12,16 @@
 }
 
 void GrTextBlobCache::freeAll() {
-    SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key>::Iter iter(&fCache);
-    while (!iter.done()) {
-        GrAtlasTextBlob* blob = &(*iter);
-        fBlobList.remove(blob);
-        blob->unref();
-        ++iter;
-    }
-    fCache.rewind();
+    fBlobIDCache.foreach([this](uint32_t, BlobIDCacheEntry* entry) {
+        for (auto* blob : entry->fBlobs) {
+            fBlobList.remove(blob);
+            blob->unref();
+        }
+    });
+
+    fBlobIDCache.reset();
 
     // There should be no allocations in the memory pool at this point
     SkASSERT(fPool.isEmpty());
+    SkASSERT(fBlobList.isEmpty());
 }