diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index f8d3589168b6b..b0f4c2c7189d7 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -554,11 +554,8 @@ void Caches::deleteTexture(GLuint texture) { // call, any texture operation will be performed on the default // texture (name=0) - for (int i = 0; i < REQUIRED_TEXTURE_UNITS_COUNT; i++) { - if (mBoundTextures[i] == texture) { - mBoundTextures[i] = 0; - } - } + unbindTexture(texture); + glDeleteTextures(1, &texture); } @@ -566,6 +563,14 @@ void Caches::resetBoundTextures() { memset(mBoundTextures, 0, REQUIRED_TEXTURE_UNITS_COUNT * sizeof(GLuint)); } +void Caches::unbindTexture(GLuint texture) { + for (int i = 0; i < REQUIRED_TEXTURE_UNITS_COUNT; i++) { + if (mBoundTextures[i] == texture) { + mBoundTextures[i] = 0; + } + } +} + /////////////////////////////////////////////////////////////////////////////// // Scissor /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 282aee901006e..544757aac6962 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -263,6 +263,11 @@ public: */ void resetBoundTextures(); + /** + * Clear the cache of bound textures. + */ + void unbindTexture(GLuint texture); + /** * Sets the scissor for the current surface. */ diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index bd371a3bcef42..987bf03bb863a 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -171,6 +171,7 @@ void Layer::deleteTexture() { } void Layer::clearTexture() { + caches.unbindTexture(texture.id); texture.id = 0; }