diff options
3 files changed, 16 insertions, 9 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index e600b04..a4953a3 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -395,8 +395,8 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale) static_cast<int>(ceilf(viewport.fRight * invTileContentWidth)), static_cast<int>(ceilf(viewport.fBottom * invTileContentHeight))); - int maxTextureCount = (m_viewportTileBounds.width() + TILE_PREFETCH_DISTANCE * 2 + 1) * - (m_viewportTileBounds.height() + TILE_PREFETCH_DISTANCE * 2 + 1) * 2; + int maxTextureCount = (m_viewportTileBounds.width() + TILE_PREFETCH_DISTANCE * 2) * + (m_viewportTileBounds.height() + TILE_PREFETCH_DISTANCE * 2) * 2; TilesManager::instance()->setMaxTextureCount(maxTextureCount); m_tiledPageA->updateBaseTileSize(); m_tiledPageB->updateBaseTileSize(); diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index 421b25f..9182af3 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -44,8 +44,10 @@ // #define MEASURES_PERF #define MAX_MEASURES_PERF 2000 -// Prefetch and render 2 tiles ahead of the scroll -#define TILE_PREFETCH_DISTANCE 0 +// Prefetch and render 1 tiles ahead of the scroll +// TODO: We should either dynamically change the outer bound by detecting the +// HW limit or save further in the GPU memory consumption. +#define TILE_PREFETCH_DISTANCE 1 // ratio of content to view required for prefetching to enable #define TILE_PREFETCH_RATIO 1.2 diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index d7c7952..57c38cf 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -58,8 +58,14 @@ #endif // DEBUG -// Number of tiles for base layer -#define MAX_TEXTURE_ALLOCATION 51 +// Important: We need at least twice as many textures as is needed to cover +// one viewport, otherwise the allocation may stall. +// We need n textures for one TiledPage, and another n textures for the +// second page used when scaling. +// In our case, we use 256*256 textures. On the tablet, this equates to +// at least 60 textures, or 112 with expanded tile boundaries. +// 112(tiles)*256*256*4(bpp)*2(pages) = 56MB +#define MAX_TEXTURE_ALLOCATION ((6+TILE_PREFETCH_DISTANCE*2)*(5+TILE_PREFETCH_DISTANCE*2)*2) #define TILE_WIDTH 256 #define TILE_HEIGHT 256 #define LAYER_TILE_WIDTH 256 @@ -322,9 +328,8 @@ void TilesManager::setMaxTextureCount(int max) { XLOG("setMaxTextureCount: %d (current: %d, total:%d)", max, m_maxTextureCount, MAX_TEXTURE_ALLOCATION); - if (m_maxTextureCount && - (max > MAX_TEXTURE_ALLOCATION || - max <= m_maxTextureCount)) + if (m_maxTextureCount == MAX_TEXTURE_ALLOCATION || + max <= m_maxTextureCount) return; android::Mutex::Autolock lock(m_texturesLock); |