diff options
Diffstat (limited to 'Source/WebCore/platform/graphics/android/TiledPage.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TiledPage.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index 3c262d4..e33d39a 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -68,6 +68,7 @@ TiledPage::TiledPage(int id, GLWebViewState* state) , m_latestPictureInval(0) , m_prepare(false) , m_isPrefetchPage(false) + , m_willDraw(false) { m_baseTiles = new BaseTile[TilesManager::getMaxTextureAllocation() + 1]; #ifdef DEBUG_COUNT @@ -271,11 +272,6 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound lastTileX = std::min(lastTileX, static_cast<int>(ceilf(maxWidthTiles)) - 1); lastTileY = std::min(lastTileY, static_cast<int>(ceilf(maxHeightTiles)) - 1); - m_expandedTileBounds.fLeft = firstTileX; - m_expandedTileBounds.fTop = firstTileY; - m_expandedTileBounds.fRight = lastTileX; - m_expandedTileBounds.fBottom = lastTileY; - // check against corrupted scale values giving bad height/width (use float to avoid overflow) float numTiles = static_cast<float>(nbTilesHeight) * static_cast<float>(nbTilesWidth); if (numTiles > TilesManager::getMaxTextureAllocation() || nbTilesHeight < 1 || nbTilesWidth < 1) @@ -303,7 +299,22 @@ bool TiledPage::hasMissingContent(const SkIRect& tileBounds) return neededTiles > 0; } -bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale, SwapMethod swap) +bool TiledPage::isReady(const SkIRect& tileBounds) +{ + int neededTiles = tileBounds.width() * tileBounds.height(); + XLOG("tiled page %p needs %d ready tiles", this, neededTiles); + for (int j = 0; j < m_baseTileSize; j++) { + BaseTile& tile = m_baseTiles[j]; + if (tileBounds.contains(tile.x(), tile.y())) { + if (tile.isTileReady()) + neededTiles--; + } + } + XLOG("tiled page %p still needs %d ready tiles", this, neededTiles); + return neededTiles == 0; +} + +bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale) { if (!m_glWebViewState) return false; @@ -316,21 +327,11 @@ bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale, SwapM int swaps = 0; bool fullSwap = true; - if (swap == SwapWholePage) { - for (int x = tileBounds.fLeft; x < tileBounds.fRight; x++) { - for (int y = tileBounds.fTop; y < tileBounds.fBottom; y++) { - BaseTile* t = getBaseTile(x, y); - if (!t || !t->isTileReady()) - return false; - } - } - } else { // SwapWhateveryIsReady - for (int x = tileBounds.fLeft; x < tileBounds.fRight; x++) { - for (int y = tileBounds.fTop; y < tileBounds.fBottom; y++) { - BaseTile* t = getBaseTile(x, y); - if (!t || !t->isTileReady()) - fullSwap = false; - } + for (int x = tileBounds.fLeft; x < tileBounds.fRight; x++) { + for (int y = tileBounds.fTop; y < tileBounds.fBottom; y++) { + BaseTile* t = getBaseTile(x, y); + if (!t || !t->isTileReady()) + fullSwap = false; } } @@ -341,15 +342,20 @@ bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale, SwapM swaps++; } - XLOG("%p %s swapped %d textures, returning true", - this, (swap == SwapWholePage) ? "whole page" : "greedy swap", swaps); + XLOG("%p greedy swapped %d textures, returning true", this, swaps); return fullSwap; } +void TiledPage::prepareForDrawGL(float transparency, const SkIRect& tileBounds) +{ + m_willDraw = true; + m_transparency = transparency; + m_tileBounds = tileBounds; +} -void TiledPage::draw(float transparency, const SkIRect& tileBounds) +void TiledPage::drawGL() { - if (!m_glWebViewState) + if (!m_glWebViewState || m_transparency == 0 || !m_willDraw) return; const float tileWidth = TilesManager::tileWidth() * m_invScale; @@ -357,7 +363,7 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) for (int j = 0; j < m_baseTileSize; j++) { BaseTile& tile = m_baseTiles[j]; - bool tileInView = tileBounds.contains(tile.x(), tile.y()); + bool tileInView = m_tileBounds.contains(tile.x(), tile.y()); if (tileInView) { SkRect rect; rect.fLeft = tile.x() * tileWidth; @@ -365,11 +371,12 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) rect.fRight = rect.fLeft + tileWidth; rect.fBottom = rect.fTop + tileHeight; - tile.draw(transparency, rect, m_scale); + tile.draw(m_transparency, rect, m_scale); } TilesManager::instance()->getProfiler()->nextTile(tile, m_invScale, tileInView); } + m_willDraw = false; // don't redraw until re-prepared } bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) |