Convert GrStrikeCache to sk_sp<GrTextStrike>

Change-Id: I3f198c67dd271ff008f0696a012ed652ad5b37b8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260038
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/gpu/text/GrStrikeCache.cpp b/src/gpu/text/GrStrikeCache.cpp
index 70b3594..10f1bc7 100644
--- a/src/gpu/text/GrStrikeCache.cpp
+++ b/src/gpu/text/GrStrikeCache.cpp
@@ -23,16 +23,14 @@
                     GrMaskFormatBytesPerPixel(kA565_GrMaskFormat))) { }
 
 GrStrikeCache::~GrStrikeCache() {
-    fCache.foreach([](GrTextStrike** strike){
+    fCache.foreach([](sk_sp<GrTextStrike>* strike){
         (*strike)->fIsAbandoned = true;
-        (*strike)->unref();
     });
 }
 
 void GrStrikeCache::freeAll() {
-    fCache.foreach([](GrTextStrike** strike){
+    fCache.foreach([](sk_sp<GrTextStrike>* strike){
         (*strike)->fIsAbandoned = true;
-        (*strike)->unref();
     });
     fCache.reset();
 }
@@ -40,15 +38,14 @@
 void GrStrikeCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) {
     GrStrikeCache* grStrikeCache = reinterpret_cast<GrStrikeCache*>(ptr);
 
-    grStrikeCache->fCache.mutate([grStrikeCache, id](GrTextStrike** strikePtrPtr){
-        GrTextStrike* strike = *strikePtrPtr;
+    grStrikeCache->fCache.mutate([grStrikeCache, id](sk_sp<GrTextStrike>* strikeHandle){
+        GrTextStrike* strike = strikeHandle->get();
         strike->removeID(id);
 
         // clear out any empty strikes.  We will preserve the strike whose call to addToAtlas
         // triggered the eviction
         if (strike != grStrikeCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) {
             strike->fIsAbandoned = true;
-            strike->unref();
             return false;  // Remove this entry from the cache.
         }
         return true;  // Keep this entry in the cache.
diff --git a/src/gpu/text/GrStrikeCache.h b/src/gpu/text/GrStrikeCache.h
index 5616748..6920b4f 100644
--- a/src/gpu/text/GrStrikeCache.h
+++ b/src/gpu/text/GrStrikeCache.h
@@ -86,11 +86,9 @@
     // Therefore, the caller must check GrTextStrike::isAbandoned() if there are other
     // interactions with the cache since the strike was received.
     sk_sp<GrTextStrike> getStrike(const SkDescriptor& desc) {
-        sk_sp<GrTextStrike> strike = sk_ref_sp(fCache.findOrNull(desc));
-        if (!strike) {
-            strike = this->generateStrike(desc);
-        }
-        return strike;
+        sk_sp<GrTextStrike>* strike = fCache.find(desc);
+        if (strike) { return *strike; }
+        return this->generateStrike(desc);
     }
 
     const SkMasks& getMasks() const { return *f565Masks; }
@@ -102,13 +100,13 @@
 private:
     sk_sp<GrTextStrike> generateStrike(const SkDescriptor& desc) {
         // 'fCache' get the construction ref
-        sk_sp<GrTextStrike> strike = sk_ref_sp(new GrTextStrike(desc));
-        fCache.set(strike.get());
+        sk_sp<GrTextStrike> strike = sk_make_sp<GrTextStrike>(desc);
+        fCache.set(strike);
         return strike;
     }
 
     struct DescriptorHashTraits {
-        static const SkDescriptor& GetKey(const GrTextStrike* strike) {
+        static const SkDescriptor& GetKey(const sk_sp<GrTextStrike>& strike) {
             return *strike->fFontScalerKey.getDesc();
         }
         static uint32_t Hash(const SkDescriptor& desc) { return desc.getChecksum(); }
@@ -116,7 +114,7 @@
 
     // TODO - switch from GrTextStrike* to sk_sp<GrTextStrike>.
     // TODO - can this become SkTHashMap?
-    using StrikeHash = SkTHashTable<GrTextStrike*, SkDescriptor, DescriptorHashTraits>;
+    using StrikeHash = SkTHashTable<sk_sp<GrTextStrike>, SkDescriptor, DescriptorHashTraits>;
 
     StrikeHash fCache;
     GrTextStrike* fPreserveStrike;