diff options
| author | Romain Guy <romainguy@google.com> | 2013-05-28 14:25:09 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2013-05-28 14:32:01 -0700 |
| commit | 7d9b1b3c02eb1ffd99742ecb7b69e3ab97d2ba18 (patch) | |
| tree | 56b72ad7a4975043f28a8af8b63d3f4d9f0f630e /libs/hwui | |
| parent | 0efd4f0215f1df1207b67240d7a52b1da6af43c8 (diff) | |
| download | frameworks_base-7d9b1b3c02eb1ffd99742ecb7b69e3ab97d2ba18.zip frameworks_base-7d9b1b3c02eb1ffd99742ecb7b69e3ab97d2ba18.tar.gz frameworks_base-7d9b1b3c02eb1ffd99742ecb7b69e3ab97d2ba18.tar.bz2 | |
Re-initialize the 9patch cache if cleared with onTrimMemory
The 9aptch cache was reinitialized after destroying/recreating
the EGL context but not after clearing it during a normal
memory trim.
Change-Id: If6155bfc8a62439e9878bc742a4766b3bd6c6aec
Diffstat (limited to 'libs/hwui')
| -rw-r--r-- | libs/hwui/PatchCache.cpp | 26 | ||||
| -rw-r--r-- | libs/hwui/PatchCache.h | 3 |
2 files changed, 21 insertions, 8 deletions
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp index c2b28d1..c6ed275 100644 --- a/libs/hwui/PatchCache.cpp +++ b/libs/hwui/PatchCache.cpp @@ -40,6 +40,7 @@ PatchCache::PatchCache(): mCache(LruCache<PatchDescription, Patch*>::kUnlimitedC mMaxSize = KB(DEFAULT_PATCH_CACHE_SIZE); } mSize = 0; + mMeshBuffer = 0; } PatchCache::~PatchCache() { @@ -47,11 +48,18 @@ PatchCache::~PatchCache() { } void PatchCache::init(Caches& caches) { - glGenBuffers(1, &mMeshBuffer); + bool created = false; + if (!mMeshBuffer) { + glGenBuffers(1, &mMeshBuffer); + created = true; + } + caches.bindMeshBuffer(mMeshBuffer); caches.resetVertexPointers(); - glBufferData(GL_ARRAY_BUFFER, mMaxSize, NULL, GL_DYNAMIC_DRAW); + if (created) { + glBufferData(GL_ARRAY_BUFFER, mMaxSize, NULL, GL_DYNAMIC_DRAW); + } } /////////////////////////////////////////////////////////////////////////////// @@ -73,9 +81,14 @@ int PatchCache::PatchDescription::compare(const PatchCache::PatchDescription& lh } void PatchCache::clear() { - glDeleteBuffers(1, &mMeshBuffer); clearCache(); - mSize = 0; + + if (mMeshBuffer) { + Caches::getInstance().unbindMeshBuffer(); + glDeleteBuffers(1, &mMeshBuffer); + mMeshBuffer = 0; + mSize = 0; + } } void PatchCache::clearCache() { @@ -106,9 +119,8 @@ const Patch* PatchCache::get(const AssetAtlas::Entry* entry, } if (vertices) { - Caches& caches = Caches::getInstance(); - caches.bindMeshBuffer(mMeshBuffer); - caches.resetVertexPointers(); + // This call ensures the VBO exists and that it is bound + init(Caches::getInstance()); // TODO: Simply remove the oldest items until we have enough room // This will require to keep a list of free blocks in the VBO diff --git a/libs/hwui/PatchCache.h b/libs/hwui/PatchCache.h index 129a0dc..530dad0 100644 --- a/libs/hwui/PatchCache.h +++ b/libs/hwui/PatchCache.h @@ -121,9 +121,10 @@ private: uint32_t mMaxSize; uint32_t mSize; - LruCache<PatchDescription, Patch*> mCache; GLuint mMeshBuffer; + + LruCache<PatchDescription, Patch*> mCache; }; // class PatchCache }; // namespace uirenderer |
