summaryrefslogtreecommitdiffstats
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r--libs/hwui/TextureCache.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index fe1b7fd..fda0091 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -122,10 +122,12 @@ void TextureCache::setAssetAtlas(AssetAtlas* assetAtlas) {
mAssetAtlas = assetAtlas;
}
-void TextureCache::resetMarkInUse() {
+void TextureCache::resetMarkInUse(void* ownerToken) {
LruCache<uint32_t, Texture*>::Iterator iter(mCache);
while (iter.next()) {
- iter.value()->isInUse = false;
+ if (iter.value()->isInUse == ownerToken) {
+ iter.value()->isInUse = nullptr;
+ }
}
}
@@ -140,8 +142,8 @@ bool TextureCache::canMakeTextureFromBitmap(const SkBitmap* bitmap) {
// Returns a prepared Texture* that either is already in the cache or can fit
// in the cache (and is thus added to the cache)
-Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap) {
- if (CC_LIKELY(mAssetAtlas)) {
+Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap, AtlasUsageType atlasUsageType) {
+ if (CC_LIKELY(mAssetAtlas != nullptr) && atlasUsageType == AtlasUsageType::Use) {
AssetAtlas::Entry* entry = mAssetAtlas->getEntry(bitmap);
if (CC_UNLIKELY(entry)) {
return entry->texture;
@@ -189,16 +191,16 @@ Texture* TextureCache::getCachedTexture(const SkBitmap* bitmap) {
return texture;
}
-bool TextureCache::prefetchAndMarkInUse(const SkBitmap* bitmap) {
- Texture* texture = getCachedTexture(bitmap);
+bool TextureCache::prefetchAndMarkInUse(void* ownerToken, const SkBitmap* bitmap) {
+ Texture* texture = getCachedTexture(bitmap, AtlasUsageType::Use);
if (texture) {
- texture->isInUse = true;
+ texture->isInUse = ownerToken;
}
return texture;
}
-Texture* TextureCache::get(const SkBitmap* bitmap) {
- Texture* texture = getCachedTexture(bitmap);
+Texture* TextureCache::get(const SkBitmap* bitmap, AtlasUsageType atlasUsageType) {
+ Texture* texture = getCachedTexture(bitmap, atlasUsageType);
if (!texture) {
if (!canMakeTextureFromBitmap(bitmap)) {