Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3634)

Unified Diff: cc/tiled_layer.cc

Issue 11028132: cc: The recent texture manager bug uncovered some unnecessary code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/prioritized_texture.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiled_layer.cc
diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc
index 1ea1e25fde49a6eb6953e51bdab2351c2f9cd725..19ba2947c8cb5582d8acb99791b88882b7a28dd6 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());
@@ -322,26 +317,9 @@ void TiledLayerChromium::invalidateContentRect(const IntRect& contentRect)
// Returns true if tile is dirty and only part of it needs to be updated.
bool TiledLayerChromium::tileOnlyNeedsPartialUpdate(UpdatableTile* tile)
{
- return !tile->dirtyRect.contains(m_tiler->tileRect(tile));
+ return !tile->updateRect.contains(m_tiler->tileRect(tile)) && tile->managedTexture()->haveBackingTexture();
}
-// Dirty tiles with valid textures needs buffered update to guarantee that
-// we don't modify textures currently used for drawing by the impl thread.
-bool TiledLayerChromium::tileNeedsBufferedUpdate(UpdatableTile* tile)
-{
- if (!tile->managedTexture()->haveBackingTexture())
- return false;
-
- 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;
@@ -478,6 +456,20 @@ void TiledLayerChromium::updateTileTextures(const IntRect& paintRect, int left,
if (dirtyRect.isEmpty())
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()) {
+ // 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();
+ }
+
// Save what was painted opaque in the tile. Keep the old area if the paint didn't touch it, and didn't paint some
// other part of the tile opaque.
IntRect tilePaintedRect = intersection(tileRect, paintRect);
@@ -577,6 +569,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 +582,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;
danakj 2012/10/17 23:19:37 who's doing this now?
epenner 2012/10/17 23:33:14 Throwing the texture away will make it dirty.... B
- 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);
« no previous file with comments | « cc/prioritized_texture.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698