| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 142 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
| 143 if (tile.get()) { | 143 if (tile.get()) { |
| 144 DCHECK(!tile->is_shared()); | 144 DCHECK(!tile->is_shared()); |
| 145 tile->set_tiling_index(i, j); | 145 tile->set_tiling_index(i, j); |
| 146 tiles_[key] = tile; | 146 tiles_[key] = tile; |
| 147 } | 147 } |
| 148 return tile.get(); | 148 return tile.get(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 151 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
| 152 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 152 const PictureLayerTiling* twin_tiling = |
| 153 client_->GetPendingOrActiveTwinTiling(this); |
| 153 bool include_borders = false; | 154 bool include_borders = false; |
| 154 for (TilingData::Iterator iter( | 155 for (TilingData::Iterator iter( |
| 155 &tiling_data_, live_tiles_rect_, include_borders); | 156 &tiling_data_, live_tiles_rect_, include_borders); |
| 156 iter; | 157 iter; |
| 157 ++iter) { | 158 ++iter) { |
| 158 TileMapKey key = iter.index(); | 159 TileMapKey key = iter.index(); |
| 159 TileMap::iterator find = tiles_.find(key); | 160 TileMap::iterator find = tiles_.find(key); |
| 160 if (find != tiles_.end()) | 161 if (find != tiles_.end()) |
| 161 continue; | 162 continue; |
| 162 CreateTile(key.first, key.second, twin_tiling); | 163 CreateTile(key.first, key.second, twin_tiling); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 for (int j = before_top; j <= before_bottom; ++j) | 220 for (int j = before_top; j <= before_bottom; ++j) |
| 220 RemoveTileAt(i, j, recycled_twin); | 221 RemoveTileAt(i, j, recycled_twin); |
| 221 } | 222 } |
| 222 for (int i = before_left; i <= after_right; ++i) { | 223 for (int i = before_left; i <= after_right; ++i) { |
| 223 for (int j = after_bottom + 1; j <= before_bottom; ++j) | 224 for (int j = after_bottom + 1; j <= before_bottom; ++j) |
| 224 RemoveTileAt(i, j, recycled_twin); | 225 RemoveTileAt(i, j, recycled_twin); |
| 225 } | 226 } |
| 226 | 227 |
| 227 // If the layer grew, the live_tiles_rect_ is not changed, but a new row | 228 // If the layer grew, the live_tiles_rect_ is not changed, but a new row |
| 228 // and/or column of tiles may now exist inside the same live_tiles_rect_. | 229 // and/or column of tiles may now exist inside the same live_tiles_rect_. |
| 229 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 230 const PictureLayerTiling* twin_tiling = |
| 231 client_->GetPendingOrActiveTwinTiling(this); |
| 230 if (after_right > before_right) { | 232 if (after_right > before_right) { |
| 231 DCHECK_EQ(after_right, before_right + 1); | 233 DCHECK_EQ(after_right, before_right + 1); |
| 232 for (int j = before_top; j <= after_bottom; ++j) | 234 for (int j = before_top; j <= after_bottom; ++j) |
| 233 CreateTile(after_right, j, twin_tiling); | 235 CreateTile(after_right, j, twin_tiling); |
| 234 } | 236 } |
| 235 if (after_bottom > before_bottom) { | 237 if (after_bottom > before_bottom) { |
| 236 DCHECK_EQ(after_bottom, before_bottom + 1); | 238 DCHECK_EQ(after_bottom, before_bottom + 1); |
| 237 for (int i = before_left; i <= before_right; ++i) | 239 for (int i = before_left; i <= before_right; ++i) |
| 238 CreateTile(i, after_bottom, twin_tiling); | 240 CreateTile(i, after_bottom, twin_tiling); |
| 239 } | 241 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 // Iterate to delete all tiles outside of our new live_tiles rect. | 625 // Iterate to delete all tiles outside of our new live_tiles rect. |
| 624 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | 626 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
| 625 for (TilingData::DifferenceIterator iter(&tiling_data_, | 627 for (TilingData::DifferenceIterator iter(&tiling_data_, |
| 626 live_tiles_rect_, | 628 live_tiles_rect_, |
| 627 new_live_tiles_rect); | 629 new_live_tiles_rect); |
| 628 iter; | 630 iter; |
| 629 ++iter) { | 631 ++iter) { |
| 630 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); | 632 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); |
| 631 } | 633 } |
| 632 | 634 |
| 633 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 635 const PictureLayerTiling* twin_tiling = |
| 636 client_->GetPendingOrActiveTwinTiling(this); |
| 634 | 637 |
| 635 // Iterate to allocate new tiles for all regions with newly exposed area. | 638 // Iterate to allocate new tiles for all regions with newly exposed area. |
| 636 for (TilingData::DifferenceIterator iter(&tiling_data_, | 639 for (TilingData::DifferenceIterator iter(&tiling_data_, |
| 637 new_live_tiles_rect, | 640 new_live_tiles_rect, |
| 638 live_tiles_rect_); | 641 live_tiles_rect_); |
| 639 iter; | 642 iter; |
| 640 ++iter) { | 643 ++iter) { |
| 641 TileMapKey key(iter.index()); | 644 TileMapKey key(iter.index()); |
| 642 CreateTile(key.first, key.second, twin_tiling); | 645 CreateTile(key.first, key.second, twin_tiling); |
| 643 } | 646 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 714 |
| 712 if (resolution_ != HIGH_RESOLUTION) | 715 if (resolution_ != HIGH_RESOLUTION) |
| 713 return false; | 716 return false; |
| 714 | 717 |
| 715 if (IsTileOccluded(tile)) | 718 if (IsTileOccluded(tile)) |
| 716 return false; | 719 return false; |
| 717 | 720 |
| 718 if (client_->RequiresHighResToDraw()) | 721 if (client_->RequiresHighResToDraw()) |
| 719 return true; | 722 return true; |
| 720 | 723 |
| 721 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 724 const PictureLayerTiling* twin_tiling = |
| 725 client_->GetPendingOrActiveTwinTiling(this); |
| 722 if (!twin_tiling) | 726 if (!twin_tiling) |
| 723 return true; | 727 return true; |
| 724 | 728 |
| 725 if (twin_tiling->layer_bounds() != layer_bounds()) | 729 if (twin_tiling->layer_bounds() != layer_bounds()) |
| 726 return true; | 730 return true; |
| 727 | 731 |
| 728 if (twin_tiling->current_visible_rect_ != current_visible_rect_) | 732 if (twin_tiling->current_visible_rect_ != current_visible_rect_) |
| 729 return true; | 733 return true; |
| 730 | 734 |
| 731 Tile* twin_tile = | 735 Tile* twin_tile = |
| 732 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); | 736 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); |
| 733 // If twin tile is missing, it might not have a recording, so we don't need | 737 // If twin tile is missing, it might not have a recording, so we don't need |
| 734 // this tile to be required for activation. | 738 // this tile to be required for activation. |
| 735 if (!twin_tile) | 739 if (!twin_tile) |
| 736 return false; | 740 return false; |
| 737 | 741 |
| 738 return true; | 742 return true; |
| 739 } | 743 } |
| 740 | 744 |
| 741 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { | 745 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { |
| 742 UpdateTilePriority(tile); | 746 UpdateTilePriority(tile); |
| 743 | 747 |
| 744 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 748 const PictureLayerTiling* twin_tiling = |
| 749 client_->GetPendingOrActiveTwinTiling(this); |
| 745 if (!tile->is_shared() || !twin_tiling) { | 750 if (!tile->is_shared() || !twin_tiling) { |
| 746 WhichTree tree = client_->GetTree(); | 751 WhichTree tree = client_->GetTree(); |
| 747 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 752 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
| 748 tile->SetPriority(twin_tree, TilePriority()); | 753 tile->SetPriority(twin_tree, TilePriority()); |
| 749 tile->set_is_occluded(twin_tree, false); | 754 tile->set_is_occluded(twin_tree, false); |
| 750 if (twin_tree == PENDING_TREE) | 755 if (twin_tree == PENDING_TREE) |
| 751 tile->set_required_for_activation(false); | 756 tile->set_required_for_activation(false); |
| 752 return; | 757 return; |
| 753 } | 758 } |
| 754 | 759 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 DCHECK(*this); | 1232 DCHECK(*this); |
| 1228 do { | 1233 do { |
| 1229 ++current_eviction_tiles_index_; | 1234 ++current_eviction_tiles_index_; |
| 1230 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1235 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
| 1231 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1236 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
| 1232 | 1237 |
| 1233 return *this; | 1238 return *this; |
| 1234 } | 1239 } |
| 1235 | 1240 |
| 1236 } // namespace cc | 1241 } // namespace cc |
| OLD | NEW |