Chromium Code Reviews| 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 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 if (a_is_occluded != b_is_occluded) | 50 if (a_is_occluded != b_is_occluded) |
| 51 return a_is_occluded; | 51 return a_is_occluded; |
| 52 | 52 |
| 53 // Or if a is farther away from visible. | 53 // Or if a is farther away from visible. |
| 54 return a_priority.distance_to_visible > b_priority.distance_to_visible; | 54 return a_priority.distance_to_visible > b_priority.distance_to_visible; |
| 55 } | 55 } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 TreePriority tree_priority_; | 58 TreePriority tree_priority_; |
| 59 }; | 59 }; |
| 60 | |
| 61 // Reset priority as tile is ref-counted and might still be used | |
| 62 // even though we no longer hold a reference to it here anymore. | |
|
reveman
2014/07/28 15:50:53
Please move this comment just above "tile->SetPrio
sohanjg
2014/07/30 11:12:57
Done.
| |
| 63 void ResetPriority(Tile* tile, WhichTree tree) { | |
|
reveman
2014/07/28 15:50:53
I would prefer if you named this "ReleaseTile" and
sohanjg
2014/07/30 11:12:57
Done.
| |
| 64 DCHECK(tile); | |
|
reveman
2014/07/28 15:50:53
Remove this. It's awkward to not be able to assume
sohanjg
2014/07/30 11:12:57
Acknowledged.
| |
| 65 tile->SetPriority(tree, TilePriority()); | |
| 66 } | |
| 67 | |
| 60 } // namespace | 68 } // namespace |
| 61 | 69 |
| 62 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 70 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 63 float contents_scale, | 71 float contents_scale, |
| 64 const gfx::Size& layer_bounds, | 72 const gfx::Size& layer_bounds, |
| 65 PictureLayerTilingClient* client) { | 73 PictureLayerTilingClient* client) { |
| 66 return make_scoped_ptr(new PictureLayerTiling(contents_scale, | 74 return make_scoped_ptr(new PictureLayerTiling(contents_scale, |
| 67 layer_bounds, | 75 layer_bounds, |
| 68 client)); | 76 client)); |
| 69 } | 77 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 87 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << | 95 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << |
| 88 "Tiling created with scale too small as contents become empty." << | 96 "Tiling created with scale too small as contents become empty." << |
| 89 " Layer bounds: " << layer_bounds.ToString() << | 97 " Layer bounds: " << layer_bounds.ToString() << |
| 90 " Contents scale: " << contents_scale; | 98 " Contents scale: " << contents_scale; |
| 91 | 99 |
| 92 tiling_data_.SetTilingSize(content_bounds); | 100 tiling_data_.SetTilingSize(content_bounds); |
| 93 tiling_data_.SetMaxTextureSize(tile_size); | 101 tiling_data_.SetMaxTextureSize(tile_size); |
| 94 } | 102 } |
| 95 | 103 |
| 96 PictureLayerTiling::~PictureLayerTiling() { | 104 PictureLayerTiling::~PictureLayerTiling() { |
| 105 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | |
| 106 ResetPriority(it->second.get(), client_->GetTree()); | |
| 97 } | 107 } |
| 98 | 108 |
| 99 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 109 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
| 100 client_ = client; | 110 client_ = client; |
| 101 } | 111 } |
| 102 | 112 |
| 103 Tile* PictureLayerTiling::CreateTile(int i, | 113 Tile* PictureLayerTiling::CreateTile(int i, |
| 104 int j, | 114 int j, |
| 105 const PictureLayerTiling* twin_tiling) { | 115 const PictureLayerTiling* twin_tiling) { |
| 106 TileMapKey key(i, j); | 116 TileMapKey key(i, j); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 continue; | 217 continue; |
| 208 bool include_borders = true; | 218 bool include_borders = true; |
| 209 for (TilingData::Iterator iter( | 219 for (TilingData::Iterator iter( |
| 210 &tiling_data_, content_rect, include_borders); | 220 &tiling_data_, content_rect, include_borders); |
| 211 iter; | 221 iter; |
| 212 ++iter) { | 222 ++iter) { |
| 213 TileMapKey key(iter.index()); | 223 TileMapKey key(iter.index()); |
| 214 TileMap::iterator find = tiles_.find(key); | 224 TileMap::iterator find = tiles_.find(key); |
| 215 if (find == tiles_.end()) | 225 if (find == tiles_.end()) |
| 216 continue; | 226 continue; |
| 227 | |
| 228 ResetPriority(find->second.get(), client_->GetTree()); | |
| 229 | |
| 217 tiles_.erase(find); | 230 tiles_.erase(find); |
| 218 new_tile_keys.push_back(key); | 231 new_tile_keys.push_back(key); |
| 219 } | 232 } |
| 220 } | 233 } |
| 221 | 234 |
| 222 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { | 235 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
| 223 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 236 for (size_t i = 0; i < new_tile_keys.size(); ++i) { |
| 224 // Don't try to share a tile with the twin layer, it's been invalidated so | 237 // Don't try to share a tile with the twin layer, it's been invalidated so |
| 225 // we have to make our own tile here. | 238 // we have to make our own tile here. |
| 226 const PictureLayerTiling* twin_tiling = NULL; | 239 const PictureLayerTiling* twin_tiling = NULL; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 // Iterate to delete all tiles outside of our new live_tiles rect. | 604 // Iterate to delete all tiles outside of our new live_tiles rect. |
| 592 for (TilingData::DifferenceIterator iter(&tiling_data_, | 605 for (TilingData::DifferenceIterator iter(&tiling_data_, |
| 593 live_tiles_rect_, | 606 live_tiles_rect_, |
| 594 new_live_tiles_rect); | 607 new_live_tiles_rect); |
| 595 iter; | 608 iter; |
| 596 ++iter) { | 609 ++iter) { |
| 597 TileMapKey key(iter.index()); | 610 TileMapKey key(iter.index()); |
| 598 TileMap::iterator found = tiles_.find(key); | 611 TileMap::iterator found = tiles_.find(key); |
| 599 // If the tile was outside of the recorded region, it won't exist even | 612 // If the tile was outside of the recorded region, it won't exist even |
| 600 // though it was in the live rect. | 613 // though it was in the live rect. |
| 601 if (found != tiles_.end()) | 614 if (found != tiles_.end()) { |
| 615 ResetPriority(found->second.get(), client_->GetTree()); | |
| 602 tiles_.erase(found); | 616 tiles_.erase(found); |
| 617 } | |
| 603 } | 618 } |
| 604 | 619 |
| 605 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 620 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
| 606 | 621 |
| 607 // Iterate to allocate new tiles for all regions with newly exposed area. | 622 // Iterate to allocate new tiles for all regions with newly exposed area. |
| 608 for (TilingData::DifferenceIterator iter(&tiling_data_, | 623 for (TilingData::DifferenceIterator iter(&tiling_data_, |
| 609 new_live_tiles_rect, | 624 new_live_tiles_rect, |
| 610 live_tiles_rect_); | 625 live_tiles_rect_); |
| 611 iter; | 626 iter; |
| 612 ++iter) { | 627 ++iter) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 1002 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
| 988 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 1003 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
| 989 is_valid_ = true; | 1004 is_valid_ = true; |
| 990 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 1005 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
| 991 !(*tile_iterator_)->HasResources()) { | 1006 !(*tile_iterator_)->HasResources()) { |
| 992 ++(*this); | 1007 ++(*this); |
| 993 } | 1008 } |
| 994 } | 1009 } |
| 995 | 1010 |
| 996 } // namespace cc | 1011 } // namespace cc |
| OLD | NEW |