OSDN Git Service

Stop layer tile flickering
authorChris Craik <ccraik@google.com>
Thu, 8 Sep 2011 21:09:43 +0000 (14:09 -0700)
committerChris Craik <ccraik@google.com>
Thu, 8 Sep 2011 21:28:12 +0000 (14:28 -0700)
bug:5265207
Don't steal textures with a draw count from last frame to prevent flickering

Change-Id: I0a37b2417f0721b150b47920feea9ddb1666ec28

Source/WebCore/platform/graphics/android/TilesManager.cpp

index 2c263e3..8b6566a 100644 (file)
@@ -235,10 +235,11 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
     //  1. If a tile isn't owned, break with that one
     //  2. If we find a tile in the same page with a different scale,
     //         it's old and not visible. Break with that one
-    //  3. Otherwise, use the least recently prepared tile
+    //  3. Otherwise, use the least recently prepared tile, but ignoring tiles
+    //         drawn in the last frame to avoid flickering
 
     BaseTileTexture* farthestTexture = 0;
-    unsigned long long oldestDrawCount = ~0; //maximum u64
+    unsigned long long oldestDrawCount = getDrawGLCount() - 1;
     const unsigned int max = availableTexturePool->size();
     for (unsigned int i = 0; i < max; i++) {
         BaseTileTexture* texture = (*availableTexturePool)[i];
@@ -263,16 +264,18 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
         }
     }
 
-    TextureOwner* previousOwner = farthestTexture->owner();
-    if (farthestTexture && farthestTexture->acquire(owner)) {
-        if (previousOwner) {
-            XLOG("%s texture %p stolen from tile %d, %d, drawCount was %llu",
-                 owner->isLayerTile() ? "LAYER" : "BASE",
-                 farthestTexture, owner->x(), owner->y(), oldestDrawCount);
+    if (farthestTexture) {
+        TextureOwner* previousOwner = farthestTexture->owner();
+        if (farthestTexture->acquire(owner)) {
+            if (previousOwner) {
+                XLOG("%s texture %p stolen from tile %d, %d, drawCount was %llu",
+                     owner->isLayerTile() ? "LAYER" : "BASE",
+                     farthestTexture, owner->x(), owner->y(), oldestDrawCount);
+            }
+
+            availableTexturePool->remove(availableTexturePool->find(farthestTexture));
+            return farthestTexture;
         }
-
-        availableTexturePool->remove(availableTexturePool->find(farthestTexture));
-        return farthestTexture;
     }
 
     XLOG("Couldn't find an available texture for tile %x (%d, %d) out of %d available!!!",