From d428cef6d334156cb4178476d2c36d115d91d4a4 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Fri, 2 Dec 2011 11:48:43 -0800 Subject: clip tile prepare bounds to content OR viewport bug:5699003 Change-Id: I4c35008f1324e0f9e83b7dd9e72e09a7e09ae7a9 --- .../platform/graphics/android/TiledPage.cpp | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'Source/WebCore') diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index 8352cce..31a0593 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -257,23 +257,27 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound firstTileY -= expandY; nbTilesHeight += expandY * 2; + } - // crop the prepared region to the contents of the base layer - float maxWidthTiles = m_glWebViewState->baseContentWidth() * m_scale / TilesManager::tileWidth(); - float maxHeightTiles = m_glWebViewState->baseContentHeight() * m_scale / TilesManager::tileHeight(); - - // adjust perimeter to not go outside base content bounds - if (firstTileX < 0) { - nbTilesWidth += firstTileX; - firstTileX = 0; - } - if (firstTileY < 0) { - nbTilesHeight += firstTileY; - firstTileY = 0; - } - nbTilesWidth = std::min(nbTilesWidth, static_cast(ceilf(maxWidthTiles)) - firstTileX); - nbTilesHeight = std::min(nbTilesHeight, static_cast(ceilf(maxHeightTiles)) - firstTileY); + // crop the tile bounds in each dimension to the larger of the base layer or viewport + float maxBaseX = m_glWebViewState->baseContentWidth() * m_scale / TilesManager::tileWidth(); + float maxBaseY = m_glWebViewState->baseContentHeight() * m_scale / TilesManager::tileHeight(); + int maxX = std::max(static_cast(ceilf(maxBaseX)), + m_glWebViewState->viewportTileBounds().width()); + int maxY = std::max(static_cast(ceilf(maxBaseY)), + m_glWebViewState->viewportTileBounds().height()); + + // adjust perimeter to not go outside cropped region + if (firstTileX < 0) { + nbTilesWidth += firstTileX; + firstTileX = 0; + } + if (firstTileY < 0) { + nbTilesHeight += firstTileY; + firstTileY = 0; } + nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX); + nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY); // check against corrupted scale values giving bad height/width (use float to avoid overflow) float numTiles = static_cast(nbTilesHeight) * static_cast(nbTilesWidth); -- cgit v1.1