diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/androidfw/ZipFileRO.cpp | 1 | ||||
| -rw-r--r-- | libs/hwui/PathCache.cpp | 37 | ||||
| -rw-r--r-- | libs/hwui/PathCache.h | 4 | ||||
| -rw-r--r-- | libs/hwui/Properties.h | 2 |
4 files changed, 14 insertions, 30 deletions
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp index af3d9b3..93b1d56 100644 --- a/libs/androidfw/ZipFileRO.cpp +++ b/libs/androidfw/ZipFileRO.cpp @@ -68,6 +68,7 @@ ZipFileRO::~ZipFileRO() { const int32_t error = OpenArchive(zipFileName, &handle); if (error) { ALOGW("Error opening archive %s: %s", zipFileName, ErrorCodeString(error)); + CloseArchive(handle); return NULL; } diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 74964f6..8f5fea3 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -142,7 +142,7 @@ PathCache::PathCache(): 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); - setMaxSize(MB(atof(property))); + mMaxSize = MB(atof(property)); } else { INIT_LOGD(" Using default %s cache size of %.2fMB", name, DEFAULT_PATH_CACHE_SIZE); } @@ -172,13 +172,6 @@ uint32_t PathCache::getMaxSize() { return mMaxSize; } -void PathCache::setMaxSize(uint32_t maxSize) { - mMaxSize = maxSize; - while (mSize > mMaxSize) { - mCache.removeOldest(); - } -} - /////////////////////////////////////////////////////////////////////////////// // Callbacks /////////////////////////////////////////////////////////////////////////////// @@ -267,24 +260,18 @@ void PathCache::generateTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture, bool addToCache) { generateTexture(*bitmap, texture); + // Note here that we upload to a texture even if it's bigger than mMaxSize. + // Such an entry in mCache will only be temporary, since it will be evicted + // immediately on trim, or on any other Path entering the cache. uint32_t size = texture->width * texture->height; - if (size < mMaxSize) { - mSize += size; - PATH_LOGD("PathCache::get/create: name, size, mSize = %d, %d, %d", - texture->id, size, mSize); - if (mDebugEnabled) { - ALOGD("Shape created, size = %d", size); - } - if (addToCache) { - mCache.put(entry, texture); - } - } else { - // It's okay to add a texture that's bigger than the cache since - // we'll trim the cache later when addToCache is set to false - if (!addToCache) { - mSize += size; - } - texture->cleanup = true; + mSize += size; + PATH_LOGD("PathCache::get/create: name, size, mSize = %d, %d, %d", + texture->id, size, mSize); + if (mDebugEnabled) { + ALOGD("Shape created, size = %d", size); + } + if (addToCache) { + mCache.put(entry, texture); } } diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h index 4297693..7014863 100644 --- a/libs/hwui/PathCache.h +++ b/libs/hwui/PathCache.h @@ -186,10 +186,6 @@ public: void clear(); /** - * Sets the maximum size of the cache in bytes. - */ - void setMaxSize(uint32_t maxSize); - /** * Returns the maximum size of the cache in bytes. */ uint32_t getMaxSize(); diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index cb5560f..e993f74 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -250,7 +250,7 @@ enum DebugLevel { #define DEFAULT_TEXTURE_CACHE_SIZE 24.0f #define DEFAULT_LAYER_CACHE_SIZE 16.0f #define DEFAULT_RENDER_BUFFER_CACHE_SIZE 2.0f -#define DEFAULT_PATH_CACHE_SIZE 10.0f +#define DEFAULT_PATH_CACHE_SIZE 4.0f #define DEFAULT_VERTEX_CACHE_SIZE 1.0f #define DEFAULT_PATCH_CACHE_SIZE 128 // in kB #define DEFAULT_GRADIENT_CACHE_SIZE 0.5f |
