Index: cc/resources/picture_layer_tiling.cc |
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc |
index e9e3b86180a0dba8a297dc77235f6f84224fe191..8eb95d80f91021603960cadd613e4b336e37fe43 100644 |
--- a/cc/resources/picture_layer_tiling.cc |
+++ b/cc/resources/picture_layer_tiling.cc |
@@ -105,10 +105,6 @@ PictureLayerTiling::~PictureLayerTiling() { |
it->second->set_shared(false); |
} |
-void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
- client_ = client; |
-} |
- |
Tile* PictureLayerTiling::CreateTile(int i, |
int j, |
const PictureLayerTiling* twin_tiling) { |
@@ -167,6 +163,13 @@ void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
VerifyLiveTilesRect(); |
} |
+void PictureLayerTiling::CreateSharedTilesFromPending( |
+ const PictureLayerTiling& other) { |
+ DCHECK_EQ(&other, client_->GetPendingOrActiveTwinTiling(this)); |
+ SetLiveTilesRect(other.live_tiles_rect()); |
+ DCHECK_EQ(other.tiles_.size(), tiles_.size()); |
+} |
+ |
void PictureLayerTiling::UpdateTilesToCurrentRasterSource( |
RasterSource* raster_source, |
const Region& layer_invalidation, |
@@ -210,10 +213,10 @@ void PictureLayerTiling::UpdateTilesToCurrentRasterSource( |
tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); |
} |
- // There is no recycled twin since this is run on the pending tiling. |
+ // There is no recycled twin since this is run on the pending tiling |
+ // during commit, and on the active tree during activate. |
PictureLayerTiling* recycled_twin = NULL; |
DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); |
- DCHECK_EQ(PENDING_TREE, client_->GetTree()); |
// Drop tiles outside the new layer bounds if the layer shrank. |
for (int i = after_right + 1; i <= before_right; ++i) { |
@@ -250,23 +253,22 @@ void PictureLayerTiling::UpdateTilesToCurrentRasterSource( |
Invalidate(layer_invalidation); |
} |
- for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
- it->second->set_raster_source(raster_source); |
+ // Shared (ie. non-invalidated) tiles on the pending tree are updated to use |
+ // the new raster source. When this raster source is activated, the raster |
+ // source will remain valid for shared tiles in the active tree. |
+ // TODO(danakj): Clean this up, pass it in or make it a separate function call |
+ // or something. |
+ // TODO(danakj): This breaks if we commit to active tree! We really need to do |
+ // this for the sync tree. |
+ bool set_tiles_to_raster_source = client_->GetTree() == PENDING_TREE; |
+ if (set_tiles_to_raster_source) { |
+ for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
+ it->second->set_raster_source(raster_source); |
+ } |
VerifyLiveTilesRect(); |
} |
-void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { |
- bool recreate_invalidated_tiles = false; |
- DoInvalidate(layer_region, recreate_invalidated_tiles); |
-} |
- |
void PictureLayerTiling::Invalidate(const Region& layer_region) { |
- bool recreate_invalidated_tiles = true; |
- DoInvalidate(layer_region, recreate_invalidated_tiles); |
-} |
- |
-void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
- bool recreate_invalidated_tiles) { |
std::vector<TileMapKey> new_tile_keys; |
gfx::Rect expanded_live_tiles_rect = |
tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
@@ -291,20 +293,24 @@ void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
&tiling_data_, content_rect, include_borders); |
iter; |
++iter) { |
- // There is no recycled twin since this is run on the pending tiling. |
+ // There is no recycled twin for the peding tree during commit, or for the |
+ // active tree during activation. |
PictureLayerTiling* recycled_twin = NULL; |
DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); |
- DCHECK_EQ(PENDING_TREE, client_->GetTree()); |
if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin)) |
new_tile_keys.push_back(iter.index()); |
} |
} |
- if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
+ if (!new_tile_keys.empty()) { |
+ // During commit to the pending tree, invalidations can never be shared with |
+ // the active tree since the active tree has different content there. |
+ // However, during activation, invalidations on the active tree can be |
+ // shared with the pending tree always. |
+ const PictureLayerTiling* twin_tiling = nullptr; |
+ if (client_->GetTree() == ACTIVE_TREE) |
+ twin_tiling = client_->GetPendingOrActiveTwinTiling(this); |
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. |
- const PictureLayerTiling* twin_tiling = NULL; |
CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); |
} |
} |