diff options
author | Chris Craik <ccraik@google.com> | 2011-12-02 11:48:43 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2011-12-02 12:39:54 -0800 |
commit | d428cef6d334156cb4178476d2c36d115d91d4a4 (patch) | |
tree | cff14d9d474e99f2a73c66a0db9a9fcdd5f9a062 /Source/WebCore | |
parent | 243f1a9f7a19e951afa11a656b273cd4da03ef38 (diff) | |
download | external_webkit-d428cef6d334156cb4178476d2c36d115d91d4a4.zip external_webkit-d428cef6d334156cb4178476d2c36d115d91d4a4.tar.gz external_webkit-d428cef6d334156cb4178476d2c36d115d91d4a4.tar.bz2 |
clip tile prepare bounds to content OR viewport
bug:5699003
Change-Id: I4c35008f1324e0f9e83b7dd9e72e09a7e09ae7a9
Diffstat (limited to 'Source/WebCore')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TiledPage.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
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<int>(ceilf(maxWidthTiles)) - firstTileX); - nbTilesHeight = std::min(nbTilesHeight, static_cast<int>(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<int>(ceilf(maxBaseX)), + m_glWebViewState->viewportTileBounds().width()); + int maxY = std::max(static_cast<int>(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<float>(nbTilesHeight) * static_cast<float>(nbTilesWidth); |