From: Chris Craik Date: Tue, 11 Oct 2011 21:35:51 +0000 (-0700) Subject: Fixed infinite redraw loop from running out of layer tiles X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=93bfc77abb66a95750b747cf5d782c31beadf7cf;p=android-x86%2Fexternal-webkit.git Fixed infinite redraw loop from running out of layer tiles 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 --- diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 94bf04512..827c85844 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -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(); } diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp index 8c63b4267..ce4dc7fb1 100644 --- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp +++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp @@ -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; diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index f077d48ac..38a378875 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -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", diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 154958159..b7d6aa6b7 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -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 m_tilesTextures; Vector m_availableTilesTextures; + bool m_layerTexturesRemain; Vector m_paintedSurfaces; - unsigned int m_layersMemoryUsage; - int m_maxTextureCount; bool m_generatorReady;