dedup images/blobs/pictures by ID in old serialization format

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2289783002

Review-Url: https://codereview.chromium.org/2289783002
diff --git a/include/private/SkTDArray.h b/include/private/SkTDArray.h
index d6ef3a3..f71d357 100644
--- a/include/private/SkTDArray.h
+++ b/include/private/SkTDArray.h
@@ -217,6 +217,18 @@
         }
     }
 
+    template <typename S> int select(S&& selector) const {
+        const T* iter = fArray;
+        const T* stop = fArray + fCount;
+
+        for (; iter < stop; iter++) {
+            if (selector(*iter)) {
+                return SkToInt(iter - fArray);
+            }
+        }
+        return -1;
+    }
+    
     int find(const T& elem) const {
         const T* iter = fArray;
         const T* stop = fArray + fCount;