Loading libs/hwui/DisplayListRenderer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -127,8 +127,10 @@ DisplayList::DisplayList(const DisplayListRenderer& recorder) { } mPathHeap = recorder.mPathHeap; if (mPathHeap) { mPathHeap->safeRef(); } } DisplayList::~DisplayList() { sk_free((void*) mReader.base()); Loading @@ -155,8 +157,13 @@ DisplayList::~DisplayList() { } mMatrices.clear(); if (mPathHeap) { for (int i = 0; i < mPathHeap->count(); i++) { caches.pathCache.remove(&(*mPathHeap)[i]); } mPathHeap->safeUnref(); } } void DisplayList::init() { mPathHeap = NULL; Loading libs/hwui/PathCache.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -92,10 +92,13 @@ void PathCache::setMaxSize(uint32_t maxSize) { /////////////////////////////////////////////////////////////////////////////// void PathCache::operator()(PathCacheEntry& path, PathTexture*& texture) { if (texture) { const uint32_t size = texture->width * texture->height; mSize -= size; if (texture) { PATH_LOGD("PathCache::callback: delete path: name, size, mSize = %d, %d, %d", texture->id, size, mSize); glDeleteTextures(1, &texture->id); delete texture; } Loading @@ -107,11 +110,17 @@ 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)); } } Loading Loading @@ -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 { Loading libs/hwui/PathCache.h +18 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading libs/hwui/TextureCache.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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 { Loading libs/hwui/TextureCache.h +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
libs/hwui/DisplayListRenderer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -127,8 +127,10 @@ DisplayList::DisplayList(const DisplayListRenderer& recorder) { } mPathHeap = recorder.mPathHeap; if (mPathHeap) { mPathHeap->safeRef(); } } DisplayList::~DisplayList() { sk_free((void*) mReader.base()); Loading @@ -155,8 +157,13 @@ DisplayList::~DisplayList() { } mMatrices.clear(); if (mPathHeap) { for (int i = 0; i < mPathHeap->count(); i++) { caches.pathCache.remove(&(*mPathHeap)[i]); } mPathHeap->safeUnref(); } } void DisplayList::init() { mPathHeap = NULL; Loading
libs/hwui/PathCache.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -92,10 +92,13 @@ void PathCache::setMaxSize(uint32_t maxSize) { /////////////////////////////////////////////////////////////////////////////// void PathCache::operator()(PathCacheEntry& path, PathTexture*& texture) { if (texture) { const uint32_t size = texture->width * texture->height; mSize -= size; if (texture) { PATH_LOGD("PathCache::callback: delete path: name, size, mSize = %d, %d, %d", texture->id, size, mSize); glDeleteTextures(1, &texture->id); delete texture; } Loading @@ -107,11 +110,17 @@ 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)); } } Loading Loading @@ -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 { Loading
libs/hwui/PathCache.h +18 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading
libs/hwui/TextureCache.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading @@ -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 { Loading
libs/hwui/TextureCache.h +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading