From ab3df5899158b0bcb5c7bb6858d9717a22781ad3 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 8 Sep 2011 14:09:43 -0700 Subject: [PATCH] Stop layer tile flickering bug:5265207 Don't steal textures with a draw count from last frame to prevent flickering Change-Id: I0a37b2417f0721b150b47920feea9ddb1666ec28 --- .../platform/graphics/android/TilesManager.cpp | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 2c263e396..8b6566a77 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -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!!!", -- 2.11.0