Index: cc/tiled_layer.cc |
diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc |
index 1ea1e25fde49a6eb6953e51bdab2351c2f9cd725..67f333c20df16eca28e4bf1be162fa8e42e2f460 100644 |
--- a/cc/tiled_layer.cc |
+++ b/cc/tiled_layer.cc |
@@ -58,14 +58,12 @@ public: |
bool partialUpdate; |
bool validForFrame; |
bool occluded; |
- bool isInUseOnImpl; |
private: |
explicit UpdatableTile(scoped_ptr<LayerTextureUpdater::Texture> texture) |
: partialUpdate(false) |
, validForFrame(false) |
, occluded(false) |
- , isInUseOnImpl(false) |
, m_texture(texture.Pass()) |
{ |
} |
@@ -208,8 +206,6 @@ void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer) |
if (!tile) |
continue; |
- tile->isInUseOnImpl = false; |
- |
if (!tile->managedTexture()->haveBackingTexture()) { |
// Evicted tiles get deleted from both layers |
invalidTiles.append(tile); |
@@ -223,7 +219,6 @@ void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer) |
} |
tiledLayer->pushTileProperties(i, j, tile->managedTexture()->resourceId(), tile->opaqueRect()); |
- tile->isInUseOnImpl = true; |
} |
for (Vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin(); iter != invalidTiles.end(); ++iter) |
m_tiler->takeTile((*iter)->i(), (*iter)->j()); |
@@ -335,13 +330,9 @@ bool TiledLayerChromium::tileNeedsBufferedUpdate(UpdatableTile* tile) |
if (!tile->isDirty()) |
return false; |
- if (!tile->isInUseOnImpl) |
- return false; |
- |
return true; |
} |
- |
bool TiledLayerChromium::updateTiles(int left, int top, int right, int bottom, CCTextureUpdateQueue& queue, const CCOcclusionTracker* occlusion, CCRenderingStats& stats, bool& didPaint) |
{ |
didPaint = false; |
@@ -397,12 +388,10 @@ void TiledLayerChromium::markOcclusionsAndRequestTextures(int left, int top, int |
if (!succeeded) |
return; |
- // FIXME: Remove the loop and just pass the count! |
- for (int i = 0; i < occludedTileCount; i++) |
- occlusion->overdrawMetrics().didCullTileForUpload(); |
+ occlusion->overdrawMetrics().didCullTilesForUpload(occludedTileCount); |
danakj
2012/10/18 03:03:42
Nice, thanks for this :)
|
} |
-bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int bottom, bool ignoreOcclusions) |
+bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int bottom, bool ignoreOcclusions) const |
{ |
for (int j = top; j <= bottom; ++j) { |
for (int i = left; i <= right; ++i) { |
@@ -412,10 +401,6 @@ bool TiledLayerChromium::haveTexturesForTiles(int left, int top, int right, int |
if (!tile) |
continue; |
- // Ensure the entire tile is dirty if we don't have the texture. |
- if (!tile->managedTexture()->haveBackingTexture()) |
- tile->dirtyRect = m_tiler->tileRect(tile); |
- |
// If using occlusion and the visible region of the tile is occluded, |
// don't reserve a texture or update the tile. |
if (tile->occluded && !ignoreOcclusions) |
@@ -440,6 +425,22 @@ IntRect TiledLayerChromium::markTilesForUpdate(int left, int top, int right, int |
continue; |
if (tile->occluded && !ignoreOcclusions) |
continue; |
+ // FIXME: Decide if partial update should be allowed based on cost |
+ // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 |
+ if (layerTreeHost() && layerTreeHost()->bufferedUpdates() && tileNeedsBufferedUpdate(tile)) { |
+ // If we get a partial update, we use the same texture, otherwise return the |
+ // current texture backing, so we don't update visible textures non-atomically. |
+ // If the current backing is in-use, it won't be deleted until after the commit |
+ // as the texture manager will not allow deletion or recycling of in-use textures. |
+ if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost()->requestPartialTextureUpdate()) |
+ tile->partialUpdate = true; |
+ else |
+ tile->managedTexture()->returnBackingTexture(); |
+ } |
+ // Ensure the entire tile is dirty if we don't have the texture. |
+ if (!tile->managedTexture()->haveBackingTexture()) |
+ tile->dirtyRect = m_tiler->tileRect(tile); |
+ |
paintRect.unite(tile->dirtyRect); |
tile->markForUpdate(); |
} |
@@ -577,6 +578,8 @@ void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priori |
// Minimally create the tiles in the desired pre-paint rect. |
IntRect createTilesRect = idlePaintRect(); |
+ if (smallAnimatedLayer) |
+ createTilesRect = IntRect(IntPoint::zero(), contentBounds()); |
if (!createTilesRect.isEmpty()) { |
int left, top, right, bottom; |
m_tiler->contentRectToTileIndices(createTilesRect, left, top, right, bottom); |
@@ -588,48 +591,6 @@ void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priori |
} |
} |
- // Also, minimally create all tiles for small animated layers and also |
- // double-buffer them since we have limited their size to be reasonable. |
- IntRect doubleBufferedRect = visibleContentRect(); |
- if (smallAnimatedLayer) |
- doubleBufferedRect = IntRect(IntPoint::zero(), contentBounds()); |
- |
- // Create additional textures for double-buffered updates when needed. |
- // These textures must stay alive while the updated textures are incrementally |
- // uploaded, swapped atomically via pushProperties, and finally deleted |
- // after the commit is complete, after which they can be recycled. |
- if (!doubleBufferedRect.isEmpty()) { |
- int left, top, right, bottom; |
- m_tiler->contentRectToTileIndices(doubleBufferedRect, left, top, right, bottom); |
- for (int j = top; j <= bottom; ++j) { |
- for (int i = left; i <= right; ++i) { |
- UpdatableTile* tile = tileAt(i, j); |
- if (!tile) |
- tile = createTile(i, j); |
- // We need an additional texture if the tile needs a buffered-update and it's not a partial update. |
- // FIXME: Decide if partial update should be allowed based on cost |
- // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 |
- if (!layerTreeHost() || !layerTreeHost()->bufferedUpdates() || !tileNeedsBufferedUpdate(tile)) |
- continue; |
- if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost()->requestPartialTextureUpdate()) { |
- tile->partialUpdate = true; |
- continue; |
- } |
- |
- IntRect tileRect = m_tiler->tileRect(tile); |
- tile->dirtyRect = tileRect; |
- LayerTextureUpdater::Texture* backBuffer = tile->texture(); |
- setPriorityForTexture(visibleContentRect(), tile->dirtyRect, drawsToRoot, smallAnimatedLayer, backBuffer->texture()); |
- scoped_ptr<CCPrioritizedTexture> frontBuffer = CCPrioritizedTexture::create(backBuffer->texture()->textureManager(), |
- backBuffer->texture()->size(), |
- backBuffer->texture()->format()); |
- // Swap backBuffer into frontBuffer and add it to delete after commit queue. |
- backBuffer->swapTextureWith(frontBuffer); |
- layerTreeHost()->deleteTextureAfterCommit(frontBuffer.Pass()); |
- } |
- } |
- } |
- |
// Now update priorities on all tiles we have in the layer, no matter where they are. |
for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { |
UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); |