| 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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 tile->set_tiling_index(i, j); | 114 tile->set_tiling_index(i, j); |
| 115 tiles_.add(key, tile.Pass()); | 115 tiles_.add(key, tile.Pass()); |
| 116 return raw_ptr; | 116 return raw_ptr; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 119 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
| 120 bool include_borders = false; | 120 bool include_borders = false; |
| 121 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, | 121 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, |
| 122 include_borders); | 122 include_borders); |
| 123 iter; ++iter) { | 123 iter; ++iter) { |
| 124 TileMapKey key = iter.index(); | 124 TileMapKey key(iter.index()); |
| 125 TileMap::iterator find = tiles_.find(key); | 125 TileMap::iterator find = tiles_.find(key); |
| 126 if (find != tiles_.end()) | 126 if (find != tiles_.end()) |
| 127 continue; | 127 continue; |
| 128 | 128 |
| 129 if (ShouldCreateTileAt(key.first, key.second)) | 129 if (ShouldCreateTileAt(key.index_x, key.index_y)) |
| 130 CreateTile(key.first, key.second); | 130 CreateTile(key.index_x, key.index_y); |
| 131 } | 131 } |
| 132 VerifyLiveTilesRect(false); | 132 VerifyLiveTilesRect(false); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void PictureLayerTiling::TakeTilesAndPropertiesFrom( | 135 void PictureLayerTiling::TakeTilesAndPropertiesFrom( |
| 136 PictureLayerTiling* pending_twin, | 136 PictureLayerTiling* pending_twin, |
| 137 const Region& layer_invalidation) { | 137 const Region& layer_invalidation) { |
| 138 TRACE_EVENT0("cc", "TakeTilesAndPropertiesFrom"); | 138 TRACE_EVENT0("cc", "TakeTilesAndPropertiesFrom"); |
| 139 SetRasterSourceAndResize(pending_twin->raster_source_); | 139 SetRasterSourceAndResize(pending_twin->raster_source_); |
| 140 | 140 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (content_rect.IsEmpty()) | 279 if (content_rect.IsEmpty()) |
| 280 continue; | 280 continue; |
| 281 // Since the content_rect includes border pixels already, don't include | 281 // Since the content_rect includes border pixels already, don't include |
| 282 // borders when iterating to avoid double counting them. | 282 // borders when iterating to avoid double counting them. |
| 283 bool include_borders = false; | 283 bool include_borders = false; |
| 284 for ( | 284 for ( |
| 285 TilingData::Iterator iter(&tiling_data_, content_rect, include_borders); | 285 TilingData::Iterator iter(&tiling_data_, content_rect, include_borders); |
| 286 iter; ++iter) { | 286 iter; ++iter) { |
| 287 if (RemoveTileAt(iter.index_x(), iter.index_y())) { | 287 if (RemoveTileAt(iter.index_x(), iter.index_y())) { |
| 288 if (recreate_tiles) | 288 if (recreate_tiles) |
| 289 new_tile_keys.push_back(iter.index()); | 289 new_tile_keys.push_back(TileMapKey(iter.index())); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 for (const auto& key : new_tile_keys) | 294 for (const auto& key : new_tile_keys) |
| 295 CreateTile(key.first, key.second); | 295 CreateTile(key.index_x, key.index_y); |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { | 298 bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { |
| 299 // Active tree should always create a tile. The reason for this is that active | 299 // Active tree should always create a tile. The reason for this is that active |
| 300 // tree represents content that we draw on screen, which means that whenever | 300 // tree represents content that we draw on screen, which means that whenever |
| 301 // we check whether a tile should exist somewhere, the answer is yes. This | 301 // we check whether a tile should exist somewhere, the answer is yes. This |
| 302 // doesn't mean it will actually be created (if raster source doesn't cover | 302 // doesn't mean it will actually be created (if raster source doesn't cover |
| 303 // the tile for instance). Pending tree, on the other hand, should only be | 303 // the tile for instance). Pending tree, on the other hand, should only be |
| 304 // creating tiles that are different from the current active tree, which is | 304 // creating tiles that are different from the current active tree, which is |
| 305 // represented by the logic in the rest of the function. | 305 // represented by the logic in the rest of the function. |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 new_live_tiles_rect); | 651 new_live_tiles_rect); |
| 652 iter; ++iter) { | 652 iter; ++iter) { |
| 653 RemoveTileAt(iter.index_x(), iter.index_y()); | 653 RemoveTileAt(iter.index_x(), iter.index_y()); |
| 654 } | 654 } |
| 655 | 655 |
| 656 // Iterate to allocate new tiles for all regions with newly exposed area. | 656 // Iterate to allocate new tiles for all regions with newly exposed area. |
| 657 for (TilingData::DifferenceIterator iter(&tiling_data_, new_live_tiles_rect, | 657 for (TilingData::DifferenceIterator iter(&tiling_data_, new_live_tiles_rect, |
| 658 live_tiles_rect_); | 658 live_tiles_rect_); |
| 659 iter; ++iter) { | 659 iter; ++iter) { |
| 660 TileMapKey key(iter.index()); | 660 TileMapKey key(iter.index()); |
| 661 if (ShouldCreateTileAt(key.first, key.second)) | 661 if (ShouldCreateTileAt(key.index_x, key.index_y)) |
| 662 CreateTile(key.first, key.second); | 662 CreateTile(key.index_x, key.index_y); |
| 663 } | 663 } |
| 664 | 664 |
| 665 live_tiles_rect_ = new_live_tiles_rect; | 665 live_tiles_rect_ = new_live_tiles_rect; |
| 666 VerifyLiveTilesRect(false); | 666 VerifyLiveTilesRect(false); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void PictureLayerTiling::VerifyLiveTilesRect(bool is_on_recycle_tree) const { | 669 void PictureLayerTiling::VerifyLiveTilesRect(bool is_on_recycle_tree) const { |
| 670 #if DCHECK_IS_ON() | 670 #if DCHECK_IS_ON() |
| 671 for (auto it = tiles_.begin(); it != tiles_.end(); ++it) { | 671 for (auto it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 672 if (!it->second) | 672 if (!it->second) |
| 673 continue; | 673 continue; |
| 674 DCHECK(it->first.first < tiling_data_.num_tiles_x()) | 674 TileMapKey key = it->first; |
| 675 << this << " " << it->first.first << "," << it->first.second | 675 DCHECK(key.index_x < tiling_data_.num_tiles_x()) |
| 676 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " | 676 << this << " " << key.index_x << "," << key.index_y << " num_tiles_x " |
| 677 << tiling_data_.num_tiles_x() << " live_tiles_rect " |
| 677 << live_tiles_rect_.ToString(); | 678 << live_tiles_rect_.ToString(); |
| 678 DCHECK(it->first.second < tiling_data_.num_tiles_y()) | 679 DCHECK(key.index_y < tiling_data_.num_tiles_y()) |
| 679 << this << " " << it->first.first << "," << it->first.second | 680 << this << " " << key.index_x << "," << key.index_y << " num_tiles_y " |
| 680 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " | 681 << tiling_data_.num_tiles_y() << " live_tiles_rect " |
| 681 << live_tiles_rect_.ToString(); | 682 << live_tiles_rect_.ToString(); |
| 682 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) | 683 DCHECK(tiling_data_.TileBounds(key.index_x, key.index_y) |
| 683 .Intersects(live_tiles_rect_)) | 684 .Intersects(live_tiles_rect_)) |
| 684 << this << " " << it->first.first << "," << it->first.second | 685 << this << " " << key.index_x << "," << key.index_y << " tile bounds " |
| 685 << " tile bounds " | 686 << tiling_data_.TileBounds(key.index_x, key.index_y).ToString() |
| 686 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() | |
| 687 << " live_tiles_rect " << live_tiles_rect_.ToString(); | 687 << " live_tiles_rect " << live_tiles_rect_.ToString(); |
| 688 } | 688 } |
| 689 #endif | 689 #endif |
| 690 } | 690 } |
| 691 | 691 |
| 692 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { | 692 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { |
| 693 // If this tile is not occluded on this tree, then it is not occluded. | 693 // If this tile is not occluded on this tree, then it is not occluded. |
| 694 if (!IsTileOccludedOnCurrentTree(tile)) | 694 if (!IsTileOccludedOnCurrentTree(tile)) |
| 695 return false; | 695 return false; |
| 696 | 696 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 break; | 1071 break; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 gfx::Rect result(origin_x, origin_y, width, height); | 1074 gfx::Rect result(origin_x, origin_y, width, height); |
| 1075 if (cache) | 1075 if (cache) |
| 1076 cache->previous_result = result; | 1076 cache->previous_result = result; |
| 1077 return result; | 1077 return result; |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 } // namespace cc | 1080 } // namespace cc |
| OLD | NEW |