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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Reset(); | 161 Reset(); |
162 } else { | 162 } else { |
163 Invalidate(layer_invalidation); | 163 Invalidate(layer_invalidation); |
164 } | 164 } |
165 | 165 |
166 PicturePileImpl* pile = client_->GetPile(); | 166 PicturePileImpl* pile = client_->GetPile(); |
167 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 167 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
168 it->second->set_picture_pile(pile); | 168 it->second->set_picture_pile(pile); |
169 } | 169 } |
170 | 170 |
| 171 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { |
| 172 bool recreate_invalidated_tiles = false; |
| 173 DoInvalidate(layer_region, recreate_invalidated_tiles); |
| 174 } |
| 175 |
171 void PictureLayerTiling::Invalidate(const Region& layer_region) { | 176 void PictureLayerTiling::Invalidate(const Region& layer_region) { |
| 177 bool recreate_invalidated_tiles = true; |
| 178 DoInvalidate(layer_region, recreate_invalidated_tiles); |
| 179 } |
| 180 |
| 181 void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
| 182 bool recreate_invalidated_tiles) { |
172 std::vector<TileMapKey> new_tile_keys; | 183 std::vector<TileMapKey> new_tile_keys; |
173 gfx::Rect expanded_live_tiles_rect = | 184 gfx::Rect expanded_live_tiles_rect = |
174 tiling_data_.ExpandRectIgnoringBordersToTileBoundsWithBorders( | 185 tiling_data_.ExpandRectIgnoringBordersToTileBoundsWithBorders( |
175 live_tiles_rect_); | 186 live_tiles_rect_); |
176 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | 187 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { |
177 gfx::Rect layer_rect = iter.rect(); | 188 gfx::Rect layer_rect = iter.rect(); |
178 gfx::Rect content_rect = | 189 gfx::Rect content_rect = |
179 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 190 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
180 // Avoid needless work by not bothering to invalidate where there aren't | 191 // Avoid needless work by not bothering to invalidate where there aren't |
181 // tiles. | 192 // tiles. |
182 content_rect.Intersect(expanded_live_tiles_rect); | 193 content_rect.Intersect(expanded_live_tiles_rect); |
183 if (content_rect.IsEmpty()) | 194 if (content_rect.IsEmpty()) |
184 continue; | 195 continue; |
185 bool include_borders = true; | 196 bool include_borders = true; |
186 for (TilingData::Iterator iter( | 197 for (TilingData::Iterator iter( |
187 &tiling_data_, content_rect, include_borders); | 198 &tiling_data_, content_rect, include_borders); |
188 iter; | 199 iter; |
189 ++iter) { | 200 ++iter) { |
190 TileMapKey key(iter.index()); | 201 TileMapKey key(iter.index()); |
191 TileMap::iterator find = tiles_.find(key); | 202 TileMap::iterator find = tiles_.find(key); |
192 if (find == tiles_.end()) | 203 if (find == tiles_.end()) |
193 continue; | 204 continue; |
194 tiles_.erase(find); | 205 tiles_.erase(find); |
195 new_tile_keys.push_back(key); | 206 new_tile_keys.push_back(key); |
196 } | 207 } |
197 } | 208 } |
198 | 209 |
199 if (!new_tile_keys.empty()) { | 210 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
200 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
201 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 211 for (size_t i = 0; i < new_tile_keys.size(); ++i) { |
202 // Don't try to share a tile with the twin layer, it's been invalidated so | 212 // Don't try to share a tile with the twin layer, it's been invalidated so |
203 // we have to make our own tile here. | 213 // we have to make our own tile here. |
204 // TODO(danakj): Because we have two frames of invalidation during sync | 214 const PictureLayerTiling* twin_tiling = NULL; |
205 // this isn't always true. When sync is gone we can do this again. | |
206 // PictureLayerTiling* twin_tiling = NULL; | |
207 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); | 215 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); |
208 } | 216 } |
209 } | 217 } |
210 } | 218 } |
211 | 219 |
212 PictureLayerTiling::CoverageIterator::CoverageIterator() | 220 PictureLayerTiling::CoverageIterator::CoverageIterator() |
213 : tiling_(NULL), | 221 : tiling_(NULL), |
214 current_tile_(NULL), | 222 current_tile_(NULL), |
215 tile_i_(0), | 223 tile_i_(0), |
216 tile_j_(0), | 224 tile_j_(0), |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 975 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
968 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 976 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
969 is_valid_ = true; | 977 is_valid_ = true; |
970 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 978 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
971 !(*tile_iterator_)->HasResources()) { | 979 !(*tile_iterator_)->HasResources()) { |
972 ++(*this); | 980 ++(*this); |
973 } | 981 } |
974 } | 982 } |
975 | 983 |
976 } // namespace cc | 984 } // namespace cc |
OLD | NEW |