summaryrefslogtreecommitdiff
path: root/libs/hwui/Texture.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/Texture.h')
-rw-r--r--libs/hwui/Texture.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index d37013d683ba..90f548b5621d 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -26,6 +26,10 @@ namespace uirenderer {
* Represents an OpenGL texture.
*/
struct Texture {
+ Texture() {
+ cleanup = false;
+ }
+
/**
* Name of the texture.
*/
@@ -46,8 +50,26 @@ struct Texture {
* Height of the backing bitmap.
*/
uint32_t height;
+ /**
+ * Indicates whether this texture should be cleaned up after use.
+ */
+ bool cleanup;
}; // struct Texture
+class AutoTexture {
+public:
+ AutoTexture(const Texture* texture): mTexture(texture) { }
+ ~AutoTexture() {
+ if (mTexture && mTexture->cleanup) {
+ glDeleteTextures(1, &mTexture->id);
+ delete mTexture;
+ }
+ }
+
+private:
+ const Texture* mTexture;
+}; // class AutoTexture
+
}; // namespace uirenderer
}; // namespace android