OSDN Git Service

Fix attempted uploading of recycled tiles
authorBobby Georgescu <georgescu@google.com>
Wed, 24 Oct 2012 21:15:38 +0000 (14:15 -0700)
committerBobby Georgescu <georgescu@google.com>
Wed, 24 Oct 2012 21:15:38 +0000 (14:15 -0700)
Bug: 7405398
Change-Id: I17711f9c724af216aa22cee6a86d9feba84c1548

src/com/android/gallery3d/ui/TiledTexture.java

index 8598a3f..2c685bd 100644 (file)
@@ -164,14 +164,19 @@ public class TiledTexture implements Texture {
         if (mUploadIndex == mTiles.length) return true;
 
         Tile next = mTiles[mUploadIndex++];
-        boolean hasBeenLoad = next.isLoaded();
-        next.updateContent(canvas);
-
-        // It will take some time for a texture to be drawn for the first
-        // time. When scrolling, we need to draw several tiles on the screen
-        // at the same time. It may cause a UI jank even these textures has
-        // been uploaded.
-        if (!hasBeenLoad) next.draw(canvas, 0, 0);
+
+        // Make sure tile has not already been recycled by the time
+        // this is called (race condition in onGLIdle)
+        if (next.bitmap != null) {
+            boolean hasBeenLoad = next.isLoaded();
+            next.updateContent(canvas);
+
+            // It will take some time for a texture to be drawn for the first
+            // time. When scrolling, we need to draw several tiles on the screen
+            // at the same time. It may cause a UI jank even these textures has
+            // been uploaded.
+            if (!hasBeenLoad) next.draw(canvas, 0, 0);
+        }
         return mUploadIndex == mTiles.length;
     }