Index: cc/tiles/picture_layer_tiling.cc |
diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc |
index f0bcae6f2a79ccaf014a4c5646a674588f67dcb7..5bef3aa22b5d1784f27801d5b05c410b2b4a831f 100644 |
--- a/cc/tiles/picture_layer_tiling.cc |
+++ b/cc/tiles/picture_layer_tiling.cc |
@@ -102,21 +102,18 @@ float PictureLayerTiling::CalculateSoonBorderDistance( |
max_dimension * kSoonBorderDistanceViewportPercentage); |
} |
-Tile* PictureLayerTiling::CreateTile(int i, int j) { |
+Tile* PictureLayerTiling::CreateTile(const Tile::CreateInfo& info) { |
+ const int i = info.tiling_i_index; |
vmpstr
2015/08/28 21:04:17
While here and doing this, could you just use info
danakj
2015/08/31 21:12:12
As per offline convo.. nope. :D This is kinda weir
|
+ const int j = info.tiling_j_index; |
TileMapKey key(i, j); |
DCHECK(tiles_.find(key) == tiles_.end()); |
- gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); |
- gfx::Rect tile_rect = paint_rect; |
- tile_rect.set_size(tiling_data_.max_texture_size()); |
- |
- if (!raster_source_->CoversRect(tile_rect, contents_scale_)) |
+ if (!raster_source_->CoversRect(info.enclosing_layer_rect)) |
return nullptr; |
all_tiles_done_ = false; |
- ScopedTilePtr tile = client_->CreateTile(contents_scale_, tile_rect); |
+ ScopedTilePtr tile = client_->CreateTile(info); |
Tile* raw_ptr = tile.get(); |
- tile->set_tiling_index(i, j); |
tiles_.add(key, tile.Pass()); |
return raw_ptr; |
} |
@@ -137,8 +134,9 @@ void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
if (find != tiles_.end()) |
continue; |
- if (ShouldCreateTileAt(key.index_x, key.index_y)) { |
- Tile* tile = CreateTile(key.index_x, key.index_y); |
+ Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); |
vmpstr
2015/08/28 21:04:17
... Then don't expand key here, just pass a key.
|
+ if (ShouldCreateTileAt(info)) { |
+ Tile* tile = CreateTile(info); |
// If this is the pending tree, then the active twin tiling may contain |
// the previous content ID of these tiles. In that case, we need only |
@@ -269,15 +267,17 @@ void PictureLayerTiling::SetRasterSourceAndResize( |
if (after_right > before_right) { |
DCHECK_EQ(after_right, before_right + 1); |
for (int j = before_top; j <= after_bottom; ++j) { |
- if (ShouldCreateTileAt(after_right, j)) |
- CreateTile(after_right, j); |
+ Tile::CreateInfo info = CreateInfoForTile(after_right, j); |
+ if (ShouldCreateTileAt(info)) |
+ CreateTile(info); |
} |
} |
if (after_bottom > before_bottom) { |
DCHECK_EQ(after_bottom, before_bottom + 1); |
for (int i = before_left; i <= before_right; ++i) { |
- if (ShouldCreateTileAt(i, after_bottom)) |
- CreateTile(i, after_bottom); |
+ Tile::CreateInfo info = CreateInfoForTile(i, after_bottom); |
+ if (ShouldCreateTileAt(info)) |
+ CreateTile(info); |
} |
} |
} |
@@ -337,13 +337,26 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, |
// tiles from knowing the invalidation rect and content id. crbug.com/490847 |
ScopedTilePtr old_tile = TakeTileAt(key.index_x, key.index_y); |
if (recreate_tiles && old_tile) { |
- if (Tile* tile = CreateTile(key.index_x, key.index_y)) |
+ Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); |
+ if (Tile* tile = CreateTile(info)) |
tile->SetInvalidated(invalid_content_rect, old_tile->id()); |
} |
} |
} |
-bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { |
+Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { |
+ gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); |
vmpstr
2015/08/28 21:04:17
... And expand here? Wdyt?
|
+ tile_rect.set_size(tiling_data_.max_texture_size()); |
+ gfx::Rect enclosing_layer_rect = |
+ gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale_); |
+ return Tile::CreateInfo(i, j, enclosing_layer_rect, tile_rect, |
+ contents_scale_); |
+} |
+ |
+bool PictureLayerTiling::ShouldCreateTileAt( |
+ const Tile::CreateInfo& info) const { |
+ const int i = info.tiling_i_index; |
+ const int j = info.tiling_j_index; |
// Active tree should always create a tile. The reason for this is that active |
// tree represents content that we draw on screen, which means that whenever |
// we check whether a tile should exist somewhere, the answer is yes. This |
@@ -364,21 +377,16 @@ bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { |
if (!TilingMatchesTileIndices(active_twin)) |
return true; |
- gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); |
- gfx::Rect tile_rect = paint_rect; |
- tile_rect.set_size(tiling_data_.max_texture_size()); |
- |
// If the active tree can't create a tile, because of its raster source, then |
// the pending tree should create one. |
- if (!active_twin->raster_source()->CoversRect(tile_rect, contents_scale())) |
+ if (!active_twin->raster_source()->CoversRect(info.enclosing_layer_rect)) |
return true; |
const Region* layer_invalidation = client_->GetPendingInvalidation(); |
- gfx::Rect layer_rect = |
- gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale()); |
// If this tile is invalidated, then the pending tree should create one. |
- if (layer_invalidation && layer_invalidation->Intersects(layer_rect)) |
+ if (layer_invalidation && |
+ layer_invalidation->Intersects(info.enclosing_layer_rect)) |
return true; |
// If the active tree doesn't have a tile here, but it's in the pending tree's |
@@ -386,7 +394,8 @@ bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { |
// if the pending visible rect is outside of the active tree's live tiles |
// rect. In those situations, we need to block activation until we're ready to |
// display content, which will have to come from the pending tree. |
- if (!active_twin->TileAt(i, j) && current_visible_rect_.Intersects(tile_rect)) |
+ if (!active_twin->TileAt(i, j) && |
+ current_visible_rect_.Intersects(info.content_rect)) |
return true; |
// In all other cases, the pending tree doesn't need to create a tile. |
@@ -736,9 +745,9 @@ void PictureLayerTiling::SetLiveTilesRect( |
for (TilingData::DifferenceIterator iter(&tiling_data_, new_live_tiles_rect, |
live_tiles_rect_); |
iter; ++iter) { |
- TileMapKey key(iter.index()); |
- if (ShouldCreateTileAt(key.index_x, key.index_y)) |
- CreateTile(key.index_x, key.index_y); |
+ Tile::CreateInfo info = CreateInfoForTile(iter.index_x(), iter.index_y()); |
+ if (ShouldCreateTileAt(info)) |
+ CreateTile(info); |
} |
live_tiles_rect_ = new_live_tiles_rect; |
@@ -889,11 +898,11 @@ PrioritizedTile PictureLayerTiling::MakePrioritizedTile( |
Tile* tile, |
PriorityRectType priority_rect_type) const { |
DCHECK(tile); |
- DCHECK( |
- raster_source()->CoversRect(tile->content_rect(), tile->contents_scale())) |
+ DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) |
<< "Recording rect: " |
<< gfx::ScaleToEnclosingRect(tile->content_rect(), |
- 1.f / tile->contents_scale()).ToString(); |
+ 1.f / tile->contents_scale()) |
+ .ToString(); |
return PrioritizedTile(tile, raster_source(), |
ComputePriorityForTile(tile, priority_rect_type), |