summaryrefslogtreecommitdiffstats
path: root/libs/hwui/AssetAtlas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/AssetAtlas.cpp')
-rw-r--r--libs/hwui/AssetAtlas.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp
index e5a93bd..c6de535 100644
--- a/libs/hwui/AssetAtlas.cpp
+++ b/libs/hwui/AssetAtlas.cpp
@@ -36,39 +36,37 @@ void AssetAtlas::init(sp<GraphicBuffer> buffer, int64_t* map, int count) {
ATRACE_NAME("AssetAtlas::init");
mImage = new Image(buffer);
-
if (mImage->getTexture()) {
- Caches& caches = Caches::getInstance();
-
- mTexture = new Texture(caches);
- mTexture->id = mImage->getTexture();
- mTexture->width = buffer->getWidth();
- mTexture->height = buffer->getHeight();
-
- createEntries(caches, map, count);
+ if (!mTexture) {
+ Caches& caches = Caches::getInstance();
+ mTexture = new Texture(caches);
+ mTexture->width = buffer->getWidth();
+ mTexture->height = buffer->getHeight();
+ createEntries(caches, map, count);
+ }
} else {
ALOGW("Could not create atlas image");
-
delete mImage;
mImage = NULL;
- mTexture = NULL;
}
- mGenerationId++;
+ updateTextureId();
}
void AssetAtlas::terminate() {
if (mImage) {
delete mImage;
mImage = NULL;
+ updateTextureId();
+ }
+}
- delete mTexture;
- mTexture = NULL;
- for (size_t i = 0; i < mEntries.size(); i++) {
- delete mEntries.valueAt(i);
- }
- mEntries.clear();
+void AssetAtlas::updateTextureId() {
+ mTexture->id = mImage ? mImage->getTexture() : 0;
+ for (size_t i = 0; i < mEntries.size(); i++) {
+ AssetAtlas::Entry* entry = mEntries.valueAt(i);
+ entry->texture->id = mTexture->id;
}
}
@@ -133,7 +131,6 @@ void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
y / height, (y + bitmap->height()) / height);
Texture* texture = new DelegateTexture(caches, mTexture);
- texture->id = mTexture->id;
texture->blend = !bitmap->isOpaque();
texture->width = bitmap->width();
texture->height = bitmap->height();