From 4a473c7d9406a2d6f6792f0f48d933424740ec5c Mon Sep 17 00:00:00 2001 From: jiayuanr Date: Tue, 10 Jun 2014 17:41:49 +0800 Subject: Fix the texture ID reuse issue in HWUI. Issue: When the layer of previous frame is destroyed, it doesn't clear the texture id in mBoundTextures[mTextureUnit], so in the next frame, if glGenTexture returns same texture ID of the previous frame, the new texture is not bound. CRs-fixed: 671736 Change-Id: Ifc5fd2115fb1863b3c006ab14b0faabeaeb4eab4 --- libs/hwui/Caches.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libs/hwui/Caches.cpp') diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index f8d3589168b6..b0f4c2c7189d 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 /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3-59-g8ed1b