Add logic to clean up resources more frequently

Added call to Skia's performDeferredCleanup method
to free resources that were not referenced within
the last 100 frames or 10 seconds whichever is
furthest away

Bug: 188450217
Test: manual
Change-Id: I3f37e1b5bd01330dbbc2da4a84b1259d56be2768
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index 46e8060..ded2b06 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -210,6 +210,14 @@
     }
 }
 
+void CacheManager::performDeferredCleanup(nsecs_t cleanupOlderThanMillis) {
+    if (mGrContext) {
+        mGrContext->performDeferredCleanup(
+            std::chrono::milliseconds(cleanupOlderThanMillis),
+            /* scratchResourcesOnly */true);
+    }
+}
+
 } /* namespace renderthread */
 } /* namespace uirenderer */
 } /* namespace android */