OSDN Git Service

Re-enable tile prefetching, correct and adjust max tile allocation logic
authorChris Craik <ccraik@google.com>
Mon, 22 Aug 2011 22:49:32 +0000 (15:49 -0700)
committerChris Craik <ccraik@google.com>
Mon, 22 Aug 2011 22:49:32 +0000 (15:49 -0700)
bug:5168261
Change-Id: I37ec223da4ac1555cd925b08f105f9ed571cb2d9

Source/WebCore/platform/graphics/android/GLWebViewState.cpp
Source/WebCore/platform/graphics/android/GLWebViewState.h
Source/WebCore/platform/graphics/android/TilesManager.cpp

index e600b04..a4953a3 100644 (file)
@@ -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();
index 421b25f..9182af3 100644 (file)
 // #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
index d7c7952..57c38cf 100644 (file)
 
 #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);