Remove unnecessary return and add bitmap generation ID tracking.
Change-Id: Icf5e0635e789f5ea53268c22fad51cf733b5b1a6
diff --git a/libs/hwui/Texture.h b/libs/hwui/Texture.h
index b3b17ca..6802c59 100644
--- a/libs/hwui/Texture.h
+++ b/libs/hwui/Texture.h
@@ -31,6 +31,10 @@
*/
GLuint id;
/**
+ * Generation of the backing bitmap,
+ */
+ uint32_t generation;
+ /**
* Indicates whether the texture requires blending.
*/
bool blend;
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index fd12a3c..c3b1463 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -43,6 +43,8 @@
texture = new Texture;
generateTexture(bitmap, texture);
mCache.put(bitmap, texture);
+ } else if (bitmap->getGenerationID() != texture->generation) {
+ generateTexture(bitmap, texture, true);
}
return texture;
}
@@ -55,11 +57,14 @@
mCache.clear();
}
-void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture) {
- texture->width = bitmap->width();
- texture->height = bitmap->height();
+void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) {
+ if (!regenerate) {
+ texture->width = bitmap->width();
+ texture->height = bitmap->height();
- glGenTextures(1, &texture->id);
+ glGenTextures(1, &texture->id);
+ }
+
glBindTexture(GL_TEXTURE_2D, texture->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -80,7 +85,7 @@
break;
}
- return texture;
+ glBindTexture(GL_TEXTURE_2D, 0);
}
}; // namespace uirenderer
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index 7f95366..bf68061 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -37,7 +37,7 @@
void clear();
private:
- void generateTexture(SkBitmap* bitmap, Texture* texture);
+ void generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate = false);
GenerationCache<SkBitmap, Texture> mCache;
}; // class TextureCache