From 32ce41e0241790f20e63cafea4d3c1db87423eec Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Fri, 20 Apr 2012 11:28:59 -0700 Subject: Don't overdraw TileGrids Given the visible area info, we can just tune the shader and matrix to draw partial tile at the edge of TileGrids. This could save a lot of GPU time. Change-Id: I1a45aa9a3a76ab5894096828bfff83057b1c9272 --- .../WebCore/platform/graphics/android/rendering/TileGrid.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp') diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp index e3aa2a9..7c6175f 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp @@ -232,9 +232,6 @@ void TileGrid::prepareTile(int x, int y, TilePainter* painter, tile->setContents(x, y, m_scale, isExpandPrefetch); - // TODO: move below (which is largely the same for layers / tiled page) into - // prepareGL() function - if (tile->isDirty() || !tile->frontTexture()) tile->reserveTexture(); @@ -299,6 +296,10 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity, bool usePointSampling = TilesManager::instance()->shader()->usePointSampling(m_scale, transform); + + float maxTileWidth = visibleArea.maxX() / tileWidth; + float maxTileHeight = visibleArea.maxY() / tileWidth; + for (unsigned int i = 0; i < m_tiles.size(); i++) { Tile* tile = m_tiles[i]; @@ -314,8 +315,11 @@ void TileGrid::drawGL(const IntRect& visibleArea, float opacity, tile->scale(), m_scale, tile->isTileReady(), tile->isDirty()); bool forceBaseBlending = background ? background->hasAlpha() : false; + + FloatPoint fillPortion(std::min(maxTileWidth - tile->x(), 1.0f), + std::min(maxTileHeight - tile->y(), 1.0f)); bool success = tile->drawGL(opacity, rect, m_scale, transform, - forceBaseBlending, usePointSampling); + forceBaseBlending, usePointSampling, fillPortion); if (semiOpaqueBaseSurface && success) { // Cut the successful drawn tile area from the missing region. missingRegion.op(SkIRect::MakeXYWH(tile->x(), tile->y(), 1, 1), -- cgit v1.1