diff options
Diffstat (limited to 'Source/WebCore')
4 files changed, 33 insertions, 23 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index a8c4d7a..2902b5c 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -124,7 +124,7 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas) #if USE(ACCELERATED_COMPOSITING) void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale, - TiledPage* prefetchTiledPage) + TiledPage* prefetchTiledPage, bool draw) { SkIRect bounds; float prefetchScale = currentScale * PREFETCH_SCALE_MODIFIER; @@ -162,7 +162,8 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale, prefetchTiledPage->swapBuffersIfReady(bounds, prefetchScale, TiledPage::SwapWhateverIsReady); - prefetchTiledPage->draw(PREFETCH_OPACITY, bounds); + if (draw) + prefetchTiledPage->draw(PREFETCH_OPACITY, bounds); } bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, @@ -235,7 +236,7 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, // When we aren't zooming, we should TRY and swap tile buffers if they're // ready. When scrolling, we swap whatever's ready. Otherwise, buffer until // the entire page is ready and then swap. - bool buffersSwapped = false; + bool tilesFinished = false; if (!zooming) { TiledPage::SwapMethod swapMethod; if (scrolling) @@ -243,13 +244,13 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, else swapMethod = TiledPage::SwapWholePage; - buffersSwapped = tiledPage->swapBuffersIfReady(preZoomBounds, + tilesFinished = tiledPage->swapBuffersIfReady(preZoomBounds, zoomManager->currentScale(), swapMethod); - if (buffersSwappedPtr && buffersSwapped) + if (buffersSwappedPtr && tilesFinished) *buffersSwappedPtr = true; - if (buffersSwapped) { + if (tilesFinished) { if (m_scrollState == ScrollingFinishPaint) { m_scrollState = NotScrolling; scrolling = false; @@ -265,7 +266,7 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, } - bool needsRedraw = scrolling || zooming || !buffersSwapped; + bool needsRedraw = scrolling || zooming || !tilesFinished; // if we don't expect to redraw, unlock the invals if (!needsRedraw) @@ -283,15 +284,19 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, TiledPage::ExpandedBounds); } - XLOG("scrolling %d, zooming %d, buffersSwapped %d, needsRedraw %d", - scrolling, zooming, buffersSwapped, needsRedraw); + XLOG("scrolling %d, zooming %d, tilesFinished %d, needsRedraw %d", + scrolling, zooming, tilesFinished, needsRedraw); // prefetch in the nextTiledPage if unused by zooming (even if not scrolling // since we want the tiles to be ready before they're needed) bool usePrefetchPage = !zooming; nextTiledPage->setIsPrefetchPage(usePrefetchPage); - if (usePrefetchPage) - prefetchBasePicture(viewport, scale, nextTiledPage); + if (usePrefetchPage) { + // if the non-prefetch page isn't missing tiles, don't bother drawing + // prefetch page + bool drawPrefetchPage = tiledPage->hasMissingContent(preZoomBounds); + prefetchBasePicture(viewport, scale, nextTiledPage, drawPrefetchPage); + } tiledPage->draw(transparency, preZoomBounds); diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h index 26fd158..40afac8 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.h @@ -67,7 +67,7 @@ public: private: #if USE(ACCELERATED_COMPOSITING) void prefetchBasePicture(SkRect& viewport, float currentScale, - TiledPage* prefetchTiledPage); + TiledPage* prefetchTiledPage, bool draw); bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime, bool* buffersSwappedPtr); diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index b3b4daf..b28133f 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -290,6 +290,19 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound m_prepare = true; } +bool TiledPage::hasMissingContent(const SkIRect& tileBounds) +{ + int neededTiles = tileBounds.width() * tileBounds.height(); + for (int j = 0; j < m_baseTileSize; j++) { + BaseTile& tile = m_baseTiles[j]; + if (tileBounds.contains(tile.x(), tile.y())) { + if (tile.frontTexture()) + neededTiles--; + } + } + return neededTiles > 0; +} + bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale, SwapMethod swap) { if (!m_glWebViewState) @@ -342,18 +355,9 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) const float tileWidth = TilesManager::tileWidth() * m_invScale; const float tileHeight = TilesManager::tileHeight() * m_invScale; - SkIRect actualTileBounds = tileBounds; - actualTileBounds.fTop -= m_glWebViewState->expandedTileBoundsY(); - actualTileBounds.fBottom += m_glWebViewState->expandedTileBoundsY(); - actualTileBounds.fLeft -= m_glWebViewState->expandedTileBoundsX(); - actualTileBounds.fRight += m_glWebViewState->expandedTileBoundsX(); - - actualTileBounds.fTop = std::max(0, actualTileBounds.fTop); - actualTileBounds.fLeft = std::max(0, actualTileBounds.fLeft); - for (int j = 0; j < m_baseTileSize; j++) { BaseTile& tile = m_baseTiles[j]; - bool tileInView = actualTileBounds.contains(tile.x(), tile.y()); + bool tileInView = tileBounds.contains(tile.x(), tile.y()); if (tileInView) { SkRect rect; rect.fLeft = tile.x() * tileWidth; diff --git a/Source/WebCore/platform/graphics/android/TiledPage.h b/Source/WebCore/platform/graphics/android/TiledPage.h index 718908d..2d11a5a 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.h +++ b/Source/WebCore/platform/graphics/android/TiledPage.h @@ -73,7 +73,8 @@ public: // dirty (and thus repaint needed) bool updateTileDirtiness(const SkIRect& tileBounds); - // check to see if the page is ready for display + // returns true if the page can't draw the entire region (may still be stale) + bool hasMissingContent(const SkIRect& tileBounds); // swap 'buffers' by swapping each modified texture bool swapBuffersIfReady(const SkIRect& tileBounds, float scale, SwapMethod swap); |