summaryrefslogtreecommitdiff
path: root/libs/hwui/PathCache.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2016-08-22 21:48:31 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-08-22 21:48:31 +0000
commit24e38ab322a0c396df1c6fe95f3f427d85cd5da1 (patch)
tree998aca9597a6323b003cd7e0a6e96d3fccd6ba4b /libs/hwui/PathCache.cpp
parent834e5ce170a3bb7ef1a87743ec7dda5602d85797 (diff)
parent4b505376cb1d77de39d12f4f8bc88e111fbbdc5f (diff)
Merge "Fix native memory leak caused by small HWUI path cache creation"
Diffstat (limited to 'libs/hwui/PathCache.cpp')
-rw-r--r--libs/hwui/PathCache.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 3236f6f7c24d..ec86101f4c0b 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -138,7 +138,7 @@ static void drawPath(const SkPath *path, const SkPaint* paint, SkBitmap& bitmap,
PathCache::PathCache():
mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity),
- mSize(0), mMaxSize(MB(DEFAULT_PATH_CACHE_SIZE)) {
+ mSize(0), mMaxSize(MB(DEFAULT_PATH_CACHE_SIZE)), mTexNum(0) {
char property[PROPERTY_VALUE_MAX];
if (property_get(PROPERTY_PATH_CACHE_SIZE, property, nullptr) > 0) {
INIT_LOGD(" Setting %s cache size to %sMB", name, property);
@@ -202,6 +202,7 @@ void PathCache::removeTexture(PathTexture* texture) {
"the cache in an inconsistent state", size);
}
mSize -= size;
+ mTexNum--;
}
PATH_LOGD("PathCache::delete name, size, mSize = %d, %d, %d",
@@ -228,7 +229,7 @@ void PathCache::purgeCache(uint32_t width, uint32_t height) {
}
void PathCache::trim() {
- while (mSize > mMaxSize) {
+ while (mSize > mMaxSize || mTexNum > DEFAULT_PATH_TEXTURE_CAP) {
mCache.removeOldest();
}
}
@@ -299,6 +300,7 @@ void PathCache::generateTexture(SkBitmap& bitmap, Texture* texture) {
texture->setFilter(GL_LINEAR);
texture->setWrap(GL_CLAMP_TO_EDGE);
+ mTexNum++;
}
///////////////////////////////////////////////////////////////////////////////