From f7ad77dc2a981834d664fd24022c3dfade69c8aa Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 8 Mar 2012 16:09:15 -0800 Subject: Replace picture count with the SurfaceCollection count Displays surface collection count on tiles when visual indicator is on. Change-Id: Ibe90792279849baff6f5bf0d71b80d9081471dc4 --- .../platform/graphics/android/BaseLayerAndroid.cpp | 7 ++-- .../platform/graphics/android/BaseRenderer.cpp | 28 +++++++++------- .../platform/graphics/android/BaseRenderer.h | 4 +-- .../WebCore/platform/graphics/android/BaseTile.cpp | 11 ++----- .../WebCore/platform/graphics/android/BaseTile.h | 7 +--- .../platform/graphics/android/GLWebViewState.cpp | 9 ++--- .../platform/graphics/android/GLWebViewState.h | 5 +-- .../graphics/android/GraphicsLayerAndroid.cpp | 3 -- .../platform/graphics/android/ImageTexture.cpp | 2 +- .../platform/graphics/android/ImageTexture.h | 2 +- .../platform/graphics/android/LayerAndroid.cpp | 2 -- .../platform/graphics/android/LayerAndroid.h | 5 --- .../platform/graphics/android/LayerGroup.cpp | 2 +- .../WebCore/platform/graphics/android/LayerGroup.h | 2 +- .../graphics/android/SurfaceCollection.cpp | 14 +++++++- .../platform/graphics/android/TextureInfo.cpp | 1 - .../platform/graphics/android/TextureInfo.h | 2 -- .../platform/graphics/android/TilePainter.h | 8 ++++- .../platform/graphics/android/TiledPage.cpp | 38 +++++++--------------- .../WebCore/platform/graphics/android/TiledPage.h | 18 +++------- .../platform/graphics/android/TiledTexture.cpp | 2 +- .../platform/graphics/android/TilesManager.cpp | 1 + .../platform/graphics/android/TilesManager.h | 4 +++ 23 files changed, 75 insertions(+), 102 deletions(-) (limited to 'Source/WebCore/platform') diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 3cf863e..ded25a7 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -146,7 +146,7 @@ void BaseLayerAndroid::prefetchBasePicture(const SkRect& viewport, float current prefetchTiledPage); prefetchTiledPage->setScale(prefetchScale); - prefetchTiledPage->updateTileDirtiness(bounds); + prefetchTiledPage->updateTileDirtiness(); prefetchTiledPage->prepare(goingDown, goingLeft, bounds, TiledPage::ExpandedBounds); prefetchTiledPage->swapBuffersIfReady(bounds, @@ -218,8 +218,7 @@ void BaseLayerAndroid::prepareGL(const SkRect& viewport, float scale, double cur nextTiledPage->setScale(scale); m_state->setFutureViewport(viewportTileBounds); - // ignore dirtiness return value since while zooming we repaint regardless - nextTiledPage->updateTileDirtiness(viewportTileBounds); + nextTiledPage->updateTileDirtiness(); nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds, TiledPage::VisibleBounds); @@ -256,7 +255,7 @@ void BaseLayerAndroid::prepareGL(const SkRect& viewport, float scale, double cur m_state->swapPages(); } - tiledPage->updateTileDirtiness(preZoomBounds); + tiledPage->updateTileDirtiness(); // paint what's needed unless we're zooming, since the new tiles won't // be relevant soon anyway diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp index b708ad1..832ed0c 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp @@ -41,11 +41,14 @@ #include -#ifdef DEBUG - #include #include +#undef XLOGC +#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "BaseRenderer", __VA_ARGS__) + +#ifdef DEBUG + #undef XLOG #define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "BaseRenderer", __VA_ARGS__) @@ -56,6 +59,9 @@ #endif // DEBUG +#define UPDATE_COUNT_MASK 0xFF // displayed count wraps at 256 +#define UPDATE_COUNT_ALPHA_MASK 0x3F // alpha wraps at 64 + namespace WebCore { BaseRenderer::RendererType BaseRenderer::g_currentType = BaseRenderer::Raster; @@ -79,12 +85,12 @@ void BaseRenderer::swapRendererIfNeeded(BaseRenderer*& renderer) } void BaseRenderer::drawTileInfo(SkCanvas* canvas, - const TileRenderInfo& renderInfo, int pictureCount) + const TileRenderInfo& renderInfo, int updateCount) { SkPaint paint; char str[256]; snprintf(str, 256, "(%d,%d) %.2f, tl%x p%x c%d", renderInfo.x, renderInfo.y, - renderInfo.scale, this, renderInfo.tilePainter, pictureCount); + renderInfo.scale, this, renderInfo.tilePainter, updateCount); paint.setARGB(255, 0, 0, 0); canvas->drawText(str, strlen(str), 0, 10, paint); paint.setARGB(255, 255, 0, 0); @@ -112,7 +118,7 @@ void BaseRenderer::drawTileInfo(SkCanvas* canvas, canvas->drawText(str, strlen(str), 0, textY + 1, paint); } -int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) +void BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) { const bool visualIndicator = TilesManager::instance()->getShowVisualIndicator(); const SkSize& tileSize = renderInfo.tileSize; @@ -122,7 +128,7 @@ int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) if (!canvas.getDevice()) { XLOG("Error: No Device"); - return 0; + return; } if (visualIndicator) @@ -131,12 +137,12 @@ int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) setupPartialInval(renderInfo, &canvas); canvas.translate(-renderInfo.x * tileSize.width(), -renderInfo.y * tileSize.height()); canvas.scale(renderInfo.scale, renderInfo.scale); - unsigned int pictureCount = 0; - renderInfo.tilePainter->paint(renderInfo.baseTile, &canvas, &pictureCount); + renderInfo.tilePainter->paint(renderInfo.baseTile, &canvas); if (visualIndicator) { canvas.restore(); - const int color = 20 + (pictureCount % 100); + unsigned int updateCount = renderInfo.tilePainter->getUpdateCount() & UPDATE_COUNT_MASK; + const int color = updateCount & UPDATE_COUNT_ALPHA_MASK; // only color the invalidated area SkPaint invalPaint; @@ -173,11 +179,9 @@ int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) } if (renderInfo.measurePerf) - drawTileInfo(&canvas, renderInfo, pictureCount); + drawTileInfo(&canvas, renderInfo, updateCount); } - renderInfo.textureInfo->m_pictureCount = pictureCount; renderingComplete(renderInfo, &canvas); - return pictureCount; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.h b/Source/WebCore/platform/graphics/android/BaseRenderer.h index 7780db1..2defcc3 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.h +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.h @@ -76,7 +76,7 @@ public: BaseRenderer(RendererType type) : m_type(type) {} virtual ~BaseRenderer() {} - int renderTiledContent(const TileRenderInfo& renderInfo); + void renderTiledContent(const TileRenderInfo& renderInfo); RendererType getType() { return m_type; } @@ -92,7 +92,7 @@ protected: virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) = 0; void drawTileInfo(SkCanvas* canvas, const TileRenderInfo& renderInfo, - int pictureCount); + int updateCount); virtual const String* getPerformanceTags(int& tagCount) = 0; diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp index ae4fb9d..de64425 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp @@ -74,7 +74,6 @@ BaseTile::BaseTile(bool isLayerTile) , m_scale(1) , m_dirty(true) , m_repaintPending(false) - , m_lastDirtyPicture(0) , m_fullRepaint(true) , m_isTexturePainted(false) , m_isLayerTile(isLayerTile) @@ -167,13 +166,11 @@ bool BaseTile::removeTexture(BaseTileTexture* texture) return true; } -void BaseTile::markAsDirty(int unsigned pictureCount, - const SkRegion& dirtyArea) +void BaseTile::markAsDirty(const SkRegion& dirtyArea) { if (dirtyArea.isEmpty()) return; android::AutoMutex lock(m_atomicSync); - m_lastDirtyPicture = pictureCount; m_dirtyArea.op(dirtyArea, SkRegion::kUnion_Op); // Check if we actually intersect with the area @@ -340,8 +337,6 @@ void BaseTile::paintBitmap() return; } - unsigned int pictureCount = 0; - // swap out the renderer if necessary BaseRenderer::swapRendererIfNeeded(m_renderer); // setup the common renderInfo fields; @@ -418,7 +413,7 @@ void BaseTile::paintBitmap() if (!fullRepaint) { renderInfo.invalRect = &totalRect; renderInfo.measurePerf = false; - pictureCount = m_renderer->renderTiledContent(renderInfo); + m_renderer->renderTiledContent(renderInfo); } } @@ -426,7 +421,7 @@ void BaseTile::paintBitmap() if (fullRepaint) { renderInfo.invalRect = 0; renderInfo.measurePerf = TilesManager::instance()->getShowVisualIndicator(); - pictureCount = m_renderer->renderTiledContent(renderInfo); + m_renderer->renderTiledContent(renderInfo); } m_atomicSync.lock(); diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h index 6ba66ef..f02386b 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.h +++ b/Source/WebCore/platform/graphics/android/BaseTile.h @@ -112,8 +112,7 @@ public: SkRect& realTileRect); bool isTileVisible(const IntRect& viewTileBounds); - void markAsDirty(const unsigned int pictureCount, - const SkRegion& dirtyArea); + void markAsDirty(const SkRegion& dirtyArea); bool isDirty(); bool isRepaintPending(); void setRepaintPending(bool pending); @@ -167,10 +166,6 @@ private: // used to signal that a repaint is pending bool m_repaintPending; - // stores the id of the latest picture from webkit that caused this tile to - // become dirty. A tile is no longer dirty when it has been painted with a - // picture that is newer than this value. - unsigned int m_lastDirtyPicture; // store the dirty region SkRegion m_dirtyArea; diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index cfd8937..97bd7a8 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -81,7 +81,6 @@ using namespace android; GLWebViewState::GLWebViewState() : m_zoomManager(this) - , m_currentPictureCounter(0) , m_usePageA(true) , m_frameworkInval(0, 0, 0, 0) , m_frameworkLayersInval(0, 0, 0, 0) @@ -186,11 +185,10 @@ void GLWebViewState::invalRegion(const SkRegion& region) void GLWebViewState::inval(const IntRect& rect) { - m_currentPictureCounter++; if (!rect.isEmpty()) { // find which tiles fall within the invalRect and mark them as dirty - m_tiledPageA->invalidateRect(rect, m_currentPictureCounter); - m_tiledPageB->invalidateRect(rect, m_currentPictureCounter); + m_tiledPageA->invalidateRect(rect); + m_tiledPageB->invalidateRect(rect); if (m_frameworkInval.isEmpty()) m_frameworkInval = rect; else @@ -202,10 +200,9 @@ void GLWebViewState::inval(const IntRect& rect) TilesManager::instance()->getProfiler()->nextInval(rect, zoomManager()->currentScale()); } -unsigned int GLWebViewState::paintBaseLayerContent(SkCanvas* canvas) +void GLWebViewState::paintBaseLayerContent(SkCanvas* canvas) { m_surfaceCollectionManager.drawCanvas(canvas, m_layersRenderingMode == kSingleSurfaceRendering); - return m_currentPictureCounter; } TiledPage* GLWebViewState::sibling(TiledPage* page) diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h index da579da..fcdd07c 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.h +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h @@ -175,7 +175,7 @@ public: const SkIRect& futureViewport() const { return m_futureViewportTileBounds; } void setFutureViewport(const SkIRect& viewport) { m_futureViewportTileBounds = viewport; } - unsigned int paintBaseLayerContent(SkCanvas* canvas); + void paintBaseLayerContent(SkCanvas* canvas); bool setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator, bool isPictureAfterFirstLayout); void paintExtras(); @@ -197,8 +197,6 @@ public: const SkIRect& preZoomBounds() const { return m_preZoomBounds; } void setPreZoomBounds(const SkIRect& bounds) { m_preZoomBounds = bounds; } - unsigned int currentPictureCounter() const { return m_currentPictureCounter; } - void setIsScrolling(bool isScrolling) { m_isScrolling = isScrolling; } bool isScrolling() { return m_isScrolling || m_isViewportScrolling; } @@ -264,7 +262,6 @@ private: SkIRect m_futureViewportTileBounds; SkIRect m_preZoomBounds; - unsigned int m_currentPictureCounter; bool m_usePageA; TiledPage* m_tiledPageA; TiledPage* m_tiledPageB; diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 1ac90e9..c6a69b7 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -658,7 +658,6 @@ bool GraphicsLayerAndroid::repaint() SkRegion region; region.setRect(0, 0, contentsRect.width(), contentsRect.height()); m_foregroundLayer->markAsDirty(region); - m_foregroundLayer->needsRepaint(); } else { // If there is no contents clip, we can draw everything into one // picture. @@ -688,7 +687,6 @@ bool GraphicsLayerAndroid::repaint() m_contentLayer->markAsDirty(m_dirtyRegion); m_dirtyRegion.setEmpty(); - m_contentLayer->needsRepaint(); m_needsRepaint = false; return true; @@ -698,7 +696,6 @@ bool GraphicsLayerAndroid::repaint() // texture. Only do so if we effectively have a new image! m_contentLayer->markAsDirty(m_dirtyRegion); m_dirtyRegion.setEmpty(); - m_contentLayer->needsRepaint(); m_newImage = false; m_needsRepaint = false; return true; diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp index 25dd6f3..815a70a 100644 --- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp +++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp @@ -230,7 +230,7 @@ float ImageTexture::opacity() return m_layer->drawOpacity(); } -bool ImageTexture::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) +bool ImageTexture::paint(BaseTile* tile, SkCanvas* canvas) { if (!m_picture) { XLOG("IT %p COULDNT PAINT, NO PICTURE", this); diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.h b/Source/WebCore/platform/graphics/android/ImageTexture.h index f2f99dd..91c8a29 100644 --- a/Source/WebCore/platform/graphics/android/ImageTexture.h +++ b/Source/WebCore/platform/graphics/android/ImageTexture.h @@ -85,7 +85,7 @@ public: bool equalsCRC(unsigned crc); // methods used by TiledTexture - virtual bool paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed); + virtual bool paint(BaseTile* tile, SkCanvas* canvas); virtual float opacity(); int nbTextures(); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index f101208..3549618 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -76,7 +76,6 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(), m_zValue(0), m_uniqueId(++gUniqueId), m_imageCRC(0), - m_pictureUsed(0), m_scale(1), m_lastComputeTextureSize(0), m_owningLayer(owner), @@ -129,7 +128,6 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_drawTransform = layer.m_drawTransform; m_childrenTransform = layer.m_childrenTransform; - m_pictureUsed = layer.m_pictureUsed; m_dirtyRegion = layer.m_dirtyRegion; m_scale = layer.m_scale; m_lastComputeTextureSize = 0; diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 7f5d5e2..2174ba4 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -235,9 +235,6 @@ public: virtual LayerAndroid* copy() const { return new LayerAndroid(*this); } - void needsRepaint() { m_pictureUsed++; } - unsigned int pictureUsed() { return m_pictureUsed; } - void clearDirtyRegion(); virtual void contentDraw(SkCanvas* canvas, PaintStyle style); @@ -342,8 +339,6 @@ private: unsigned m_imageCRC; - unsigned int m_pictureUsed; - // used to signal the framework we need a repaint bool m_hasRunningAnimations; diff --git a/Source/WebCore/platform/graphics/android/LayerGroup.cpp b/Source/WebCore/platform/graphics/android/LayerGroup.cpp index 5ec41f8..ce65d4a 100644 --- a/Source/WebCore/platform/graphics/android/LayerGroup.cpp +++ b/Source/WebCore/platform/graphics/android/LayerGroup.cpp @@ -260,7 +260,7 @@ void LayerGroup::computeTexturesAmount(TexturesResult* result) m_dualTiledTexture->computeTexturesAmount(result, getFirstLayer()); } -bool LayerGroup::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) +bool LayerGroup::paint(BaseTile* tile, SkCanvas* canvas) { if (singleLayer()) { getFirstLayer()->contentDraw(canvas, Layer::UnmergedLayers); diff --git a/Source/WebCore/platform/graphics/android/LayerGroup.h b/Source/WebCore/platform/graphics/android/LayerGroup.h index e3e0247..90001a5 100644 --- a/Source/WebCore/platform/graphics/android/LayerGroup.h +++ b/Source/WebCore/platform/graphics/android/LayerGroup.h @@ -64,7 +64,7 @@ public: bool hasText() { return m_hasText; } // TilePainter methods - virtual bool paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed); + virtual bool paint(BaseTile* tile, SkCanvas* canvas); virtual float opacity(); private: const TransformationMatrix* drawTransform(); diff --git a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp index 55fa51a..23abc06 100644 --- a/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp +++ b/Source/WebCore/platform/graphics/android/SurfaceCollection.cpp @@ -32,6 +32,7 @@ #include "LayerGroup.h" #include "GLWebViewState.h" #include "ScrollableLayerAndroid.h" +#include "TilesManager.h" #include #include @@ -62,8 +63,11 @@ SurfaceCollection::SurfaceCollection(BaseLayerAndroid* baseLayer) : m_baseLayer(baseLayer) , m_compositedRoot(0) { + if (!m_baseLayer) + return; + SkSafeRef(m_baseLayer); - if (m_baseLayer && m_baseLayer->countChildren()) { + if (m_baseLayer->countChildren()) { m_compositedRoot = static_cast(m_baseLayer->getChild(0)); // calculate draw transforms and z values @@ -76,6 +80,14 @@ SurfaceCollection::SurfaceCollection(BaseLayerAndroid* baseLayer) LayerMergeState layerMergeState(&m_layerGroups); m_compositedRoot->assignGroups(&layerMergeState); } + + // set the layergroups' and tiledpages' update count, to be drawn on painted tiles + unsigned int updateCount = TilesManager::instance()->incWebkitContentUpdates(); + for (unsigned int i = 0; i < m_layerGroups.size(); i++) + m_layerGroups[i]->setUpdateCount(updateCount); + m_baseLayer->state()->frontPage()->setUpdateCount(updateCount); + m_baseLayer->state()->backPage()->setUpdateCount(updateCount); + #ifdef DEBUG_COUNT ClassTracker::instance()->increment("SurfaceCollection"); #endif diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/TextureInfo.cpp index 3c4dde2..56b6698 100644 --- a/Source/WebCore/platform/graphics/android/TextureInfo.cpp +++ b/Source/WebCore/platform/graphics/android/TextureInfo.cpp @@ -42,7 +42,6 @@ TextureInfo::TextureInfo() m_height = 0; m_internalFormat = 0; m_eglSurface = EGL_NO_SURFACE; - m_pictureCount = 0; } bool TextureInfo::equalsAttributes(const TextureInfo* otherTexture) diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.h b/Source/WebCore/platform/graphics/android/TextureInfo.h index 8549365..764c229 100644 --- a/Source/WebCore/platform/graphics/android/TextureInfo.h +++ b/Source/WebCore/platform/graphics/android/TextureInfo.h @@ -64,8 +64,6 @@ public: sp m_ANW; // The EGLSurface wraps the m_ANW to enable direct OpenGL rendering (e.g. Ganesh) EGLSurface m_eglSurface; - - int m_pictureCount; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/TilePainter.h b/Source/WebCore/platform/graphics/android/TilePainter.h index e2ae66c..34e877e 100644 --- a/Source/WebCore/platform/graphics/android/TilePainter.h +++ b/Source/WebCore/platform/graphics/android/TilePainter.h @@ -39,10 +39,16 @@ class TilePainter : public SkRefCnt { // TODO: investigate webkit threadsafe ref counting public: virtual ~TilePainter() { } - virtual bool paint(BaseTile* tile, SkCanvas*, unsigned int*) = 0; + virtual bool paint(BaseTile* tile, SkCanvas* canvas) = 0; virtual float opacity() { return 1.0; } enum SurfaceType { Painted, Image }; virtual SurfaceType type() { return Painted; } + + unsigned int getUpdateCount() { return m_updateCount; } + void setUpdateCount(unsigned int updateCount) { m_updateCount = updateCount; } + +private: + unsigned int m_updateCount; }; } diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index 820cd56..629b095 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -65,7 +65,6 @@ TiledPage::TiledPage(int id, GLWebViewState* state) , m_scale(1) , m_invScale(1) , m_glWebViewState(state) - , m_latestPictureInval(0) , m_prepare(false) , m_isPrefetchPage(false) , m_willDraw(false) @@ -126,8 +125,9 @@ void TiledPage::discardTextures() return; } -void TiledPage::invalidateRect(const IntRect& inval, const unsigned int pictureCount) +void TiledPage::invalidateRect(const IntRect& inval) { +#ifdef DEBUG // Given the current scale level we need to mark the appropriate tiles as dirty const float invTileContentWidth = m_scale / TilesManager::tileWidth(); const float invTileContentHeight = m_scale / TilesManager::tileHeight(); @@ -138,11 +138,10 @@ void TiledPage::invalidateRect(const IntRect& inval, const unsigned int pictureC const int lastDirtyTileY = static_cast(ceilf(inval.maxY() * invTileContentHeight)); XLOG("Marking X %d-%d and Y %d-%d dirty", firstDirtyTileX, lastDirtyTileX, firstDirtyTileY, lastDirtyTileY); +#endif // We defer marking the tile as dirty until the next time we need to prepare // to draw. - m_invalRegion.op(firstDirtyTileX, firstDirtyTileY, lastDirtyTileX, lastDirtyTileY, SkRegion::kUnion_Op); - m_invalTilesRegion.op(inval.x(), inval.y(), inval.maxX(), inval.maxY(), SkRegion::kUnion_Op); - m_latestPictureInval = pictureCount; + m_invalRegion.op(inval.x(), inval.y(), inval.maxX(), inval.maxY(), SkRegion::kUnion_Op); } void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds) @@ -205,32 +204,17 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y } } -bool TiledPage::updateTileDirtiness(const SkIRect& tileBounds) +void TiledPage::updateTileDirtiness() { - if (!m_glWebViewState || tileBounds.isEmpty()) { - m_invalRegion.setEmpty(); - m_invalTilesRegion.setEmpty(); - return false; - } - - bool visibleTileIsDirty = false; - for (int x = 0; x < m_baseTileSize; x++) { - - BaseTile& tile = m_baseTiles[x]; + if (!m_glWebViewState || m_invalRegion.isEmpty()) + return; - // if the tile is in the dirty region then we must invalidate it - if (m_invalRegion.contains(tile.x(), tile.y())) { - tile.markAsDirty(m_latestPictureInval, m_invalTilesRegion); - if (tileBounds.contains(tile.x(), tile.y())) - visibleTileIsDirty = true; - } - } + for (int x = 0; x < m_baseTileSize; x++) + m_baseTiles[x].markAsDirty(m_invalRegion); // 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) @@ -385,7 +369,7 @@ void TiledPage::drawGL() m_willDraw = false; // don't redraw until re-prepared } -bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) +bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas) { static SkPaintFlagsDrawFilter prefetchFilter(SkPaint::kAllFlags, SkPaint::kAntiAlias_Flag); @@ -396,7 +380,7 @@ bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUse if (isPrefetchPage()) canvas->setDrawFilter(&prefetchFilter); - *pictureUsed = m_glWebViewState->paintBaseLayerContent(canvas); + m_glWebViewState->paintBaseLayerContent(canvas); return true; } diff --git a/Source/WebCore/platform/graphics/android/TiledPage.h b/Source/WebCore/platform/graphics/android/TiledPage.h index e6269ae..5587618 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.h +++ b/Source/WebCore/platform/graphics/android/TiledPage.h @@ -65,9 +65,8 @@ public: // prepare the page for display on the screen void prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds); - // update tiles with inval information, return true if visible ones are - // dirty (and thus repaint needed) - bool updateTileDirtiness(const SkIRect& tileBounds); + // update tiles with inval information + void updateTileDirtiness(); // returns true if the page can't draw the entire region (may still be stale) bool hasMissingContent(const SkIRect& tileBounds); @@ -83,7 +82,7 @@ public: // TilePainter implementation // used by individual tiles to generate the bitmap for their tile - bool paint(BaseTile*, SkCanvas*, unsigned int*); + bool paint(BaseTile* tile, SkCanvas* canvas); // used by individual tiles to get the information about the current picture GLWebViewState* glWebViewState() { return m_glWebViewState; } @@ -93,7 +92,7 @@ public: //TODO: clear all textures if this is called with a new value void setScale(float scale) { m_scale = scale; m_invScale = 1 / scale; } - void invalidateRect(const IntRect& invalRect, const unsigned int pictureCount); + void invalidateRect(const IntRect& invalRect); void discardTextures(); void updateBaseTileSize(); bool scrollingDown() { return m_scrollingDown; } @@ -116,15 +115,8 @@ private: float m_invScale; GLWebViewState* m_glWebViewState; - // used to identify the tiles that have been invalidated (marked dirty) since - // the last time updateTileState() has been called. The region is stored in - // terms of the (x,y) coordinates used to determine the location of the tile - // within the page, not in content/view pixel coordinates. - SkRegion m_invalRegion; - // inval regions in content coordinates - SkRegion m_invalTilesRegion; - unsigned int m_latestPictureInval; + SkRegion m_invalRegion; // in content coordinates bool m_prepare; bool m_scrollingDown; bool m_isPrefetchPage; diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp index 3edc93c..57d7683 100644 --- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp +++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp @@ -152,7 +152,7 @@ void TiledTexture::prepareGL(GLWebViewState* state, float scale, // apply dirty region to affected tiles if (!m_dirtyRegion.isEmpty()) { for (unsigned int i = 0; i < m_tiles.size(); i++) - m_tiles[i]->markAsDirty(1, m_dirtyRegion); + m_tiles[i]->markAsDirty(m_dirtyRegion); m_dirtyRegion.setEmpty(); } diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index a284687..5e9bf58 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -105,6 +105,7 @@ TilesManager::TilesManager() , m_useMinimalMemory(true) , m_useDoubleBuffering(true) , m_contentUpdates(0) + , m_webkitContentUpdates(0) , m_queue(0) , m_drawGLCount(1) , m_lastTimeLayersUsed(0) diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h index 98fc08c..a0ed9e7 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.h +++ b/Source/WebCore/platform/graphics/android/TilesManager.h @@ -182,6 +182,9 @@ public: } bool useDoubleBuffering() { return m_useDoubleBuffering; } + + unsigned int incWebkitContentUpdates() { return m_webkitContentUpdates++; } + void incContentUpdates() { m_contentUpdates++; } unsigned int getContentUpdates() { return m_contentUpdates; } void clearContentUpdates() { m_contentUpdates = 0; } @@ -231,6 +234,7 @@ private: bool m_useDoubleBuffering; unsigned int m_contentUpdates; // nr of successful tiled paints + unsigned int m_webkitContentUpdates; // nr of paints from webkit sp m_pixmapsGenerationThread; -- cgit v1.1