| 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..7a56e20920e6c62aa86b2b91114e4d04dc41c68e 100644
|
| --- a/cc/resources/picture_layer_tiling.cc
|
| +++ b/cc/resources/picture_layer_tiling.cc
|
| @@ -74,8 +74,8 @@ PictureLayerTiling::PictureLayerTiling(float contents_scale,
|
| client_(client),
|
| tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels),
|
| last_impl_frame_time_in_seconds_(0.0),
|
| - content_to_screen_scale_(0.f),
|
| can_require_tiles_for_activation_(false),
|
| + current_content_to_screen_scale_(0.f),
|
| has_visible_rect_tiles_(false),
|
| has_skewport_rect_tiles_(false),
|
| has_soon_border_rect_tiles_(false),
|
| @@ -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,23 @@ void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
|
| VerifyLiveTilesRect();
|
| }
|
|
|
| +void PictureLayerTiling::CloneTilesAndPropertiesFrom(
|
| + const PictureLayerTiling& other) {
|
| + DCHECK_EQ(&other, client_->GetPendingOrActiveTwinTiling(this));
|
| +
|
| + DCHECK_EQ(other.contents_scale_, contents_scale_);
|
| + DCHECK_EQ(other.layer_bounds_.ToString(), layer_bounds_.ToString());
|
| + resolution_ = other.resolution_;
|
| +
|
| + SetLiveTilesRect(other.live_tiles_rect());
|
| + DCHECK_EQ(other.tiles_.size(), tiles_.size());
|
| +
|
| + UpdateTilePriorityRects(
|
| + other.current_content_to_screen_scale_, other.current_visible_rect_,
|
| + other.current_skewport_rect_, other.current_soon_border_rect_,
|
| + other.current_eventually_rect_, other.current_occlusion_in_layer_space_);
|
| +}
|
| +
|
| void PictureLayerTiling::UpdateTilesToCurrentRasterSource(
|
| RasterSource* raster_source,
|
| const Region& layer_invalidation,
|
| @@ -210,10 +223,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 +263,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 +303,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);
|
| }
|
| }
|
| @@ -582,34 +598,43 @@ void PictureLayerTiling::ComputeTilePriorityRects(
|
| << " eventually_rect: " << eventually_rect.ToString();
|
|
|
| // Calculate the soon border rect.
|
| - content_to_screen_scale_ = ideal_contents_scale / contents_scale_;
|
| + float content_to_screen_scale = ideal_contents_scale / contents_scale_;
|
| gfx::Rect soon_border_rect = visible_rect_in_content_space;
|
| - float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale_;
|
| + float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale;
|
| soon_border_rect.Inset(-border, -border, -border, -border);
|
|
|
| - // Update the tiling state.
|
| - SetLiveTilesRect(eventually_rect);
|
| -
|
| last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
|
| last_viewport_in_layer_space_ = viewport_in_layer_space;
|
| last_visible_rect_in_content_space_ = visible_rect_in_content_space;
|
|
|
| - eviction_tiles_cache_valid_ = false;
|
| + SetLiveTilesRect(eventually_rect);
|
| + UpdateTilePriorityRects(
|
| + content_to_screen_scale, visible_rect_in_content_space, skewport,
|
| + soon_border_rect, eventually_rect, occlusion_in_layer_space);
|
| +}
|
|
|
| +void PictureLayerTiling::UpdateTilePriorityRects(
|
| + float content_to_screen_scale,
|
| + const gfx::Rect& visible_rect_in_content_space,
|
| + const gfx::Rect& skewport,
|
| + const gfx::Rect& soon_border_rect,
|
| + const gfx::Rect& eventually_rect,
|
| + const Occlusion& occlusion_in_layer_space) {
|
| current_visible_rect_ = visible_rect_in_content_space;
|
| current_skewport_rect_ = skewport;
|
| current_soon_border_rect_ = soon_border_rect;
|
| current_eventually_rect_ = eventually_rect;
|
| current_occlusion_in_layer_space_ = occlusion_in_layer_space;
|
| + current_content_to_screen_scale_ = content_to_screen_scale;
|
|
|
| - // Update has_*_tiles state.
|
| gfx::Rect tiling_rect(tiling_size());
|
| -
|
| has_visible_rect_tiles_ = tiling_rect.Intersects(current_visible_rect_);
|
| has_skewport_rect_tiles_ = tiling_rect.Intersects(current_skewport_rect_);
|
| has_soon_border_rect_tiles_ =
|
| tiling_rect.Intersects(current_soon_border_rect_);
|
| has_eventually_rect_tiles_ = tiling_rect.Intersects(current_eventually_rect_);
|
| +
|
| + eviction_tiles_cache_valid_ = false;
|
| }
|
|
|
| void PictureLayerTiling::SetLiveTilesRect(
|
| @@ -805,10 +830,10 @@ void PictureLayerTiling::UpdateTilePriority(Tile* tile) const {
|
| tile->set_required_for_draw(false);
|
| tile->set_is_occluded(tree, false);
|
|
|
| - DCHECK_GT(content_to_screen_scale_, 0.f);
|
| + DCHECK_GT(current_content_to_screen_scale_, 0.f);
|
| float distance_to_visible =
|
| current_visible_rect_.ManhattanInternalDistance(tile_bounds) *
|
| - content_to_screen_scale_;
|
| + current_content_to_screen_scale_;
|
|
|
| if (max_tile_priority_bin <= TilePriority::SOON &&
|
| (current_soon_border_rect_.Intersects(tile_bounds) ||
|
|
|