diff options
author | 2012-11-28 17:35:51 -0800 | |
---|---|---|
committer | 2012-11-29 11:44:02 -0800 | |
commit | 059e12ccd20f5c249724a8362d6bac325334ea76 (patch) | |
tree | 7b15fa6bc6d2963715ea298a51cca3909c1e50c9 /libs/hwui/PathCache.cpp | |
parent | c653df46436a796556da2633f90353900344ce39 (diff) |
Use LruCache instead of GenerationCache in libhwui
Change-Id: Ic26ddc7151eb5462bcd243b21daf7187ed6d3bec
Diffstat (limited to 'libs/hwui/PathCache.cpp')
-rw-r--r-- | libs/hwui/PathCache.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 71a4ed7966ed..03ddf597b33a 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -55,22 +55,19 @@ PathCache::PathCache(): ShapeCache<PathCacheEntry>("path", } void PathCache::remove(SkPath* path) { - // TODO: Linear search... - Vector<size_t> pathsToRemove; - for (size_t i = 0; i < mCache.size(); i++) { - if (mCache.getKeyAt(i).path == path) { - pathsToRemove.push(i); - removeTexture(mCache.getValueAt(i)); + Vector<PathCacheEntry> pathsToRemove; + LruCache<PathCacheEntry, PathTexture*>::Iterator i(mCache); + + while (i.next()) { + const PathCacheEntry& key = i.key(); + if (key.path == path) { + pathsToRemove.push(key); } } - mCache.setOnEntryRemovedListener(NULL); for (size_t i = 0; i < pathsToRemove.size(); i++) { - // This will work because pathsToRemove is sorted - // and because the cache is a sorted keyed vector - mCache.removeAt(pathsToRemove.itemAt(i) - i); + mCache.remove(pathsToRemove.itemAt(i)); } - mCache.setOnEntryRemovedListener(this); } void PathCache::removeDeferred(SkPath* path) { |