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

Unified Diff: cc/resources/picture_layer_tiling.cc

Issue 375923005: cc: Explicitly invalidate all dropped recordings on the main thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: invalid-resize: doublecall Created 6 years, 5 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
Index: cc/resources/picture_layer_tiling.cc
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index fb68cbb2fa43fcf1933dfafd8a21f4220781946a..9a65a5caf5dafc788c81e6d2c297eede02434479 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -138,57 +138,49 @@ void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
}
}
-void PictureLayerTiling::SetLayerBounds(const gfx::Size& layer_bounds) {
- if (layer_bounds_ == layer_bounds)
- return;
-
- DCHECK(!layer_bounds.IsEmpty());
+void PictureLayerTiling::UpdateTilesToCurrentPile(
+ const Region& layer_invalidation,
+ const gfx::Size& new_layer_bounds) {
+ DCHECK(!new_layer_bounds.IsEmpty());
gfx::Size old_layer_bounds = layer_bounds_;
- layer_bounds_ = layer_bounds;
+ layer_bounds_ = new_layer_bounds;
+
gfx::Size content_bounds =
gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_));
+ gfx::Size tile_size = tiling_data_.max_texture_size();
- gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
- if (tile_size != tiling_data_.max_texture_size()) {
+ if (layer_bounds_ != old_layer_bounds) {
+ // Drop tiles outside the new layer bounds if the layer shrank.
+ SetLiveTilesRect(
+ gfx::IntersectRects(live_tiles_rect_, gfx::Rect(content_bounds)));
tiling_data_.SetTilingRect(gfx::Rect(content_bounds));
+ tile_size = client_->CalculateTileSize(content_bounds);
+ }
+
+ if (tile_size != tiling_data_.max_texture_size()) {
tiling_data_.SetMaxTextureSize(tile_size);
+ // When the tile size changes, the TilingData positions no longer work
+ // as valid keys to the TileMap, so just drop all tiles.
Reset();
- return;
+ } else {
+ Invalidate(layer_invalidation);
}
- // Any tiles outside our new bounds are invalid and should be dropped.
- gfx::Rect bounded_live_tiles_rect(live_tiles_rect_);
- bounded_live_tiles_rect.Intersect(gfx::Rect(content_bounds));
- SetLiveTilesRect(bounded_live_tiles_rect);
- tiling_data_.SetTilingRect(gfx::Rect(content_bounds));
-
- // Create tiles for newly exposed areas.
- Region layer_region((gfx::Rect(layer_bounds_)));
- layer_region.Subtract(gfx::Rect(old_layer_bounds));
- Invalidate(layer_region);
-}
-
-void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) {
- DoInvalidate(layer_region, false /* recreate_tiles */);
+ PicturePileImpl* pile = client_->GetPile();
+ for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
+ it->second->set_picture_pile(pile);
}
void PictureLayerTiling::Invalidate(const Region& layer_region) {
- DoInvalidate(layer_region, true /* recreate_tiles */);
-}
-
-void PictureLayerTiling::DoInvalidate(const Region& layer_region,
- bool recreate_tiles) {
std::vector<TileMapKey> new_tile_keys;
- gfx::Rect expanded_live_tiles_rect(
- tiling_data_.ExpandRectToTileBoundsWithBorders(live_tiles_rect_));
for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) {
gfx::Rect layer_rect = iter.rect();
gfx::Rect content_rect =
gfx::ScaleToEnclosingRect(layer_rect, contents_scale_);
// Avoid needless work by not bothering to invalidate where there aren't
// tiles.
- content_rect.Intersect(expanded_live_tiles_rect);
+ content_rect.Intersect(live_tiles_rect_);
enne (OOO) 2014/07/11 18:21:54 Are you sure this shouldn't be the expanded_live_t
danakj 2014/07/11 20:15:26 I'm pretty sure.. 1) Only tiles that intersect th
if (content_rect.IsEmpty())
continue;
bool include_borders = true;
@@ -201,15 +193,17 @@ void PictureLayerTiling::DoInvalidate(const Region& layer_region,
if (find == tiles_.end())
continue;
tiles_.erase(find);
- if (recreate_tiles)
- new_tile_keys.push_back(key);
+ new_tile_keys.push_back(key);
}
}
- if (recreate_tiles) {
- const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
- for (size_t i = 0; i < new_tile_keys.size(); ++i)
+ if (!new_tile_keys.empty()) {
+ for (size_t i = 0; i < new_tile_keys.size(); ++i) {
+ // Don't try to share a tile with the twin layer, it's been invalidated so
+ // we have to make our own tile here.
+ PictureLayerTiling* twin_tiling = NULL;
CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling);
+ }
}
}
@@ -622,13 +616,6 @@ void PictureLayerTiling::DidBecomeActive() {
}
}
-void PictureLayerTiling::UpdateTilesToCurrentPile() {
- PicturePileImpl* pile = client_->GetPile();
- for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
- it->second->set_picture_pile(pile);
- }
-}
-
scoped_ptr<base::Value> PictureLayerTiling::AsValue() const {
scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
state->SetInteger("num_tiles", tiles_.size());

Powered by Google App Engine
This is Rietveld 408576698