summaryrefslogtreecommitdiff
path: root/libs/hwui/PathCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2010-11-09 14:35:20 -0800
committer Romain Guy <romainguy@google.com> 2010-11-09 14:37:42 -0800
commit9e10841c27d973b930e1b49a099c69d866659505 (patch)
treeaaf593ba3581cf97a6b031a7b310e696f5cbb51a /libs/hwui/PathCache.cpp
parent820b9e0d3b6f94fe0b524aebf756ce25df273e6a (diff)
Correctly remove unused paths from the cache.
Change-Id: I41d9334dcd9871634037344ab49bf69383498161
Diffstat (limited to 'libs/hwui/PathCache.cpp')
-rw-r--r--libs/hwui/PathCache.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index b58785a6bd04..04d07dbbee8a 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -92,10 +92,13 @@ void PathCache::setMaxSize(uint32_t maxSize) {
///////////////////////////////////////////////////////////////////////////////
void PathCache::operator()(PathCacheEntry& path, PathTexture*& texture) {
- const uint32_t size = texture->width * texture->height;
- mSize -= size;
-
if (texture) {
+ const uint32_t size = texture->width * texture->height;
+ mSize -= size;
+
+ PATH_LOGD("PathCache::callback: delete path: name, size, mSize = %d, %d, %d",
+ texture->id, size, mSize);
+
glDeleteTextures(1, &texture->id);
delete texture;
}
@@ -107,12 +110,18 @@ void PathCache::operator()(PathCacheEntry& path, PathTexture*& texture) {
void PathCache::remove(SkPath* path) {
Mutex::Autolock _l(mLock);
+
// TODO: Linear search...
+ Vector<uint32_t> pathsToRemove;
for (uint32_t i = 0; i < mCache.size(); i++) {
if (mCache.getKeyAt(i).path == path) {
- mCache.removeAt(i);
+ pathsToRemove.push(i);
}
}
+
+ for (size_t i = 0; i < pathsToRemove.size(); i++) {
+ mCache.removeAt(pathsToRemove.itemAt(i));
+ }
}
PathTexture* PathCache::get(SkPath* path, SkPaint* paint) {
@@ -188,6 +197,8 @@ PathTexture* PathCache::addTexture(const PathCacheEntry& entry,
if (size < mMaxSize) {
mLock.lock();
mSize += size;
+ PATH_LOGD("PathCache::get: create path: name, size, mSize = %d, %d, %d",
+ texture->id, size, mSize);
mCache.put(entry, texture);
mLock.unlock();
} else {