summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp18
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h12
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp34
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp24
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h8
-rw-r--r--Source/WebKit/android/nav/WebView.cpp7
6 files changed, 42 insertions, 61 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index b7da291..c54977d 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -83,6 +83,8 @@ GLWebViewState::GLWebViewState(android::Mutex* buttonMutex)
, m_focusRingTexture(-1)
, m_goingDown(true)
, m_goingLeft(false)
+ , m_expandedTileBoundsX(0)
+ , m_expandedTileBoundsY(0)
{
m_viewport.setEmpty();
m_previousViewport.setEmpty();
@@ -426,12 +428,11 @@ void GLWebViewState::swapPages()
int GLWebViewState::baseContentWidth()
{
- return m_currentBaseLayer ? m_currentBaseLayer->getWidth() : 0;
-
+ return m_currentBaseLayer ? m_currentBaseLayer->content()->width() : 0;
}
int GLWebViewState::baseContentHeight()
{
- return m_currentBaseLayer ? m_currentBaseLayer->getHeight() : 0;
+ return m_currentBaseLayer ? m_currentBaseLayer->content()->height() : 0;
}
void GLWebViewState::setViewport(SkRect& viewport, float scale)
@@ -455,8 +456,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() + TilesManager::instance()->expandedTileBoundsX() * 2 + 1) *
- (m_viewportTileBounds.height() + TilesManager::instance()->expandedTileBoundsY() * 2 + 1) * 2;
+ int maxTextureCount = (m_viewportTileBounds.width() + TILE_PREFETCH_DISTANCE * 2 + 1) *
+ (m_viewportTileBounds.height() + TILE_PREFETCH_DISTANCE * 2 + 1) * 2;
TilesManager::instance()->setMaxTextureCount(maxTextureCount);
m_tiledPageA->updateBaseTileSize();
m_tiledPageB->updateBaseTileSize();
@@ -532,6 +533,13 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
return false;
}
+ float viewWidth = (viewport.fRight - viewport.fLeft) * TILE_PREFETCH_RATIO;
+ float viewHeight = (viewport.fBottom - viewport.fTop) * TILE_PREFETCH_RATIO;
+ bool useHorzPrefetch = viewWidth < baseContentWidth();
+ bool useVertPrefetch = viewHeight < baseContentHeight();
+ m_expandedTileBoundsX = (useHorzPrefetch) ? TILE_PREFETCH_DISTANCE : 0;
+ m_expandedTileBoundsY = (useVertPrefetch) ? TILE_PREFETCH_DISTANCE : 0;
+
XLOG("drawGL, rect(%d, %d, %d, %d), viewport(%.2f, %.2f, %.2f, %.2f)",
rect.x(), rect.y(), rect.width(), rect.height(),
viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom);
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 82b6f12..f3cbf74 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -42,6 +42,12 @@
// #define MEASURES_PERF
#define MAX_MEASURES_PERF 2000
+// Prefetch and render 2 tiles ahead of the scroll
+#define TILE_PREFETCH_DISTANCE 2
+
+// ratio of content to view required for prefetching to enable
+#define TILE_PREFETCH_RATIO 1.2
+
namespace WebCore {
class BaseLayerAndroid;
@@ -248,6 +254,9 @@ public:
m_goingLeft = goingLeft;
}
+ int expandedTileBoundsX() { return m_expandedTileBoundsX; }
+ int expandedTileBoundsY() { return m_expandedTileBoundsY; }
+
private:
void inval(const IntRect& rect); // caller must hold m_baseLayerLock
void invalRegion(const SkRegion& region);
@@ -308,6 +317,9 @@ private:
bool m_goingDown;
bool m_goingLeft;
+
+ int m_expandedTileBoundsX;
+ int m_expandedTileBoundsY;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
index 0facc99..a69f9d1 100644
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp
@@ -259,25 +259,21 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
int lastTileX = tileBounds.fRight - 1;
int lastTileY = tileBounds.fBottom - 1;
- const int baseContentHeight = m_glWebViewState->baseContentHeight();
- const int baseContentWidth = m_glWebViewState->baseContentWidth();
-
// Expand number of tiles to allow tiles outside of viewport to be prepared for
// smoother scrolling.
int nTilesToPrepare = nbTilesWidth * nbTilesHeight;
int nMaxTilesPerPage = m_baseTileSize / 2;
- int expandX = TilesManager::instance()->expandedTileBoundsX();
- int expandY = TilesManager::instance()->expandedTileBoundsY();
- if (nTilesToPrepare + (nbTilesHeight * expandX * 2) <= nMaxTilesPerPage) {
- firstTileX -= expandX;
- lastTileX += expandX;
- nbTilesWidth += expandX * 2;
- }
- if (nTilesToPrepare + (nbTilesWidth * expandY * 2) <= nMaxTilesPerPage) {
- firstTileY -= expandY;
- lastTileY += expandY;
- nbTilesHeight += expandY * 2;
- }
+ int expandX = m_glWebViewState->expandedTileBoundsX();
+ int expandY = m_glWebViewState->expandedTileBoundsY();
+
+ firstTileX -= expandX;
+ lastTileX += expandX;
+ nbTilesWidth += expandX * 2;
+
+ firstTileY -= expandY;
+ lastTileY += expandY;
+ nbTilesHeight += expandY * 2;
+
m_expandedTileBounds.fLeft = firstTileX;
m_expandedTileBounds.fTop = firstTileY;
m_expandedTileBounds.fRight = lastTileX;
@@ -318,10 +314,10 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds)
const float tileHeight = TilesManager::tileHeight() * m_invScale;
SkIRect actualTileBounds = tileBounds;
- actualTileBounds.fTop -= TilesManager::instance()->expandedTileBoundsY();
- actualTileBounds.fBottom += TilesManager::instance()->expandedTileBoundsY();
- actualTileBounds.fLeft -= TilesManager::instance()->expandedTileBoundsX();
- actualTileBounds.fRight += TilesManager::instance()->expandedTileBoundsX();
+ actualTileBounds.fTop -= m_glWebViewState->expandedTileBoundsY();
+ actualTileBounds.fBottom += m_glWebViewState->expandedTileBoundsY();
+ actualTileBounds.fLeft -= m_glWebViewState->expandedTileBoundsX();
+ actualTileBounds.fRight += m_glWebViewState->expandedTileBoundsX();
for (int j = 0; j < m_baseTileSize; j++) {
BaseTile& tile = m_baseTiles[j];
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 3c160a2..6e1ce31 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -58,19 +58,8 @@
#endif // DEBUG
-// Important: We need at least twice as much 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 300x300 textures. On the tablet, this equates to
-// at least 24 textures. That is consuming almost 50MB GPU memory.
-// 24*300*300*4(bpp)*2(pages)*3(triple buffering in Surface Texture) = 49.4MB
-// In order to avoid OOM issue, we limit the bounds number to 0 for now.
-// TODO: We should either dynamically change the outer bound by detecting the
-// HW limit or save further in the GPU memory consumption.
-#define EXPANDED_TILE_BOUNDS_X 0
-#define EXPANDED_TILE_BOUNDS_Y 0
-#define MAX_TEXTURE_ALLOCATION 3+(6+EXPANDED_TILE_BOUNDS_X*2)*(4+EXPANDED_TILE_BOUNDS_Y*2)*2
+// Number of tiles for base layer
+#define MAX_TEXTURE_ALLOCATION 51
#define TILE_WIDTH 256
#define TILE_HEIGHT 256
#define LAYER_TILE_WIDTH 256
@@ -101,7 +90,6 @@ int TilesManager::getMaxTextureAllocation()
TilesManager::TilesManager()
: m_layersMemoryUsage(0)
, m_maxTextureCount(0)
- , m_expandedTileBounds(false)
, m_generatorReady(false)
, m_showVisualIndicator(false)
, m_invertedScreen(false)
@@ -368,14 +356,6 @@ float TilesManager::layerTileHeight()
return LAYER_TILE_HEIGHT;
}
-int TilesManager::expandedTileBoundsX() {
- return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_X : 0;
-}
-
-int TilesManager::expandedTileBoundsY() {
- return m_expandedTileBounds ? EXPANDED_TILE_BOUNDS_Y : 0;
-}
-
void TilesManager::registerGLWebViewState(GLWebViewState* state)
{
m_glWebViewStateMap.set(state, m_drawRegistrationCount);
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index e9f1571..471bece 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -108,18 +108,11 @@ public:
static float tileHeight();
static float layerTileWidth();
static float layerTileHeight();
- int expandedTileBoundsX();
- int expandedTileBoundsY();
void registerGLWebViewState(GLWebViewState* state);
void unregisterGLWebViewState(GLWebViewState* state);
void allocateTiles();
- void setExpandedTileBounds(bool enabled)
- {
- m_expandedTileBounds = enabled;
- }
-
bool getShowVisualIndicator()
{
return m_showVisualIndicator;
@@ -181,7 +174,6 @@ private:
unsigned int m_layersMemoryUsage;
int m_maxTextureCount;
- bool m_expandedTileBounds;
bool m_generatorReady;
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index c1cb95c..95c560d 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -2608,11 +2608,6 @@ static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint layerId, jint x,
return false;
}
-static void nativeSetExpandedTileBounds(JNIEnv*, jobject, jboolean enabled)
-{
- TilesManager::instance()->setExpandedTileBounds(enabled);
-}
-
static void nativeUseHardwareAccelSkia(JNIEnv*, jobject, jboolean enabled)
{
BaseRenderer::setCurrentRendererType(enabled ? BaseRenderer::Ganesh : BaseRenderer::Raster);
@@ -2827,8 +2822,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeScrollableLayer },
{ "nativeScrollLayer", "(III)Z",
(void*) nativeScrollLayer },
- { "nativeSetExpandedTileBounds", "(Z)V",
- (void*) nativeSetExpandedTileBounds },
{ "nativeUseHardwareAccelSkia", "(Z)V",
(void*) nativeUseHardwareAccelSkia },
{ "nativeGetBackgroundColor", "()I",