summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/hwui/DisplayListRenderer.cpp11
-rw-r--r--libs/hwui/PathCache.cpp19
-rw-r--r--libs/hwui/PathCache.h18
-rw-r--r--libs/hwui/TextureCache.cpp8
-rw-r--r--libs/hwui/TextureCache.h4
5 files changed, 50 insertions, 10 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 770e5966db61..d08df44006be 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -127,7 +127,9 @@ DisplayList::DisplayList(const DisplayListRenderer& recorder) {
}
mPathHeap = recorder.mPathHeap;
- mPathHeap->safeRef();
+ if (mPathHeap) {
+ mPathHeap->safeRef();
+ }
}
DisplayList::~DisplayList() {
@@ -155,7 +157,12 @@ DisplayList::~DisplayList() {
}
mMatrices.clear();
- mPathHeap->safeUnref();
+ if (mPathHeap) {
+ for (int i = 0; i < mPathHeap->count(); i++) {
+ caches.pathCache.remove(&(*mPathHeap)[i]);
+ }
+ mPathHeap->safeUnref();
+ }
}
void DisplayList::init() {
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 {
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index db5ce0833635..aea71cb757b8 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -28,6 +28,24 @@
namespace android {
namespace uirenderer {
+///////////////////////////////////////////////////////////////////////////////
+// Defines
+///////////////////////////////////////////////////////////////////////////////
+
+// Debug
+#define DEBUG_PATHS 0
+
+// Debug
+#if DEBUG_PATHS
+ #define PATH_LOGD(...) LOGD(__VA_ARGS__)
+#else
+ #define PATH_LOGD(...)
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// Classes
+///////////////////////////////////////////////////////////////////////////////
+
/**
* Describe a path in the path cache.
*/
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 0c7948f70f98..2497925d66e1 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -94,8 +94,8 @@ void TextureCache::operator()(SkBitmap*& bitmap, Texture*& texture) {
// This will be called already locked
if (texture) {
mSize -= texture->bitmapSize;
- TEXTURE_LOGD("TextureCache::callback: removed size, mSize = %d, %d",
- texture->bitmapSize, mSize);
+ TEXTURE_LOGD("TextureCache::callback: name, removed size, mSize = %d, %d, %d",
+ texture->id, texture->bitmapSize, mSize);
glDeleteTextures(1, &texture->id);
delete texture;
}
@@ -133,8 +133,8 @@ Texture* TextureCache::get(SkBitmap* bitmap) {
if (size < mMaxSize) {
mLock.lock();
mSize += size;
- TEXTURE_LOGD("TextureCache::get: create texture(0x%p): size, mSize = %d, %d",
- bitmap, size, mSize);
+ TEXTURE_LOGD("TextureCache::get: create texture(%p): name, size, mSize = %d, %d, %d",
+ bitmap, texture->id, size, mSize);
mCache.put(bitmap, texture);
mLock.unlock();
} else {
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index d9d2387fd56a..5c314fc83a04 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -39,6 +39,10 @@ namespace uirenderer {
#define TEXTURE_LOGD(...)
#endif
+///////////////////////////////////////////////////////////////////////////////
+// Classes
+///////////////////////////////////////////////////////////////////////////////
+
/**
* A simple LRU texture cache. The cache has a maximum size expressed in bytes.
* Any texture added to the cache causing the cache to grow beyond the maximum