Remove unnecessary return and add bitmap generation ID tracking.
Change-Id: Icf5e0635e789f5ea53268c22fad51cf733b5b1a6
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