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 it->second.get()->SetPriority(client_->GetTree(), TilePriority()); | |
97 } | 99 } |
98 | 100 |
99 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 101 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
100 client_ = client; | 102 client_ = client; |
101 } | 103 } |
102 | 104 |
103 Tile* PictureLayerTiling::CreateTile(int i, | 105 Tile* PictureLayerTiling::CreateTile(int i, |
104 int j, | 106 int j, |
105 const PictureLayerTiling* twin_tiling) { | 107 const PictureLayerTiling* twin_tiling) { |
106 TileMapKey key(i, j); | 108 TileMapKey key(i, j); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 continue; | 209 continue; |
208 bool include_borders = true; | 210 bool include_borders = true; |
209 for (TilingData::Iterator iter( | 211 for (TilingData::Iterator iter( |
210 &tiling_data_, content_rect, include_borders); | 212 &tiling_data_, content_rect, include_borders); |
211 iter; | 213 iter; |
212 ++iter) { | 214 ++iter) { |
213 TileMapKey key(iter.index()); | 215 TileMapKey key(iter.index()); |
214 TileMap::iterator find = tiles_.find(key); | 216 TileMap::iterator find = tiles_.find(key); |
215 if (find == tiles_.end()) | 217 if (find == tiles_.end()) |
216 continue; | 218 continue; |
219 | |
220 // Reset priority as tile is ref-counted and might still be used | |
221 // even though we no longer hold a reference to it here anymore. | |
222 find->second.get()->SetPriority(client_->GetTree(), TilePriority()); | |
reveman
2014/07/25 17:00:54
This comment is relevant not just here but in all
sohanjg
2014/07/26 09:36:01
I have added the comment in all the places for now
reveman
2014/07/28 02:24:35
I don't think that makes sense as a follow up. Ple
sohanjg
2014/07/28 10:10:19
Done.
| |
223 | |
217 tiles_.erase(find); | 224 tiles_.erase(find); |
218 new_tile_keys.push_back(key); | 225 new_tile_keys.push_back(key); |
219 } | 226 } |
220 } | 227 } |
221 | 228 |
222 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { | 229 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
223 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 230 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 | 231 // 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. | 232 // we have to make our own tile here. |
226 const PictureLayerTiling* twin_tiling = NULL; | 233 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. | 598 // Iterate to delete all tiles outside of our new live_tiles rect. |
592 for (TilingData::DifferenceIterator iter(&tiling_data_, | 599 for (TilingData::DifferenceIterator iter(&tiling_data_, |
593 live_tiles_rect_, | 600 live_tiles_rect_, |
594 new_live_tiles_rect); | 601 new_live_tiles_rect); |
595 iter; | 602 iter; |
596 ++iter) { | 603 ++iter) { |
597 TileMapKey key(iter.index()); | 604 TileMapKey key(iter.index()); |
598 TileMap::iterator found = tiles_.find(key); | 605 TileMap::iterator found = tiles_.find(key); |
599 // If the tile was outside of the recorded region, it won't exist even | 606 // If the tile was outside of the recorded region, it won't exist even |
600 // though it was in the live rect. | 607 // though it was in the live rect. |
601 if (found != tiles_.end()) | 608 if (found != tiles_.end()) { |
609 found->second.get()->SetPriority(client_->GetTree(), TilePriority()); | |
602 tiles_.erase(found); | 610 tiles_.erase(found); |
611 } | |
603 } | 612 } |
604 | 613 |
605 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 614 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
606 | 615 |
607 // Iterate to allocate new tiles for all regions with newly exposed area. | 616 // Iterate to allocate new tiles for all regions with newly exposed area. |
608 for (TilingData::DifferenceIterator iter(&tiling_data_, | 617 for (TilingData::DifferenceIterator iter(&tiling_data_, |
609 new_live_tiles_rect, | 618 new_live_tiles_rect, |
610 live_tiles_rect_); | 619 live_tiles_rect_); |
611 iter; | 620 iter; |
612 ++iter) { | 621 ++iter) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 996 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
988 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 997 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
989 is_valid_ = true; | 998 is_valid_ = true; |
990 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 999 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
991 !(*tile_iterator_)->HasResources()) { | 1000 !(*tile_iterator_)->HasResources()) { |
992 ++(*this); | 1001 ++(*this); |
993 } | 1002 } |
994 } | 1003 } |
995 | 1004 |
996 } // namespace cc | 1005 } // namespace cc |
OLD | NEW |