Revert "ccpr: Unregister path listeners when their cache entries are evicted"

This reverts commit f30e49310fb8927d1acbfd39f6bdc5513aa7daa1.

Reason for revert: Slow down on skps across multiple bots and configs

Original change's description:
> ccpr: Unregister path listeners when their cache entries are evicted
> 
> Bug: skia:8452
> Change-Id: I5cf63c07481db38fc37e920e04ca140bad8966e4
> Reviewed-on: https://skia-review.googlesource.com/c/163560
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

TBR=bsalomon@google.com,brianosman@google.com,csmartdalton@google.com

Change-Id: I1f9859a02d9c78e4a83e68c6b26fd8d3badd2d8e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8452
Reviewed-on: https://skia-review.googlesource.com/c/163787
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index 85d1b9c..f767323 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -707,31 +707,19 @@
     if (nullptr == listener || this == gEmpty) {
         return;
     }
-
     SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
-
-    // Clean out any stale listeners before we append the new one.
-    for (int i = 0; i < fGenIDChangeListeners.count(); ++i) {
-        if (fGenIDChangeListeners[i]->shouldUnregisterFromPath()) {
-            fGenIDChangeListeners.removeShuffle(i--);  // No need to preserve the order after i.
-        }
-    }
-
-    SkASSERT(!listener->shouldUnregisterFromPath());
-    fGenIDChangeListeners.push_back(std::move(listener));
+    *fGenIDChangeListeners.append() = listener.release();
 }
 
 // we need to be called *before* the genID gets changed or zerod
 void SkPathRef::callGenIDChangeListeners() {
     SkAutoMutexAcquire lock(fGenIDChangeListenersMutex);
-    for (const sk_sp<GenIDChangeListener>& listener : fGenIDChangeListeners) {
-        if (!listener->shouldUnregisterFromPath()) {
-            listener->onChange();
-        }
+    for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
+        fGenIDChangeListeners[i]->onChange();
     }
 
     // Listeners get at most one shot, so whether these triggered or not, blow them away.
-    fGenIDChangeListeners.reset();
+    fGenIDChangeListeners.unrefAll();
 }
 
 SkRRect SkPathRef::getRRect() const {
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index 32008c2..db85641 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -187,15 +187,12 @@
 }
 
 void GrCCPathCache::evict(GrCCPathCacheEntry* entry) {
-    // Has the entry already been evicted? (SkPaths can post eviction messages from any thread.)
-    if (entry->shouldUnregisterFromPath()) {
-        SkASSERT(!fLRU.isInList(entry));
-        return;
+    bool isInCache = entry->fNext || (fLRU.tail() == entry);
+    SkASSERT(isInCache == fLRU.isInList(entry));
+    if (isInCache) {
+        fLRU.remove(entry);
+        fHashTable.remove(HashNode::GetKey(entry));  // Do this last, as it might delete the entry.
     }
-
-    entry->markShouldUnregisterFromPath();
-    fLRU.remove(entry);
-    fHashTable.remove(HashNode::GetKey(entry));  // Do this last, as it might delete the entry.
 }
 
 void GrCCPathCache::purgeAsNeeded() {