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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << | 87 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << |
88 "Tiling created with scale too small as contents become empty." << | 88 "Tiling created with scale too small as contents become empty." << |
89 " Layer bounds: " << layer_bounds.ToString() << | 89 " Layer bounds: " << layer_bounds.ToString() << |
90 " Contents scale: " << contents_scale; | 90 " Contents scale: " << contents_scale; |
91 | 91 |
92 tiling_data_.SetTilingSize(content_bounds); | 92 tiling_data_.SetTilingSize(content_bounds); |
93 tiling_data_.SetMaxTextureSize(tile_size); | 93 tiling_data_.SetMaxTextureSize(tile_size); |
94 } | 94 } |
95 | 95 |
96 PictureLayerTiling::~PictureLayerTiling() { | 96 PictureLayerTiling::~PictureLayerTiling() { |
97 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
98 Tile* tile = it->second.get(); | |
99 tile->SetPriority(ACTIVE_TREE, TilePriority()); | |
100 tile->SetPriority(PENDING_TREE, TilePriority()); | |
reveman
2014/07/24 13:36:24
I don't think you can reset both pending and activ
sohanjg
2014/07/24 15:01:55
If we reset the priority of only the pending tree
vmpstr
2014/07/24 16:19:21
Since at this point the tile can be shared on both
sohanjg
2014/07/25 09:38:26
Done.
| |
101 } | |
97 } | 102 } |
98 | 103 |
99 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 104 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
100 client_ = client; | 105 client_ = client; |
101 } | 106 } |
102 | 107 |
103 Tile* PictureLayerTiling::CreateTile(int i, | 108 Tile* PictureLayerTiling::CreateTile(int i, |
104 int j, | 109 int j, |
105 const PictureLayerTiling* twin_tiling) { | 110 const PictureLayerTiling* twin_tiling) { |
106 TileMapKey key(i, j); | 111 TileMapKey key(i, j); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 continue; | 212 continue; |
208 bool include_borders = true; | 213 bool include_borders = true; |
209 for (TilingData::Iterator iter( | 214 for (TilingData::Iterator iter( |
210 &tiling_data_, content_rect, include_borders); | 215 &tiling_data_, content_rect, include_borders); |
211 iter; | 216 iter; |
212 ++iter) { | 217 ++iter) { |
213 TileMapKey key(iter.index()); | 218 TileMapKey key(iter.index()); |
214 TileMap::iterator find = tiles_.find(key); | 219 TileMap::iterator find = tiles_.find(key); |
215 if (find == tiles_.end()) | 220 if (find == tiles_.end()) |
216 continue; | 221 continue; |
222 | |
223 // Reset priority as tile is ref-counted and might still be used | |
224 // even though we no longer hold a reference to it here anymore. | |
225 Tile* tile = find->second.get(); | |
226 tile->SetPriority(ACTIVE_TREE, TilePriority()); | |
227 tile->SetPriority(PENDING_TREE, TilePriority()); | |
reveman
2014/07/24 13:36:24
same here. resetting both active and pending prior
sohanjg
2014/07/25 09:38:26
Done.
| |
228 | |
217 tiles_.erase(find); | 229 tiles_.erase(find); |
218 new_tile_keys.push_back(key); | 230 new_tile_keys.push_back(key); |
219 } | 231 } |
220 } | 232 } |
221 | 233 |
222 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { | 234 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
223 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 235 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 | 236 // 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. | 237 // we have to make our own tile here. |
226 const PictureLayerTiling* twin_tiling = NULL; | 238 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. | 603 // Iterate to delete all tiles outside of our new live_tiles rect. |
592 for (TilingData::DifferenceIterator iter(&tiling_data_, | 604 for (TilingData::DifferenceIterator iter(&tiling_data_, |
593 live_tiles_rect_, | 605 live_tiles_rect_, |
594 new_live_tiles_rect); | 606 new_live_tiles_rect); |
595 iter; | 607 iter; |
596 ++iter) { | 608 ++iter) { |
597 TileMapKey key(iter.index()); | 609 TileMapKey key(iter.index()); |
598 TileMap::iterator found = tiles_.find(key); | 610 TileMap::iterator found = tiles_.find(key); |
599 // If the tile was outside of the recorded region, it won't exist even | 611 // If the tile was outside of the recorded region, it won't exist even |
600 // though it was in the live rect. | 612 // though it was in the live rect. |
601 if (found != tiles_.end()) | 613 if (found != tiles_.end()) { |
614 Tile* tile = found->second.get(); | |
615 tile->SetPriority(ACTIVE_TREE, TilePriority()); | |
616 tile->SetPriority(PENDING_TREE, TilePriority()); | |
reveman
2014/07/24 13:36:24
and here. resetting both active and pending priori
sohanjg
2014/07/25 09:38:26
Done.
| |
602 tiles_.erase(found); | 617 tiles_.erase(found); |
618 } | |
603 } | 619 } |
604 | 620 |
605 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 621 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
606 | 622 |
607 // Iterate to allocate new tiles for all regions with newly exposed area. | 623 // Iterate to allocate new tiles for all regions with newly exposed area. |
608 for (TilingData::DifferenceIterator iter(&tiling_data_, | 624 for (TilingData::DifferenceIterator iter(&tiling_data_, |
609 new_live_tiles_rect, | 625 new_live_tiles_rect, |
610 live_tiles_rect_); | 626 live_tiles_rect_); |
611 iter; | 627 iter; |
612 ++iter) { | 628 ++iter) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 1003 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
988 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 1004 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
989 is_valid_ = true; | 1005 is_valid_ = true; |
990 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 1006 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
991 !(*tile_iterator_)->HasResources()) { | 1007 !(*tile_iterator_)->HasResources()) { |
992 ++(*this); | 1008 ++(*this); |
993 } | 1009 } |
994 } | 1010 } |
995 | 1011 |
996 } // namespace cc | 1012 } // namespace cc |
OLD | NEW |