Use LruCache instead of GenerationCache in libhwui
Change-Id: Ic26ddc7151eb5462bcd243b21daf7187ed6d3bec
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 4904a58..8a0235b 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -22,8 +22,6 @@
#include "Debug.h"
#include "ShapeCache.h"
-#include "utils/Compare.h"
-
namespace android {
namespace uirenderer {
@@ -41,18 +39,28 @@
path = NULL;
}
- bool lessThan(const ShapeCacheEntry& r) const {
+ hash_t hash() const {
+ uint32_t hash = ShapeCacheEntry::hash();
+ hash = JenkinsHashMix(hash, android::hash_type(path));
+ return JenkinsHashWhiten(hash);
+ }
+
+ int compare(const ShapeCacheEntry& r) const {
+ int deltaInt = ShapeCacheEntry::compare(r);
+ if (deltaInt != 0) return deltaInt;
+
const PathCacheEntry& rhs = (const PathCacheEntry&) r;
- LTE_INT(path) {
- return false;
- }
- return false;
+ return path - rhs.path;
}
SkPath* path;
}; // PathCacheEntry
+inline hash_t hash_type(const PathCacheEntry& entry) {
+ return entry.hash();
+}
+
/**
* A simple LRU path cache. The cache has a maximum size expressed in bytes.
* Any texture added to the cache causing the cache to grow beyond the maximum