nextTiledPage->setScale(scale);
m_glWebViewState->setFutureViewport(viewportTileBounds);
m_glWebViewState->lockBaseLayerUpdate();
- nextTiledPage->updateTileState(viewportTileBounds);
+
+ // ignore dirtiness return value since while zooming we repaint regardless
+ nextTiledPage->updateTileDirtiness(viewportTileBounds);
+
nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds,
TiledPage::VisibleBounds);
// Cancel pending paints for the foreground page
*buffersSwappedPtr = true;
}
- // If stuff is happening such that we need a redraw, lock updates to the
- // base layer, and only then start painting.
+
bool needsRedraw = scrolling || zooming || !buffersSwapped;
- if (needsRedraw)
- m_glWebViewState->lockBaseLayerUpdate();
- else
+
+ // if we don't expect to redraw, unlock the invals
+ if (!needsRedraw)
m_glWebViewState->unlockBaseLayerUpdate();
- XLOG("scrolling %d, zooming %d, buffersSwapped %d, needsRedraw %d",
- scrolling, zooming, buffersSwapped, needsRedraw);
+ // if applied invals mark tiles dirty, need to redraw
+ needsRedraw |= tiledPage->updateTileDirtiness(preZoomBounds);
- tiledPage->updateTileState(preZoomBounds);
+ if (needsRedraw) {
+ // lock and paint what's needed unless we're zooming, since the new
+ // tiles won't be relevant soon anyway
+ m_glWebViewState->lockBaseLayerUpdate();
+ if (!zooming)
+ tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
+ TiledPage::ExpandedBounds);
+ }
- // Only paint new textures if the base layer has been locked, but not if
- // we're zooming since the new tiles won't be relevant soon anyway
- if (needsRedraw && !zooming)
- tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
- TiledPage::ExpandedBounds);
+ XLOG("scrolling %d, zooming %d, buffersSwapped %d, needsRedraw %d",
+ scrolling, zooming, buffersSwapped, needsRedraw);
tiledPage->draw(transparency, preZoomBounds);
#include <cutils/atomic.h>
-#ifdef DEBUG
-
#include <cutils/log.h>
#include <wtf/CurrentTime.h>
#include <wtf/text/CString.h>
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "BaseTile", __VA_ARGS__)
+
+#ifdef DEBUG
+
#undef XLOG
#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "BaseTile", __VA_ARGS__)
if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
m_dirty = true;
+ XLOG("painted tile %p (%d, %d), dirty=%d", this, x, y, m_dirty);
+
if (!m_dirty)
m_isSwapNeeded = true;
}
}
}
-void TiledPage::updateTileState(const SkIRect& tileBounds)
+bool TiledPage::updateTileDirtiness(const SkIRect& tileBounds)
{
if (!m_glWebViewState || tileBounds.isEmpty()) {
m_invalRegion.setEmpty();
m_invalTilesRegion.setEmpty();
- return;
+ return false;
}
+ bool visibleTileIsDirty = false;
for (int x = 0; x < m_baseTileSize; x++) {
BaseTile& tile = m_baseTiles[x];
// if the tile is in the dirty region then we must invalidate it
- if (m_invalRegion.contains(tile.x(), tile.y()))
+ if (m_invalRegion.contains(tile.x(), tile.y())) {
tile.markAsDirty(m_latestPictureInval, m_invalTilesRegion);
+ if (tileBounds.contains(tile.x(), tile.y()))
+ visibleTileIsDirty = true;
+ }
}
// clear the invalidated region as all tiles within that region have now
// been marked as dirty.
m_invalRegion.setEmpty();
m_invalTilesRegion.setEmpty();
+ return visibleTileIsDirty;
}
void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds)
return;
TilesManager::instance()->gatherTextures();
- // update the tiles distance from the viewport
- updateTileState(tileBounds);
m_scrollingDown = goingDown;
int firstTileX = tileBounds.fLeft;