OSDN Git Service

Fixed infinite redraw loop from running out of layer tiles
authorChris Craik <ccraik@google.com>
Tue, 11 Oct 2011 21:35:51 +0000 (14:35 -0700)
committerChris Craik <ccraik@google.com>
Tue, 11 Oct 2011 22:41:34 +0000 (15:41 -0700)
bug:5349958

Clear a flag when a layer tile can't allocate a texture, and only try and redraw
from tile dirtiness if that flag is set.

Also, don't ask for redraw if offending tiles are offscreen.

Change-Id: Iadb0cb267a9c1f308e5b42a6e0e3b4bc71d18ece

Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
Source/WebCore/platform/graphics/android/TiledTexture.cpp
Source/WebCore/platform/graphics/android/TilesManager.cpp
Source/WebCore/platform/graphics/android/TilesManager.h

index 94bf045..827c858 100644 (file)
@@ -337,9 +337,13 @@ bool BaseLayerAndroid::drawGL(double currentTime, LayerAndroid* compositedRoot,
         TilesManager::instance()->videoLayerManager()->deleteUnusedTextures();
 
         compositedRoot->prepare(m_glWebViewState);
-        if (compositedRoot->drawGL(m_glWebViewState, matrix))
-            needsRedraw = true;
-        else if (!animsRunning)
+        if (compositedRoot->drawGL(m_glWebViewState, matrix)) {
+            if (TilesManager::instance()->layerTexturesRemain()) {
+                // only try redrawing for layers if layer textures remain,
+                // otherwise we'll repaint without getting anything done
+                needsRedraw = true;
+            }
+        } else if (!animsRunning)
             m_glWebViewState->resetLayersDirtyArea();
 
     }
index 8c63b42..ce4dc7f 100644 (file)
@@ -219,8 +219,8 @@ bool TiledTexture::draw()
     for (unsigned int i = 0; i < m_tiles.size(); i++) {
         BaseTile* tile = m_tiles[i];
 
-        askRedraw |= !tile->isTileReady();
         if (tile->isTileVisible(m_area)) {
+            askRedraw |= !tile->isTileReady();
             SkRect rect;
             rect.fLeft = tile->x() * tileWidth;
             rect.fTop = tile->y() * tileHeight;
index f077d48..38a3788 100644 (file)
@@ -93,7 +93,7 @@ int TilesManager::getMaxTextureAllocation()
 }
 
 TilesManager::TilesManager()
-    : m_layersMemoryUsage(0)
+    : m_layerTexturesRemain(true)
     , m_maxTextureCount(0)
     , m_generatorReady(false)
     , m_showVisualIndicator(false)
@@ -237,6 +237,7 @@ void TilesManager::gatherLayerTextures()
 {
     android::Mutex::Autolock lock(m_texturesLock);
     m_availableTilesTextures = m_tilesTextures;
+    m_layerTexturesRemain = true;
 }
 
 BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
@@ -326,6 +327,13 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
             availableTexturePool->remove(availableTexturePool->find(farthestTexture));
             return farthestTexture;
         }
+    } else {
+        if (owner->isLayerTile()) {
+            // couldn't find a tile for a layer, layers shouldn't request redraw
+            // TODO: once we do layer prefetching, don't set this for those
+            // tiles
+            m_layerTexturesRemain = false;
+        }
     }
 
     XLOG("Couldn't find an available texture for %s tile %x (%d, %d) out of %d available",
index 1549581..b7d6aa6 100644 (file)
@@ -87,6 +87,8 @@ public:
 
     void gatherLayerTextures();
     void gatherTextures();
+    bool layerTexturesRemain() { return m_layerTexturesRemain; }
+
     BaseTileTexture* getAvailableTexture(BaseTile* owner);
 
     void markGeneratorAsReady()
@@ -197,11 +199,10 @@ private:
 
     Vector<BaseTileTexture*> m_tilesTextures;
     Vector<BaseTileTexture*> m_availableTilesTextures;
+    bool m_layerTexturesRemain;
 
     Vector<PaintedSurface*> m_paintedSurfaces;
 
-    unsigned int m_layersMemoryUsage;
-
     int m_maxTextureCount;
 
     bool m_generatorReady;