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();
// #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
#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
{
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);