diff options
author | Chris Craik <ccraik@google.com> | 2011-12-02 17:57:24 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-12-02 17:57:24 -0800 |
commit | a4ddff2196986730910345b2fb01caf261aa32d6 (patch) | |
tree | c94ff2632c8dcaa141ea2e1208f0aa6585f3e0f6 /Source/WebCore | |
parent | 6e5b690ad126b77a812d4654c56354474bfd04d4 (diff) | |
parent | d428cef6d334156cb4178476d2c36d115d91d4a4 (diff) | |
download | external_webkit-a4ddff2196986730910345b2fb01caf261aa32d6.zip external_webkit-a4ddff2196986730910345b2fb01caf261aa32d6.tar.gz external_webkit-a4ddff2196986730910345b2fb01caf261aa32d6.tar.bz2 |
am d428cef6: clip tile prepare bounds to content OR viewport
* commit 'd428cef6d334156cb4178476d2c36d115d91d4a4':
clip tile prepare bounds to content OR viewport
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); |