Loading core/jni/android/graphics/Path.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) { #ifdef USE_OPENGL_RENDERER if (android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.remove(obj); android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } #endif delete obj; Loading libs/hwui/Caches.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,16 @@ void Caches::dumpMemoryUsage() { LOGD("\n"); } /////////////////////////////////////////////////////////////////////////////// // Memory management /////////////////////////////////////////////////////////////////////////////// void Caches::clearGarbage() { textureCache.clearGarbage(); gradientCache.clearGarbage(); pathCache.clearGarbage(); } /////////////////////////////////////////////////////////////////////////////// // VBO /////////////////////////////////////////////////////////////////////////////// Loading libs/hwui/Caches.h +6 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,12 @@ public: return mDebugLevel; } /** * Call this on each frame to ensure that garbage is deleted from * GPU memory. */ void clearGarbage(); /** * Binds the VBO used to render simple textured quads. */ Loading libs/hwui/DisplayListRenderer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -159,7 +159,7 @@ DisplayList::~DisplayList() { if (mPathHeap) { for (int i = 0; i < mPathHeap->count(); i++) { caches.pathCache.remove(&(*mPathHeap)[i]); caches.pathCache.removeDeferred(&(*mPathHeap)[i]); } mPathHeap->safeUnref(); } Loading libs/hwui/GradientCache.cpp +14 −11 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ GradientCache::GradientCache(uint32_t maxByteSize): } GradientCache::~GradientCache() { Mutex::Autolock _l(mLock); mCache.clear(); } Loading @@ -63,17 +62,14 @@ GradientCache::~GradientCache() { /////////////////////////////////////////////////////////////////////////////// uint32_t GradientCache::getSize() { Mutex::Autolock _l(mLock); return mSize; } uint32_t GradientCache::getMaxSize() { Mutex::Autolock _l(mLock); return mMaxSize; } void GradientCache::setMaxSize(uint32_t maxSize) { Mutex::Autolock _l(mLock); mMaxSize = maxSize; while (mSize > mMaxSize) { mCache.removeOldest(); Loading Loading @@ -102,17 +98,28 @@ void GradientCache::operator()(SkShader*& shader, Texture*& texture) { /////////////////////////////////////////////////////////////////////////////// Texture* GradientCache::get(SkShader* shader) { Mutex::Autolock _l(mLock); return mCache.get(shader); } void GradientCache::remove(SkShader* shader) { Mutex::Autolock _l(mLock); mCache.remove(shader); } void GradientCache::clear() { void GradientCache::removeDeferred(SkShader* shader) { Mutex::Autolock _l(mLock); mGarbage.push(shader); } void GradientCache::clearGarbage() { Mutex::Autolock _l(mLock); size_t count = mGarbage.size(); for (size_t i = 0; i < count; i++) { mCache.remove(mGarbage.itemAt(i)); } mGarbage.clear(); } void GradientCache::clear() { mCache.clear(); } Loading @@ -138,21 +145,17 @@ Texture* GradientCache::addLinearGradient(SkShader* shader, uint32_t* colors, canvas.drawRectCoords(0.0f, 0.0f, bitmap.width(), 1.0f, p); mLock.lock(); // Asume the cache is always big enough const uint32_t size = bitmap.rowBytes() * bitmap.height(); while (mSize + size > mMaxSize) { mCache.removeOldest(); } mLock.unlock(); Texture* texture = new Texture; generateTexture(&bitmap, texture); mLock.lock(); mSize += size; mCache.put(shader, texture); mLock.unlock(); return texture; } Loading Loading
core/jni/android/graphics/Path.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public: static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) { #ifdef USE_OPENGL_RENDERER if (android::uirenderer::Caches::hasInstance()) { android::uirenderer::Caches::getInstance().pathCache.remove(obj); android::uirenderer::Caches::getInstance().pathCache.removeDeferred(obj); } #endif delete obj; Loading
libs/hwui/Caches.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,16 @@ void Caches::dumpMemoryUsage() { LOGD("\n"); } /////////////////////////////////////////////////////////////////////////////// // Memory management /////////////////////////////////////////////////////////////////////////////// void Caches::clearGarbage() { textureCache.clearGarbage(); gradientCache.clearGarbage(); pathCache.clearGarbage(); } /////////////////////////////////////////////////////////////////////////////// // VBO /////////////////////////////////////////////////////////////////////////////// Loading
libs/hwui/Caches.h +6 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,12 @@ public: return mDebugLevel; } /** * Call this on each frame to ensure that garbage is deleted from * GPU memory. */ void clearGarbage(); /** * Binds the VBO used to render simple textured quads. */ Loading
libs/hwui/DisplayListRenderer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -159,7 +159,7 @@ DisplayList::~DisplayList() { if (mPathHeap) { for (int i = 0; i < mPathHeap->count(); i++) { caches.pathCache.remove(&(*mPathHeap)[i]); caches.pathCache.removeDeferred(&(*mPathHeap)[i]); } mPathHeap->safeUnref(); } Loading
libs/hwui/GradientCache.cpp +14 −11 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ GradientCache::GradientCache(uint32_t maxByteSize): } GradientCache::~GradientCache() { Mutex::Autolock _l(mLock); mCache.clear(); } Loading @@ -63,17 +62,14 @@ GradientCache::~GradientCache() { /////////////////////////////////////////////////////////////////////////////// uint32_t GradientCache::getSize() { Mutex::Autolock _l(mLock); return mSize; } uint32_t GradientCache::getMaxSize() { Mutex::Autolock _l(mLock); return mMaxSize; } void GradientCache::setMaxSize(uint32_t maxSize) { Mutex::Autolock _l(mLock); mMaxSize = maxSize; while (mSize > mMaxSize) { mCache.removeOldest(); Loading Loading @@ -102,17 +98,28 @@ void GradientCache::operator()(SkShader*& shader, Texture*& texture) { /////////////////////////////////////////////////////////////////////////////// Texture* GradientCache::get(SkShader* shader) { Mutex::Autolock _l(mLock); return mCache.get(shader); } void GradientCache::remove(SkShader* shader) { Mutex::Autolock _l(mLock); mCache.remove(shader); } void GradientCache::clear() { void GradientCache::removeDeferred(SkShader* shader) { Mutex::Autolock _l(mLock); mGarbage.push(shader); } void GradientCache::clearGarbage() { Mutex::Autolock _l(mLock); size_t count = mGarbage.size(); for (size_t i = 0; i < count; i++) { mCache.remove(mGarbage.itemAt(i)); } mGarbage.clear(); } void GradientCache::clear() { mCache.clear(); } Loading @@ -138,21 +145,17 @@ Texture* GradientCache::addLinearGradient(SkShader* shader, uint32_t* colors, canvas.drawRectCoords(0.0f, 0.0f, bitmap.width(), 1.0f, p); mLock.lock(); // Asume the cache is always big enough const uint32_t size = bitmap.rowBytes() * bitmap.height(); while (mSize + size > mMaxSize) { mCache.removeOldest(); } mLock.unlock(); Texture* texture = new Texture; generateTexture(&bitmap, texture); mLock.lock(); mSize += size; mCache.put(shader, texture); mLock.unlock(); return texture; } Loading