OSDN Git Service

Fix the texture ID reuse issue in HWUI.
authorjiayuanr <jiayuanr@codeaurora.org>
Tue, 10 Jun 2014 09:41:49 +0000 (17:41 +0800)
committerDigish Pandya <digishp@codeaurora.org>
Mon, 16 Jun 2014 03:59:22 +0000 (09:29 +0530)
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
libs/hwui/Caches.h
libs/hwui/Layer.cpp

index f8d3589..b0f4c2c 100644 (file)
@@ -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
 ///////////////////////////////////////////////////////////////////////////////
index 282aee9..544757a 100644 (file)
@@ -264,6 +264,11 @@ public:
     void resetBoundTextures();
 
     /**
+     * Clear the cache of bound textures.
+     */
+    void unbindTexture(GLuint texture);
+
+    /**
      * Sets the scissor for the current surface.
      */
     bool setScissor(GLint x, GLint y, GLint width, GLint height);
index bd371a3..987bf03 100644 (file)
@@ -171,6 +171,7 @@ void Layer::deleteTexture() {
 }
 
 void Layer::clearTexture() {
+    caches.unbindTexture(texture.id);
     texture.id = 0;
 }