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 #include <set> | 10 #include <set> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 tiling_data_.SetMaxTextureSize(tile_size); | 112 tiling_data_.SetMaxTextureSize(tile_size); |
113 } | 113 } |
114 | 114 |
115 PictureLayerTiling::~PictureLayerTiling() { | 115 PictureLayerTiling::~PictureLayerTiling() { |
116 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 116 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
117 it->second->set_shared(false); | 117 it->second->set_shared(false); |
118 } | 118 } |
119 | 119 |
120 Tile* PictureLayerTiling::CreateTile(int i, | 120 Tile* PictureLayerTiling::CreateTile(int i, |
121 int j, | 121 int j, |
122 const PictureLayerTiling* twin_tiling) { | 122 const PictureLayerTiling* twin_tiling, |
123 PictureLayerTiling* recycled_twin) { | |
124 // Can't have both a (pending or active) twin and a recycled twin tiling. | |
125 DCHECK_IMPLIES(twin_tiling, !recycled_twin); | |
126 DCHECK_IMPLIES(recycled_twin, !twin_tiling); | |
123 TileMapKey key(i, j); | 127 TileMapKey key(i, j); |
124 DCHECK(tiles_.find(key) == tiles_.end()); | 128 DCHECK(tiles_.find(key) == tiles_.end()); |
125 | 129 |
126 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | 130 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); |
127 gfx::Rect tile_rect = paint_rect; | 131 gfx::Rect tile_rect = paint_rect; |
128 tile_rect.set_size(tiling_data_.max_texture_size()); | 132 tile_rect.set_size(tiling_data_.max_texture_size()); |
129 | 133 |
130 // Check our twin for a valid tile. | 134 // Check our twin for a valid tile. |
131 if (twin_tiling && | 135 if (twin_tiling && |
132 tiling_data_.max_texture_size() == | 136 tiling_data_.max_texture_size() == |
(...skipping 12 matching lines...) Expand all Loading... | |
145 } | 149 } |
146 } | 150 } |
147 } | 151 } |
148 | 152 |
149 // Create a new tile because our twin didn't have a valid one. | 153 // Create a new tile because our twin didn't have a valid one. |
150 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 154 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
151 if (tile.get()) { | 155 if (tile.get()) { |
152 DCHECK(!tile->is_shared()); | 156 DCHECK(!tile->is_shared()); |
153 tile->set_tiling_index(i, j); | 157 tile->set_tiling_index(i, j); |
154 tiles_[key] = tile; | 158 tiles_[key] = tile; |
159 | |
160 if (recycled_twin) { | |
161 DCHECK(recycled_twin->tiles_.find(key) == recycled_twin->tiles_.end()); | |
162 // Do what recycled_twin->CreateTile() would do. | |
163 tile->set_shared(true); | |
164 recycled_twin->tiles_[key] = tile; | |
165 } | |
155 } | 166 } |
156 eviction_tiles_cache_valid_ = false; | 167 eviction_tiles_cache_valid_ = false; |
157 return tile.get(); | 168 return tile.get(); |
158 } | 169 } |
159 | 170 |
160 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 171 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
161 const PictureLayerTiling* twin_tiling = | 172 const PictureLayerTiling* twin_tiling = |
162 client_->GetPendingOrActiveTwinTiling(this); | 173 client_->GetPendingOrActiveTwinTiling(this); |
174 // There is no recycled twin during commit from the main thread which is when | |
175 // this occurs. | |
176 PictureLayerTiling* null_recycled_twin = nullptr; | |
177 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
163 bool include_borders = false; | 178 bool include_borders = false; |
164 for (TilingData::Iterator iter( | 179 for (TilingData::Iterator iter( |
165 &tiling_data_, live_tiles_rect_, include_borders); | 180 &tiling_data_, live_tiles_rect_, include_borders); |
166 iter; | 181 iter; |
167 ++iter) { | 182 ++iter) { |
168 TileMapKey key = iter.index(); | 183 TileMapKey key = iter.index(); |
169 TileMap::iterator find = tiles_.find(key); | 184 TileMap::iterator find = tiles_.find(key); |
170 if (find != tiles_.end()) | 185 if (find != tiles_.end()) |
171 continue; | 186 continue; |
172 CreateTile(key.first, key.second, twin_tiling); | 187 CreateTile(key.first, key.second, twin_tiling, null_recycled_twin); |
173 } | 188 } |
174 | 189 |
175 VerifyLiveTilesRect(); | 190 VerifyLiveTilesRect(false); |
176 } | 191 } |
177 | 192 |
178 void PictureLayerTiling::CloneTilesAndPropertiesFrom( | 193 void PictureLayerTiling::CloneTilesAndPropertiesFrom( |
179 const PictureLayerTiling& twin_tiling) { | 194 const PictureLayerTiling& twin_tiling) { |
180 DCHECK_EQ(&twin_tiling, client_->GetPendingOrActiveTwinTiling(this)); | 195 DCHECK_EQ(&twin_tiling, client_->GetPendingOrActiveTwinTiling(this)); |
181 | 196 |
182 Resize(twin_tiling.layer_bounds_); | 197 Resize(twin_tiling.layer_bounds_); |
183 DCHECK_EQ(twin_tiling.contents_scale_, contents_scale_); | 198 DCHECK_EQ(twin_tiling.contents_scale_, contents_scale_); |
184 DCHECK_EQ(twin_tiling.layer_bounds().ToString(), layer_bounds().ToString()); | 199 DCHECK_EQ(twin_tiling.layer_bounds().ToString(), layer_bounds().ToString()); |
185 DCHECK_EQ(twin_tiling.tile_size().ToString(), tile_size().ToString()); | 200 DCHECK_EQ(twin_tiling.tile_size().ToString(), tile_size().ToString()); |
186 | 201 |
187 resolution_ = twin_tiling.resolution_; | 202 resolution_ = twin_tiling.resolution_; |
188 | 203 |
189 SetLiveTilesRect(twin_tiling.live_tiles_rect()); | 204 SetLiveTilesRect(twin_tiling.live_tiles_rect()); |
190 | 205 |
191 // Recreate unshared tiles. | 206 // Recreate unshared tiles. |
192 std::vector<TileMapKey> to_remove; | 207 std::vector<TileMapKey> to_remove; |
193 for (const auto& tile_map_pair : tiles_) { | 208 for (const auto& tile_map_pair : tiles_) { |
194 TileMapKey key = tile_map_pair.first; | 209 TileMapKey key = tile_map_pair.first; |
195 Tile* tile = tile_map_pair.second.get(); | 210 Tile* tile = tile_map_pair.second.get(); |
196 if (!tile->is_shared()) | 211 if (!tile->is_shared()) |
197 to_remove.push_back(key); | 212 to_remove.push_back(key); |
198 } | 213 } |
199 // The recycled twin does not exist since there is a pending twin (which is | 214 // The recycled twin does not exist since there is a pending twin (which is |
200 // |twin_tiling|). | 215 // |twin_tiling|). |
201 PictureLayerTiling* null_recycled_twin = nullptr; | 216 PictureLayerTiling* null_recycled_twin = nullptr; |
202 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | 217 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); |
203 for (const auto& key : to_remove) { | 218 for (const auto& key : to_remove) { |
204 RemoveTileAt(key.first, key.second, null_recycled_twin); | 219 RemoveTileAt(key.first, key.second, null_recycled_twin); |
205 CreateTile(key.first, key.second, &twin_tiling); | 220 CreateTile(key.first, key.second, &twin_tiling, null_recycled_twin); |
221 } | |
222 | |
223 // Create any missing tiles from the |twin_tiling|. | |
224 for (const auto& tile_map_pair : twin_tiling.tiles_) { | |
danakj
2014/12/30 16:44:58
1 here: We walk all pending tiles, and if they are
danakj
2014/12/30 16:46:28
Or maybe since we know the tile will be shared we
vmpstr
2014/12/30 17:16:55
You mean when we're creating the pending tile, if
danakj
2014/12/30 17:20:47
I mean like instead of
CreateTile(key, foo bar, t
vmpstr
2014/12/30 18:03:58
Oh I see, but still keep the loop here? That could
| |
225 TileMapKey key = tile_map_pair.first; | |
226 Tile* tile = tile_map_pair.second.get(); | |
227 if (!tile->is_shared()) | |
228 CreateTile(key.first, key.second, &twin_tiling, null_recycled_twin); | |
206 } | 229 } |
207 | 230 |
208 DCHECK_EQ(twin_tiling.tiles_.size(), tiles_.size()); | 231 DCHECK_EQ(twin_tiling.tiles_.size(), tiles_.size()); |
209 #if DCHECK_IS_ON | 232 #if DCHECK_IS_ON |
210 for (const auto& tile_map_pair : tiles_) | 233 for (const auto& tile_map_pair : tiles_) |
211 DCHECK(tile_map_pair.second->is_shared()); | 234 DCHECK(tile_map_pair.second->is_shared()); |
235 VerifyLiveTilesRect(false); | |
212 #endif | 236 #endif |
213 | 237 |
214 UpdateTilePriorityRects(twin_tiling.current_content_to_screen_scale_, | 238 UpdateTilePriorityRects(twin_tiling.current_content_to_screen_scale_, |
215 twin_tiling.current_visible_rect_, | 239 twin_tiling.current_visible_rect_, |
216 twin_tiling.current_skewport_rect_, | 240 twin_tiling.current_skewport_rect_, |
217 twin_tiling.current_soon_border_rect_, | 241 twin_tiling.current_soon_border_rect_, |
218 twin_tiling.current_eventually_rect_, | 242 twin_tiling.current_eventually_rect_, |
219 twin_tiling.current_occlusion_in_layer_space_); | 243 twin_tiling.current_occlusion_in_layer_space_); |
220 } | 244 } |
221 | 245 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 int after_bottom = -1; | 294 int after_bottom = -1; |
271 if (!live_tiles_rect_.IsEmpty()) { | 295 if (!live_tiles_rect_.IsEmpty()) { |
272 after_right = | 296 after_right = |
273 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); | 297 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); |
274 after_bottom = | 298 after_bottom = |
275 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); | 299 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); |
276 } | 300 } |
277 | 301 |
278 // There is no recycled twin since this is run on the pending tiling | 302 // There is no recycled twin since this is run on the pending tiling |
279 // during commit, and on the active tree during activate. | 303 // during commit, and on the active tree during activate. |
280 PictureLayerTiling* recycled_twin = NULL; | 304 PictureLayerTiling* null_recycled_twin = nullptr; |
281 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); | 305 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); |
282 | 306 |
283 // Drop tiles outside the new layer bounds if the layer shrank. | 307 // Drop tiles outside the new layer bounds if the layer shrank. |
284 for (int i = after_right + 1; i <= before_right; ++i) { | 308 for (int i = after_right + 1; i <= before_right; ++i) { |
285 for (int j = before_top; j <= before_bottom; ++j) | 309 for (int j = before_top; j <= before_bottom; ++j) |
286 RemoveTileAt(i, j, recycled_twin); | 310 RemoveTileAt(i, j, null_recycled_twin); |
287 } | 311 } |
288 for (int i = before_left; i <= after_right; ++i) { | 312 for (int i = before_left; i <= after_right; ++i) { |
289 for (int j = after_bottom + 1; j <= before_bottom; ++j) | 313 for (int j = after_bottom + 1; j <= before_bottom; ++j) |
290 RemoveTileAt(i, j, recycled_twin); | 314 RemoveTileAt(i, j, null_recycled_twin); |
291 } | 315 } |
292 | 316 |
293 // If the layer grew, the live_tiles_rect_ is not changed, but a new row | 317 // If the layer grew, the live_tiles_rect_ is not changed, but a new row |
294 // and/or column of tiles may now exist inside the same live_tiles_rect_. | 318 // and/or column of tiles may now exist inside the same live_tiles_rect_. |
295 const PictureLayerTiling* twin_tiling = | 319 const PictureLayerTiling* twin_tiling = |
296 client_->GetPendingOrActiveTwinTiling(this); | 320 client_->GetPendingOrActiveTwinTiling(this); |
297 if (after_right > before_right) { | 321 if (after_right > before_right) { |
298 DCHECK_EQ(after_right, before_right + 1); | 322 DCHECK_EQ(after_right, before_right + 1); |
299 for (int j = before_top; j <= after_bottom; ++j) | 323 for (int j = before_top; j <= after_bottom; ++j) |
300 CreateTile(after_right, j, twin_tiling); | 324 CreateTile(after_right, j, twin_tiling, null_recycled_twin); |
301 } | 325 } |
302 if (after_bottom > before_bottom) { | 326 if (after_bottom > before_bottom) { |
303 DCHECK_EQ(after_bottom, before_bottom + 1); | 327 DCHECK_EQ(after_bottom, before_bottom + 1); |
304 for (int i = before_left; i <= before_right; ++i) | 328 for (int i = before_left; i <= before_right; ++i) |
305 CreateTile(i, after_bottom, twin_tiling); | 329 CreateTile(i, after_bottom, twin_tiling, null_recycled_twin); |
306 } | 330 } |
307 } | 331 } |
308 | 332 |
309 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | 333 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { |
310 if (live_tiles_rect_.IsEmpty()) | 334 if (live_tiles_rect_.IsEmpty()) |
311 return; | 335 return; |
312 std::vector<TileMapKey> new_tile_keys; | 336 std::vector<TileMapKey> new_tile_keys; |
313 gfx::Rect expanded_live_tiles_rect = | 337 gfx::Rect expanded_live_tiles_rect = |
314 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); | 338 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
315 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); | 339 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
(...skipping 13 matching lines...) Expand all Loading... | |
329 continue; | 353 continue; |
330 // Since the content_rect includes border pixels already, don't include | 354 // Since the content_rect includes border pixels already, don't include |
331 // borders when iterating to avoid double counting them. | 355 // borders when iterating to avoid double counting them. |
332 bool include_borders = false; | 356 bool include_borders = false; |
333 for (TilingData::Iterator iter( | 357 for (TilingData::Iterator iter( |
334 &tiling_data_, content_rect, include_borders); | 358 &tiling_data_, content_rect, include_borders); |
335 iter; | 359 iter; |
336 ++iter) { | 360 ++iter) { |
337 // There is no recycled twin for the pending tree during commit, or for | 361 // There is no recycled twin for the pending tree during commit, or for |
338 // the active tree during activation. | 362 // the active tree during activation. |
339 PictureLayerTiling* null_recycled_twin = NULL; | 363 PictureLayerTiling* null_recycled_twin = nullptr; |
340 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | 364 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); |
341 if (RemoveTileAt(iter.index_x(), iter.index_y(), null_recycled_twin)) | 365 if (RemoveTileAt(iter.index_x(), iter.index_y(), null_recycled_twin)) |
342 new_tile_keys.push_back(iter.index()); | 366 new_tile_keys.push_back(iter.index()); |
343 } | 367 } |
344 } | 368 } |
345 | 369 |
346 if (!new_tile_keys.empty()) { | 370 if (!new_tile_keys.empty()) { |
347 // During commit from the main thread, invalidations can never be shared | 371 // During commit from the main thread, invalidations can never be shared |
348 // with the active tree since the active tree has different content there. | 372 // with the active tree since the active tree has different content there. |
349 const PictureLayerTiling* twin_tiling = nullptr; | 373 // And when invalidating an active-tree tiling, it means there was no |
374 // pending tiling to clone from. | |
375 const PictureLayerTiling* null_twin_tiling = nullptr; | |
376 PictureLayerTiling* null_recycled_twin = nullptr; | |
377 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
350 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 378 for (size_t i = 0; i < new_tile_keys.size(); ++i) { |
351 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); | 379 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, |
380 null_twin_tiling, null_recycled_twin); | |
352 } | 381 } |
353 } | 382 } |
354 } | 383 } |
355 | 384 |
356 void PictureLayerTiling::SetRasterSource( | 385 void PictureLayerTiling::SetRasterSource( |
357 scoped_refptr<RasterSource> raster_source) { | 386 scoped_refptr<RasterSource> raster_source) { |
358 // Shared (ie. non-invalidated) tiles on the pending tree are updated to use | 387 // Shared (ie. non-invalidated) tiles on the pending tree are updated to use |
359 // the new raster source. When this raster source is activated, the raster | 388 // the new raster source. When this raster source is activated, the raster |
360 // source will remain valid for shared tiles in the active tree. | 389 // source will remain valid for shared tiles in the active tree. |
361 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 390 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
362 it->second->set_raster_source(raster_source); | 391 it->second->set_raster_source(raster_source); |
363 VerifyLiveTilesRect(); | 392 VerifyLiveTilesRect(false); |
364 } | 393 } |
365 | 394 |
366 PictureLayerTiling::CoverageIterator::CoverageIterator() | 395 PictureLayerTiling::CoverageIterator::CoverageIterator() |
367 : tiling_(NULL), | 396 : tiling_(NULL), |
368 current_tile_(NULL), | 397 current_tile_(NULL), |
369 tile_i_(0), | 398 tile_i_(0), |
370 tile_j_(0), | 399 tile_j_(0), |
371 left_(0), | 400 left_(0), |
372 top_(0), | 401 top_(0), |
373 right_(-1), | 402 right_(-1), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 bool PictureLayerTiling::RemoveTileAt(int i, | 545 bool PictureLayerTiling::RemoveTileAt(int i, |
517 int j, | 546 int j, |
518 PictureLayerTiling* recycled_twin) { | 547 PictureLayerTiling* recycled_twin) { |
519 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); | 548 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); |
520 if (found == tiles_.end()) | 549 if (found == tiles_.end()) |
521 return false; | 550 return false; |
522 found->second->set_shared(false); | 551 found->second->set_shared(false); |
523 tiles_.erase(found); | 552 tiles_.erase(found); |
524 eviction_tiles_cache_valid_ = false; | 553 eviction_tiles_cache_valid_ = false; |
525 if (recycled_twin) { | 554 if (recycled_twin) { |
526 // Recycled twin does not also have a recycled twin, so pass NULL. | 555 // Recycled twin does not also have a recycled twin, so pass null. |
527 recycled_twin->RemoveTileAt(i, j, NULL); | 556 recycled_twin->RemoveTileAt(i, j, nullptr); |
528 } | 557 } |
529 return true; | 558 return true; |
530 } | 559 } |
531 | 560 |
532 void PictureLayerTiling::Reset() { | 561 void PictureLayerTiling::Reset() { |
533 live_tiles_rect_ = gfx::Rect(); | 562 live_tiles_rect_ = gfx::Rect(); |
534 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | 563 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
535 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 564 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
536 it->second->set_shared(false); | 565 it->second->set_shared(false); |
537 if (recycled_twin) | 566 if (recycled_twin) |
538 recycled_twin->RemoveTileAt(it->first.first, it->first.second, NULL); | 567 recycled_twin->RemoveTileAt(it->first.first, it->first.second, nullptr); |
539 } | 568 } |
540 tiles_.clear(); | 569 tiles_.clear(); |
541 eviction_tiles_cache_valid_ = false; | 570 eviction_tiles_cache_valid_ = false; |
542 } | 571 } |
543 | 572 |
544 gfx::Rect PictureLayerTiling::ComputeSkewport( | 573 gfx::Rect PictureLayerTiling::ComputeSkewport( |
545 double current_frame_time_in_seconds, | 574 double current_frame_time_in_seconds, |
546 const gfx::Rect& visible_rect_in_content_space) const { | 575 const gfx::Rect& visible_rect_in_content_space) const { |
547 gfx::Rect skewport = visible_rect_in_content_space; | 576 gfx::Rect skewport = visible_rect_in_content_space; |
548 if (last_impl_frame_time_in_seconds_ == 0.0) | 577 if (last_impl_frame_time_in_seconds_ == 0.0) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 | 700 |
672 void PictureLayerTiling::SetLiveTilesRect( | 701 void PictureLayerTiling::SetLiveTilesRect( |
673 const gfx::Rect& new_live_tiles_rect) { | 702 const gfx::Rect& new_live_tiles_rect) { |
674 DCHECK(new_live_tiles_rect.IsEmpty() || | 703 DCHECK(new_live_tiles_rect.IsEmpty() || |
675 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) | 704 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) |
676 << "tiling_size: " << tiling_size().ToString() | 705 << "tiling_size: " << tiling_size().ToString() |
677 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); | 706 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); |
678 if (live_tiles_rect_ == new_live_tiles_rect) | 707 if (live_tiles_rect_ == new_live_tiles_rect) |
679 return; | 708 return; |
680 | 709 |
710 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | |
711 | |
681 // Iterate to delete all tiles outside of our new live_tiles rect. | 712 // Iterate to delete all tiles outside of our new live_tiles rect. |
682 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | |
683 for (TilingData::DifferenceIterator iter(&tiling_data_, | 713 for (TilingData::DifferenceIterator iter(&tiling_data_, |
684 live_tiles_rect_, | 714 live_tiles_rect_, |
685 new_live_tiles_rect); | 715 new_live_tiles_rect); |
686 iter; | 716 iter; |
687 ++iter) { | 717 ++iter) { |
688 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); | 718 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); |
689 } | 719 } |
690 | 720 |
691 const PictureLayerTiling* twin_tiling = | 721 const PictureLayerTiling* twin_tiling = |
692 client_->GetPendingOrActiveTwinTiling(this); | 722 client_->GetPendingOrActiveTwinTiling(this); |
693 | 723 |
694 // Iterate to allocate new tiles for all regions with newly exposed area. | 724 // Iterate to allocate new tiles for all regions with newly exposed area. |
695 for (TilingData::DifferenceIterator iter(&tiling_data_, | 725 for (TilingData::DifferenceIterator iter(&tiling_data_, |
696 new_live_tiles_rect, | 726 new_live_tiles_rect, |
697 live_tiles_rect_); | 727 live_tiles_rect_); |
698 iter; | 728 iter; |
699 ++iter) { | 729 ++iter) { |
700 TileMapKey key(iter.index()); | 730 TileMapKey key(iter.index()); |
701 CreateTile(key.first, key.second, twin_tiling); | 731 CreateTile(key.first, key.second, twin_tiling, recycled_twin); |
danakj
2014/12/30 16:44:58
2 here: We create and add a tile to the recycled t
| |
702 } | 732 } |
703 | 733 |
704 live_tiles_rect_ = new_live_tiles_rect; | 734 live_tiles_rect_ = new_live_tiles_rect; |
705 VerifyLiveTilesRect(); | 735 VerifyLiveTilesRect(false); |
736 if (recycled_twin) { | |
737 recycled_twin->live_tiles_rect_ = live_tiles_rect_; | |
738 recycled_twin->VerifyLiveTilesRect(true); | |
739 } | |
706 } | 740 } |
707 | 741 |
708 void PictureLayerTiling::VerifyLiveTilesRect() { | 742 void PictureLayerTiling::VerifyLiveTilesRect(bool is_on_recycle_tree) const { |
vmpstr
2014/12/12 20:10:32
hah, nice.
| |
709 #if DCHECK_IS_ON | 743 #if DCHECK_IS_ON |
710 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 744 for (auto it = tiles_.begin(); it != tiles_.end(); ++it) { |
711 if (!it->second.get()) | 745 if (!it->second.get()) |
712 continue; | 746 continue; |
713 DCHECK(it->first.first < tiling_data_.num_tiles_x()) | 747 DCHECK(it->first.first < tiling_data_.num_tiles_x()) |
714 << this << " " << it->first.first << "," << it->first.second | 748 << this << " " << it->first.first << "," << it->first.second |
715 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " | 749 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " |
716 << live_tiles_rect_.ToString(); | 750 << live_tiles_rect_.ToString(); |
717 DCHECK(it->first.second < tiling_data_.num_tiles_y()) | 751 DCHECK(it->first.second < tiling_data_.num_tiles_y()) |
718 << this << " " << it->first.first << "," << it->first.second | 752 << this << " " << it->first.first << "," << it->first.second |
719 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " | 753 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " |
720 << live_tiles_rect_.ToString(); | 754 << live_tiles_rect_.ToString(); |
721 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) | 755 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) |
722 .Intersects(live_tiles_rect_)) | 756 .Intersects(live_tiles_rect_)) |
723 << this << " " << it->first.first << "," << it->first.second | 757 << this << " " << it->first.first << "," << it->first.second |
724 << " tile bounds " | 758 << " tile bounds " |
725 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() | 759 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() |
726 << " live_tiles_rect " << live_tiles_rect_.ToString(); | 760 << " live_tiles_rect " << live_tiles_rect_.ToString(); |
761 DCHECK_IMPLIES(is_on_recycle_tree, it->second->is_shared()); | |
727 } | 762 } |
728 #endif | 763 #endif |
729 } | 764 } |
730 | 765 |
731 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { | 766 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { |
732 DCHECK(tile); | 767 DCHECK(tile); |
733 | 768 |
734 if (!current_occlusion_in_layer_space_.HasOcclusion()) | 769 if (!current_occlusion_in_layer_space_.HasOcclusion()) |
735 return false; | 770 return false; |
736 | 771 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 } | 1302 } |
1268 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | 1303 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); |
1269 } | 1304 } |
1270 | 1305 |
1271 if (current_tile_) | 1306 if (current_tile_) |
1272 tiling_->UpdateTileAndTwinPriority(current_tile_); | 1307 tiling_->UpdateTileAndTwinPriority(current_tile_); |
1273 return *this; | 1308 return *this; |
1274 } | 1309 } |
1275 | 1310 |
1276 } // namespace cc | 1311 } // namespace cc |
OLD | NEW |