Track texture memory globally
Also mostly consolidates texture creation
Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h
index a037725..75400ff 100644
--- a/libs/hwui/AssetAtlas.h
+++ b/libs/hwui/AssetAtlas.h
@@ -17,19 +17,17 @@
#ifndef ANDROID_HWUI_ASSET_ATLAS_H
#define ANDROID_HWUI_ASSET_ATLAS_H
-#include <GLES2/gl2.h>
-
-#include <ui/GraphicBuffer.h>
-
-#include <utils/KeyedVector.h>
-
-#include <cutils/compiler.h>
-
-#include <SkBitmap.h>
-
#include "Texture.h"
#include "UvMapper.h"
+#include <cutils/compiler.h>
+#include <GLES2/gl2.h>
+#include <ui/GraphicBuffer.h>
+#include <SkBitmap.h>
+
+#include <memory>
+#include <unordered_map>
+
namespace android {
namespace uirenderer {
@@ -71,6 +69,10 @@
return texture->blend ? &atlas.mBlendKey : &atlas.mOpaqueKey;
}
+ ~Entry() {
+ delete texture;
+ }
+
private:
/**
* The pixel ref that generated this atlas entry.
@@ -90,10 +92,6 @@
, atlas(atlas) {
}
- ~Entry() {
- delete texture;
- }
-
friend class AssetAtlas;
};
@@ -127,7 +125,7 @@
* Can return 0 if the atlas is not initialized.
*/
uint32_t getWidth() const {
- return mTexture ? mTexture->width : 0;
+ return mTexture ? mTexture->width() : 0;
}
/**
@@ -135,7 +133,7 @@
* Can return 0 if the atlas is not initialized.
*/
uint32_t getHeight() const {
- return mTexture ? mTexture->height : 0;
+ return mTexture ? mTexture->height() : 0;
}
/**
@@ -143,7 +141,7 @@
* Can return 0 if the atlas is not initialized.
*/
GLuint getTexture() const {
- return mTexture ? mTexture->id : 0;
+ return mTexture ? mTexture->id() : 0;
}
/**
@@ -160,7 +158,6 @@
private:
void createEntries(Caches& caches, int64_t* map, int count);
- void updateTextureId();
Texture* mTexture;
Image* mImage;
@@ -168,7 +165,7 @@
const bool mBlendKey;
const bool mOpaqueKey;
- KeyedVector<const SkPixelRef*, Entry*> mEntries;
+ std::unordered_map<const SkPixelRef*, std::unique_ptr<Entry>> mEntries;
}; // class AssetAtlas
}; // namespace uirenderer