diff options
author | Nicolas Roard <nicolasroard@google.com> | 2011-08-17 16:25:30 -0700 |
---|---|---|
committer | Nicolas Roard <nicolasroard@google.com> | 2011-08-17 17:36:11 -0700 |
commit | b7d8e1b710ce418ca1d8b7fc3612740757fd1aec (patch) | |
tree | 55416a00d8e6e3520e68c193c08c73fa41274311 /Source | |
parent | bd7e9ea6769039d66b97b4286e096416b53bdc4a (diff) | |
download | external_webkit-b7d8e1b710ce418ca1d8b7fc3612740757fd1aec.zip external_webkit-b7d8e1b710ce418ca1d8b7fc3612740757fd1aec.tar.gz external_webkit-b7d8e1b710ce418ca1d8b7fc3612740757fd1aec.tar.bz2 |
Reduce the tiles lookup complexity
bug:5032212
Change-Id: Id3c6ff55de995f1c6b3f9bf36e941f3f499f0bc8
Diffstat (limited to 'Source')
5 files changed, 49 insertions, 9 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 9978327..b7da291 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -554,6 +554,9 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // the BaseTiles' texture. TilesManager::instance()->transferQueue()->updateDirtyBaseTiles(); + // gather the textures we can use + TilesManager::instance()->gatherLayerTextures(); + if (compositedRoot != m_previouslyUsedRoot) TilesManager::instance()->swapLayersTextures(m_previouslyUsedRoot, compositedRoot); diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp index 064ffb9..3aac918 100644 --- a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp +++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp @@ -76,8 +76,12 @@ int PaintTileOperation::priority() if (!m_tile || m_tile->usedLevel() < 0) return -1; + // for now, use a constant value for layers, + // lower than the base layer tiles (as layers + // will always be on top of the base surface) if (m_tile->isLayerTile()) - return 25; // for now, use a constant value. + return -2; + bool goingDown = m_tile->page()->scrollingDown(); SkIRect *rect = m_tile->page()->expandedTileBounds(); diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index a8be501..0facc99 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -245,6 +245,7 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound if (!m_glWebViewState) return; + TilesManager::instance()->gatherTextures(); // update the tiles distance from the viewport updateTileState(tileBounds); m_prepare = true; diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index c634be0..3c160a2 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -109,6 +109,9 @@ TilesManager::TilesManager() { XLOG("TilesManager ctor"); m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION); + m_availableTextures.reserveCapacity(MAX_TEXTURE_ALLOCATION); + m_tilesTextures.reserveCapacity(LAYER_TILES); + m_availableTilesTextures.reserveCapacity(LAYER_TILES); m_pixmapsGenerationThread = new TexturesGenerator(); m_pixmapsGenerationThread->run("TexturesGenerator"); } @@ -212,6 +215,18 @@ void TilesManager::addPaintedSurface(PaintedSurface* surface) m_paintedSurfaces.append(surface); } +void TilesManager::gatherTextures() +{ + android::Mutex::Autolock lock(m_texturesLock); + m_availableTextures = m_textures; +} + +void TilesManager::gatherLayerTextures() +{ + android::Mutex::Autolock lock(m_texturesLock); + m_availableTilesTextures = m_tilesTextures; +} + BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) { android::Mutex::Autolock lock(m_texturesLock); @@ -221,26 +236,36 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) owner->texture()->setUsedLevel(0); XLOG("same owner (%d, %d), getAvailableTexture(%x) => texture %x", owner->x(), owner->y(), owner, owner->texture()); + if (owner->isLayerTile()) + m_availableTilesTextures.remove(m_availableTilesTextures.find(owner->texture())); + else + m_availableTextures.remove(m_availableTextures.find(owner->texture())); return owner->texture(); } if (owner->isLayerTile()) { - unsigned int max = m_tilesTextures.size(); + BaseTileTexture* layerTexture = 0; + unsigned int max = m_availableTilesTextures.size(); for (unsigned int i = 0; i < max; i++) { - BaseTileTexture* texture = m_tilesTextures[i]; + BaseTileTexture* texture = m_availableTilesTextures[i]; if (texture->owner() && texture->owner()->isRepaintPending()) continue; if (!texture->owner() && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } if (texture->usedLevel() != 0 && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } if (texture->scale() != owner->scale() && texture->acquire(owner)) { - return texture; + layerTexture = texture; + break; } } - return 0; + if (layerTexture) + m_availableTilesTextures.remove(m_availableTilesTextures.find(layerTexture)); + return layerTexture; } // The heuristic for selecting a texture is as follows: @@ -251,9 +276,9 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) BaseTileTexture* farthestTexture = 0; int farthestTextureLevel = 0; unsigned int lowestDrawCount = ~0; //maximum uint - const unsigned int max = m_textures.size(); + const unsigned int max = m_availableTextures.size(); for (unsigned int i = 0; i < max; i++) { - BaseTileTexture* texture = m_textures[i]; + BaseTileTexture* texture = m_availableTextures[i]; if (texture->usedLevel() == -1) { // found an unused texture, grab it farthestTexture = texture; @@ -276,6 +301,7 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner) XLOG("farthest texture, getAvailableTexture(%x) => texture %x (level %d, drawCount %d)", owner, farthestTexture, farthestTextureLevel, lowestDrawCount); farthestTexture->setUsedLevel(0); + m_availableTextures.remove(m_availableTextures.find(farthestTexture)); return farthestTexture; } diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 8f0ac7f..e9f1571 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -83,6 +83,8 @@ public: TransferQueue* transferQueue() { return &m_queue; } VideoLayerManager* videoLayerManager() { return &m_videoLayerManager; } + void gatherLayerTextures(); + void gatherTextures(); BaseTileTexture* getAvailableTexture(BaseTile* owner); void markGeneratorAsReady() @@ -169,7 +171,11 @@ private: } Vector<BaseTileTexture*> m_textures; + Vector<BaseTileTexture*> m_availableTextures; + Vector<BaseTileTexture*> m_tilesTextures; + Vector<BaseTileTexture*> m_availableTilesTextures; + Vector<PaintedSurface*> m_paintedSurfaces; unsigned int m_layersMemoryUsage; |