summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2017-05-23 17:38:36 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-05-23 17:38:43 +0000
commit1bc0286ef84c68b32c2e5f820c7498cc5df3a20b (patch)
tree714a21a99ac6e8edf60de03e2e2c41a6309c8028 /libs/hwui/TextureCache.cpp
parentda4c81d942081dbe02ecf6d4c2ce9a4edf1c8595 (diff)
parent9a814875c4e3a98fea99dae623f22268a9afa38a (diff)
Merge "Improve time to texture destruction" into oc-dev
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r--libs/hwui/TextureCache.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index 63a6a2c8c89c..710cdd9286e8 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -191,25 +191,14 @@ Texture* TextureCache::get(Bitmap* bitmap) {
return texture;
}
-void TextureCache::releaseTexture(uint32_t pixelRefStableID) {
- Mutex::Autolock _l(mLock);
- mGarbage.push_back(pixelRefStableID);
-}
-
-void TextureCache::clearGarbage() {
- Mutex::Autolock _l(mLock);
- size_t count = mGarbage.size();
- for (size_t i = 0; i < count; i++) {
- uint32_t pixelRefId = mGarbage[i];
- auto hardwareIter = mHardwareTextures.find(pixelRefId);
- if (hardwareIter == mHardwareTextures.end()) {
- mCache.remove(pixelRefId);
- } else {
- hardwareIter->second->deleteTexture();
- mHardwareTextures.erase(hardwareIter);
- }
+bool TextureCache::destroyTexture(uint32_t pixelRefStableID) {
+ auto hardwareIter = mHardwareTextures.find(pixelRefStableID);
+ if (hardwareIter != mHardwareTextures.end()) {
+ hardwareIter->second->deleteTexture();
+ mHardwareTextures.erase(hardwareIter);
+ return true;
}
- mGarbage.clear();
+ return mCache.remove(pixelRefStableID);
}
void TextureCache::clear() {