ccpr: Recycle cache entries when possible to avoid malloc

Bug: skia:
Change-Id: Id06098f66ad6399c11707f8380597e7eeb392eec
Reviewed-on: https://skia-review.googlesource.com/138441
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ccpr/GrCCPathCache.h b/src/gpu/ccpr/GrCCPathCache.h
index 6315f7c..67e7d9f 100644
--- a/src/gpu/ccpr/GrCCPathCache.h
+++ b/src/gpu/ccpr/GrCCPathCache.h
@@ -100,6 +100,8 @@
 public:
     SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrCCPathCacheEntry);
 
+    ~GrCCPathCacheEntry() override;
+
     // The number of times this specific entry (path + matrix combination) has been pulled from
     // the path cache. As long as the caller does exactly one lookup per draw, this translates to
     // the number of times the path has been drawn with a compatible matrix.
@@ -153,11 +155,15 @@
     GrCCPathCacheEntry(GrCCPathCache* cache, const MaskTransform& m)
             : fCacheWeakPtr(cache), fMaskTransform(m) {}
 
+    // Resets this entry back to not having an atlas, and purges its previous atlas texture from the
+    // resource cache if needed.
+    void invalidateAtlas();
+
     // Called when our corresponding path is modified or deleted.
     void onChange() override;
 
     GrCCPathCache* fCacheWeakPtr;  // Gets manually reset to null by the path cache upon eviction.
-    const MaskTransform fMaskTransform;
+    MaskTransform fMaskTransform;
     int fHitCount = 1;
 
     GrUniqueKey fAtlasKey;