summaryrefslogtreecommitdiff
path: root/libs/hwui/AssetAtlas.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2014-12-11 01:25:54 +0000
committer android-build-merger <android-build-merger@google.com> 2014-12-11 01:25:54 +0000
commitd67bb5015f716c094beff02b2c5e77c9bb7d11a0 (patch)
tree4f23359e87a1bb079bd499f922d763e45c7a8752 /libs/hwui/AssetAtlas.cpp
parent934d8d85be221b86cb5097625c0f48391b3a71b2 (diff)
parente4a6ed9d6d8721c9fad018b0d43dfe7daf4b24e7 (diff)
am eb2dcc79: Merge "Don\'t preload textures for AssetAtlas" into lmp-mr1-dev
automerge: e4a6ed9 * commit 'e4a6ed9d6d8721c9fad018b0d43dfe7daf4b24e7': Don't preload textures for AssetAtlas
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 e5a93bde191b..c6de53594b0f 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();