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 |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/debug/trace_event_argument.h" | 12 #include "base/debug/trace_event_argument.h" |
13 #include "base/logging.h" | |
13 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
14 #include "cc/resources/tile.h" | 15 #include "cc/resources/tile.h" |
15 #include "cc/resources/tile_priority.h" | 16 #include "cc/resources/tile_priority.h" |
16 #include "cc/trees/occlusion_tracker.h" | 17 #include "cc/trees/occlusion_tracker.h" |
17 #include "ui/gfx/point_conversions.h" | 18 #include "ui/gfx/point_conversions.h" |
18 #include "ui/gfx/rect_conversions.h" | 19 #include "ui/gfx/rect_conversions.h" |
19 #include "ui/gfx/safe_integer_conversions.h" | 20 #include "ui/gfx/safe_integer_conversions.h" |
20 #include "ui/gfx/size_conversions.h" | 21 #include "ui/gfx/size_conversions.h" |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 140 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
140 if (tile.get()) { | 141 if (tile.get()) { |
141 DCHECK(!tile->is_shared()); | 142 DCHECK(!tile->is_shared()); |
142 tiles_[key] = tile; | 143 tiles_[key] = tile; |
143 } | 144 } |
144 return tile.get(); | 145 return tile.get(); |
145 } | 146 } |
146 | 147 |
147 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 148 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
148 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 149 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
149 bool include_borders = true; | 150 bool include_borders = false; |
150 for (TilingData::Iterator iter( | 151 for (TilingData::Iterator iter( |
151 &tiling_data_, live_tiles_rect_, include_borders); | 152 &tiling_data_, live_tiles_rect_, include_borders); |
152 iter; | 153 iter; |
153 ++iter) { | 154 ++iter) { |
154 TileMapKey key = iter.index(); | 155 TileMapKey key = iter.index(); |
155 TileMap::iterator find = tiles_.find(key); | 156 TileMap::iterator find = tiles_.find(key); |
156 if (find != tiles_.end()) | 157 if (find != tiles_.end()) |
157 continue; | 158 continue; |
158 CreateTile(key.first, key.second, twin_tiling); | 159 CreateTile(key.first, key.second, twin_tiling); |
159 } | 160 } |
161 | |
162 VerifyLiveTilesRect(); | |
160 } | 163 } |
161 | 164 |
162 void PictureLayerTiling::UpdateTilesToCurrentPile( | 165 void PictureLayerTiling::UpdateTilesToCurrentPile( |
163 const Region& layer_invalidation, | 166 const Region& layer_invalidation, |
164 const gfx::Size& new_layer_bounds) { | 167 const gfx::Size& new_layer_bounds) { |
165 DCHECK(!new_layer_bounds.IsEmpty()); | 168 DCHECK(!new_layer_bounds.IsEmpty()); |
166 | 169 |
167 gfx::Size old_layer_bounds = layer_bounds_; | 170 gfx::Size old_layer_bounds = layer_bounds_; |
168 layer_bounds_ = new_layer_bounds; | 171 layer_bounds_ = new_layer_bounds; |
169 | 172 |
170 gfx::Size content_bounds = | 173 gfx::Size content_bounds = |
171 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); | 174 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); |
172 gfx::Size tile_size = tiling_data_.max_texture_size(); | 175 gfx::Size tile_size = tiling_data_.max_texture_size(); |
173 | 176 |
174 if (layer_bounds_ != old_layer_bounds) { | 177 if (layer_bounds_ != old_layer_bounds) { |
178 // The SetLiveTilesRect() method would drop tiles outside the new bounds, | |
179 // but may do so incorrectly if resizing the tiling causes the number of | |
180 // tiles in the tiling_data_ to change. | |
181 gfx::Rect content_rect(content_bounds); | |
182 int before_left = tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.x()); | |
183 int before_top = tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.y()); | |
184 int before_right = | |
185 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); | |
186 int before_bottom = | |
187 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); | |
188 | |
189 live_tiles_rect_.Intersect(content_rect); | |
vmpstr
2014/08/27 19:13:21
nit: Put a comment here saying that this is the pl
danakj
2014/08/27 19:27:01
Done.
| |
190 tiling_data_.SetTilingSize(content_bounds); | |
191 | |
192 int after_right = -1; | |
193 int after_bottom = -1; | |
194 if (!live_tiles_rect_.IsEmpty()) { | |
195 after_right = | |
196 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); | |
197 after_bottom = | |
198 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); | |
199 } | |
200 | |
201 // There is no recycled twin since this is run on the pending tiling. | |
vmpstr
2014/08/27 19:13:21
Please DCHECK the tree
danakj
2014/08/27 19:27:01
Oh, GetTree, I missed that in the client. Done.
| |
202 PictureLayerTiling* recycled_twin = NULL; | |
203 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); | |
204 | |
175 // Drop tiles outside the new layer bounds if the layer shrank. | 205 // Drop tiles outside the new layer bounds if the layer shrank. |
176 SetLiveTilesRect( | 206 for (int i = after_right + 1; i <= before_right; ++i) { |
177 gfx::IntersectRects(live_tiles_rect_, gfx::Rect(content_bounds))); | 207 for (int j = before_top; j <= before_bottom; ++j) |
178 tiling_data_.SetTilingSize(content_bounds); | 208 RemoveTileAt(i, j, recycled_twin); |
209 } | |
210 for (int i = before_left; i <= before_right; ++i) { | |
vmpstr
2014/08/27 19:13:21
nit: this can be after_right, I think? Otherwise y
danakj
2014/08/27 19:27:01
Oh, yah. I think so.
| |
211 for (int j = after_bottom + 1; j <= before_bottom; ++j) | |
212 RemoveTileAt(i, j, recycled_twin); | |
213 } | |
214 | |
215 // If the layer grew, new tiles may exist inside the same live tiles rect. | |
216 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
217 for (int i = before_right + 1; i <= after_right; ++i) { | |
vmpstr
2014/08/27 19:13:21
Can you please add a comment in the style of
// -
danakj
2014/08/27 19:27:01
I changed these from a double for-loop to an if st
| |
218 for (int j = before_top; j <= after_bottom; ++j) | |
219 CreateTile(i, j, twin_tiling); | |
220 } | |
221 for (int i = before_left; i <= before_right; ++i) { | |
222 for (int j = before_bottom + 1; j <= after_bottom; ++j) | |
223 CreateTile(i, j, twin_tiling); | |
224 } | |
225 | |
179 tile_size = client_->CalculateTileSize(content_bounds); | 226 tile_size = client_->CalculateTileSize(content_bounds); |
180 } | 227 } |
181 | 228 |
182 if (tile_size != tiling_data_.max_texture_size()) { | 229 if (tile_size != tiling_data_.max_texture_size()) { |
183 tiling_data_.SetMaxTextureSize(tile_size); | 230 tiling_data_.SetMaxTextureSize(tile_size); |
184 // When the tile size changes, the TilingData positions no longer work | 231 // When the tile size changes, the TilingData positions no longer work |
185 // as valid keys to the TileMap, so just drop all tiles. | 232 // as valid keys to the TileMap, so just drop all tiles. |
186 Reset(); | 233 Reset(); |
187 } else { | 234 } else { |
188 Invalidate(layer_invalidation); | 235 Invalidate(layer_invalidation); |
189 } | 236 } |
190 | 237 |
191 PicturePileImpl* pile = client_->GetPile(); | 238 PicturePileImpl* pile = client_->GetPile(); |
192 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 239 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
193 it->second->set_picture_pile(pile); | 240 it->second->set_picture_pile(pile); |
241 VerifyLiveTilesRect(); | |
194 } | 242 } |
195 | 243 |
196 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { | 244 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { |
197 bool recreate_invalidated_tiles = false; | 245 bool recreate_invalidated_tiles = false; |
198 DoInvalidate(layer_region, recreate_invalidated_tiles); | 246 DoInvalidate(layer_region, recreate_invalidated_tiles); |
199 } | 247 } |
200 | 248 |
201 void PictureLayerTiling::Invalidate(const Region& layer_region) { | 249 void PictureLayerTiling::Invalidate(const Region& layer_region) { |
202 bool recreate_invalidated_tiles = true; | 250 bool recreate_invalidated_tiles = true; |
203 DoInvalidate(layer_region, recreate_invalidated_tiles); | 251 DoInvalidate(layer_region, recreate_invalidated_tiles); |
204 } | 252 } |
205 | 253 |
206 void PictureLayerTiling::DoInvalidate(const Region& layer_region, | 254 void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
207 bool recreate_invalidated_tiles) { | 255 bool recreate_invalidated_tiles) { |
208 std::vector<TileMapKey> new_tile_keys; | 256 std::vector<TileMapKey> new_tile_keys; |
209 gfx::Rect expanded_live_tiles_rect = | 257 gfx::Rect expanded_live_tiles_rect = |
210 tiling_data_.ExpandRectIgnoringBordersToTileBoundsWithBorders( | 258 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
211 live_tiles_rect_); | |
212 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | 259 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { |
213 gfx::Rect layer_rect = iter.rect(); | 260 gfx::Rect layer_rect = iter.rect(); |
214 gfx::Rect content_rect = | 261 gfx::Rect content_rect = |
215 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 262 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
263 // Consider tiles inside the live tiles rect even if only their border | |
264 // pixels intersect the invalidation. But don't consider tiles outside | |
265 // the live tiles rect with the same conditions, as they won't exist. | |
266 int border_pixels = tiling_data_.border_texels(); | |
267 content_rect.Inset(-border_pixels, -border_pixels); | |
216 // Avoid needless work by not bothering to invalidate where there aren't | 268 // Avoid needless work by not bothering to invalidate where there aren't |
217 // tiles. | 269 // tiles. |
218 content_rect.Intersect(expanded_live_tiles_rect); | 270 content_rect.Intersect(expanded_live_tiles_rect); |
219 if (content_rect.IsEmpty()) | 271 if (content_rect.IsEmpty()) |
220 continue; | 272 continue; |
221 bool include_borders = true; | 273 // Since the content_rect includes border pixels already, don't include |
274 // borders when iterating to avoid double counting them. | |
275 bool include_borders = false; | |
222 for (TilingData::Iterator iter( | 276 for (TilingData::Iterator iter( |
223 &tiling_data_, content_rect, include_borders); | 277 &tiling_data_, content_rect, include_borders); |
224 iter; | 278 iter; |
225 ++iter) { | 279 ++iter) { |
226 TileMapKey key(iter.index()); | 280 // There is no recycled twin since this is run on the pending tiling. |
vmpstr
2014/08/27 19:13:21
nit: I think we have a client_->GetTree in this ve
danakj
2014/08/27 19:27:01
Done.
| |
227 TileMap::iterator find = tiles_.find(key); | 281 PictureLayerTiling* recycled_twin = NULL; |
228 if (find == tiles_.end()) | 282 DCHECK_EQ(recycled_twin, client_->GetRecycledTwinTiling(this)); |
229 continue; | 283 if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin)) |
230 | 284 new_tile_keys.push_back(iter.index()); |
231 ReleaseTile(find->second.get(), client_->GetTree()); | |
232 | |
233 tiles_.erase(find); | |
234 new_tile_keys.push_back(key); | |
235 } | 285 } |
236 } | 286 } |
237 | 287 |
238 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { | 288 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
239 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 289 for (size_t i = 0; i < new_tile_keys.size(); ++i) { |
240 // Don't try to share a tile with the twin layer, it's been invalidated so | 290 // Don't try to share a tile with the twin layer, it's been invalidated so |
241 // we have to make our own tile here. | 291 // we have to make our own tile here. |
242 const PictureLayerTiling* twin_tiling = NULL; | 292 const PictureLayerTiling* twin_tiling = NULL; |
243 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); | 293 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); |
244 } | 294 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 return texture_rect; | 438 return texture_rect; |
389 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); | 439 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); |
390 | 440 |
391 return texture_rect; | 441 return texture_rect; |
392 } | 442 } |
393 | 443 |
394 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 444 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
395 return tiling_->tiling_data_.max_texture_size(); | 445 return tiling_->tiling_data_.max_texture_size(); |
396 } | 446 } |
397 | 447 |
448 bool PictureLayerTiling::RemoveTileAt(int i, | |
449 int j, | |
450 PictureLayerTiling* recycled_twin) { | |
451 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); | |
452 if (found == tiles_.end()) | |
453 return false; | |
454 ReleaseTile(found->second.get(), client_->GetTree()); | |
455 tiles_.erase(found); | |
456 if (recycled_twin) { | |
457 // Recycled twin does not also have a recycled twin, so pass NULL. | |
458 recycled_twin->RemoveTileAt(i, j, NULL); | |
459 } | |
460 return true; | |
461 } | |
462 | |
398 void PictureLayerTiling::Reset() { | 463 void PictureLayerTiling::Reset() { |
399 live_tiles_rect_ = gfx::Rect(); | 464 live_tiles_rect_ = gfx::Rect(); |
400 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 465 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
466 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
401 ReleaseTile(it->second.get(), client_->GetTree()); | 467 ReleaseTile(it->second.get(), client_->GetTree()); |
468 if (recycled_twin) | |
469 recycled_twin->RemoveTileAt(it->first.first, it->first.second, NULL); | |
470 } | |
402 tiles_.clear(); | 471 tiles_.clear(); |
403 } | 472 } |
404 | 473 |
405 gfx::Rect PictureLayerTiling::ComputeSkewport( | 474 gfx::Rect PictureLayerTiling::ComputeSkewport( |
406 double current_frame_time_in_seconds, | 475 double current_frame_time_in_seconds, |
407 const gfx::Rect& visible_rect_in_content_space) const { | 476 const gfx::Rect& visible_rect_in_content_space) const { |
408 gfx::Rect skewport = visible_rect_in_content_space; | 477 gfx::Rect skewport = visible_rect_in_content_space; |
409 if (last_impl_frame_time_in_seconds_ == 0.0) | 478 if (last_impl_frame_time_in_seconds_ == 0.0) |
410 return skewport; | 479 return skewport; |
411 | 480 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 | 567 |
499 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; | 568 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
500 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 569 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
501 | 570 |
502 eviction_tiles_cache_valid_ = false; | 571 eviction_tiles_cache_valid_ = false; |
503 | 572 |
504 TilePriority now_priority(resolution_, TilePriority::NOW, 0); | 573 TilePriority now_priority(resolution_, TilePriority::NOW, 0); |
505 float content_to_screen_scale = ideal_contents_scale / contents_scale_; | 574 float content_to_screen_scale = ideal_contents_scale / contents_scale_; |
506 | 575 |
507 // Assign now priority to all visible tiles. | 576 // Assign now priority to all visible tiles. |
508 bool include_borders = true; | 577 bool include_borders = false; |
509 has_visible_rect_tiles_ = false; | 578 has_visible_rect_tiles_ = false; |
510 for (TilingData::Iterator iter( | 579 for (TilingData::Iterator iter( |
511 &tiling_data_, visible_rect_in_content_space, include_borders); | 580 &tiling_data_, visible_rect_in_content_space, include_borders); |
512 iter; | 581 iter; |
513 ++iter) { | 582 ++iter) { |
514 TileMap::iterator find = tiles_.find(iter.index()); | 583 TileMap::iterator find = tiles_.find(iter.index()); |
515 if (find == tiles_.end()) | 584 if (find == tiles_.end()) |
516 continue; | 585 continue; |
517 has_visible_rect_tiles_ = true; | 586 has_visible_rect_tiles_ = true; |
518 Tile* tile = find->second.get(); | 587 Tile* tile = find->second.get(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 tile->SetPriority(tree, priority); | 669 tile->SetPriority(tree, priority); |
601 } | 670 } |
602 | 671 |
603 // Update iteration rects. | 672 // Update iteration rects. |
604 current_visible_rect_ = visible_rect_in_content_space; | 673 current_visible_rect_ = visible_rect_in_content_space; |
605 current_skewport_rect_ = skewport; | 674 current_skewport_rect_ = skewport; |
606 current_soon_border_rect_ = soon_border_rect; | 675 current_soon_border_rect_ = soon_border_rect; |
607 current_eventually_rect_ = eventually_rect; | 676 current_eventually_rect_ = eventually_rect; |
608 } | 677 } |
609 | 678 |
610 void PictureLayerTiling::RemoveTileAt(int i, int j) { | |
611 TileMapKey key(i, j); | |
612 TileMap::iterator found = tiles_.find(key); | |
613 if (found == tiles_.end()) | |
614 return; | |
615 ReleaseTile(found->second.get(), client_->GetTree()); | |
616 tiles_.erase(found); | |
617 } | |
618 | |
619 void PictureLayerTiling::SetLiveTilesRect( | 679 void PictureLayerTiling::SetLiveTilesRect( |
620 const gfx::Rect& new_live_tiles_rect) { | 680 const gfx::Rect& new_live_tiles_rect) { |
621 DCHECK(new_live_tiles_rect.IsEmpty() || | 681 DCHECK(new_live_tiles_rect.IsEmpty() || |
622 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) | 682 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) |
623 << "tiling_size: " << tiling_size().ToString() | 683 << "tiling_size: " << tiling_size().ToString() |
624 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); | 684 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); |
625 if (live_tiles_rect_ == new_live_tiles_rect) | 685 if (live_tiles_rect_ == new_live_tiles_rect) |
626 return; | 686 return; |
627 | 687 |
628 // Iterate to delete all tiles outside of our new live_tiles rect. | 688 // Iterate to delete all tiles outside of our new live_tiles rect. |
629 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | 689 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
630 for (TilingData::DifferenceIterator iter(&tiling_data_, | 690 for (TilingData::DifferenceIterator iter(&tiling_data_, |
631 live_tiles_rect_, | 691 live_tiles_rect_, |
632 new_live_tiles_rect); | 692 new_live_tiles_rect); |
633 iter; | 693 iter; |
634 ++iter) { | 694 ++iter) { |
635 TileMapKey key(iter.index()); | 695 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); |
636 TileMap::iterator found = tiles_.find(key); | |
637 // If the tile was outside of the recorded region, it won't exist even | |
638 // though it was in the live rect. | |
639 if (found != tiles_.end()) { | |
640 ReleaseTile(found->second.get(), client_->GetTree()); | |
641 tiles_.erase(found); | |
642 if (recycled_twin) | |
643 recycled_twin->RemoveTileAt(iter.index_x(), iter.index_y()); | |
644 } | |
645 } | 696 } |
646 | 697 |
647 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 698 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); |
648 | 699 |
649 // Iterate to allocate new tiles for all regions with newly exposed area. | 700 // Iterate to allocate new tiles for all regions with newly exposed area. |
650 for (TilingData::DifferenceIterator iter(&tiling_data_, | 701 for (TilingData::DifferenceIterator iter(&tiling_data_, |
651 new_live_tiles_rect, | 702 new_live_tiles_rect, |
652 live_tiles_rect_); | 703 live_tiles_rect_); |
653 iter; | 704 iter; |
654 ++iter) { | 705 ++iter) { |
655 TileMapKey key(iter.index()); | 706 TileMapKey key(iter.index()); |
656 CreateTile(key.first, key.second, twin_tiling); | 707 CreateTile(key.first, key.second, twin_tiling); |
657 } | 708 } |
658 | 709 |
659 live_tiles_rect_ = new_live_tiles_rect; | 710 live_tiles_rect_ = new_live_tiles_rect; |
711 VerifyLiveTilesRect(); | |
712 } | |
713 | |
714 void PictureLayerTiling::VerifyLiveTilesRect() { | |
715 #if DCHECK_IS_ON | |
716 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
717 if (!it->second.get()) | |
718 continue; | |
719 DCHECK(it->first.first < tiling_data_.num_tiles_x()) | |
720 << this << " " << it->first.first << "," << it->first.second | |
721 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " | |
722 << live_tiles_rect_.ToString(); | |
723 DCHECK(it->first.second < tiling_data_.num_tiles_y()) | |
724 << this << " " << it->first.first << "," << it->first.second | |
725 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " | |
726 << live_tiles_rect_.ToString(); | |
727 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) | |
728 .Intersects(live_tiles_rect_)) | |
729 << this << " " << it->first.first << "," << it->first.second | |
730 << " tile bounds " | |
731 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() | |
732 << " live_tiles_rect " << live_tiles_rect_.ToString(); | |
733 } | |
734 #endif | |
660 } | 735 } |
661 | 736 |
662 void PictureLayerTiling::DidBecomeRecycled() { | 737 void PictureLayerTiling::DidBecomeRecycled() { |
663 // DidBecomeActive below will set the active priority for tiles that are | 738 // DidBecomeActive below will set the active priority for tiles that are |
664 // still in the tree. Calling this first on an active tiling that is becoming | 739 // still in the tree. Calling this first on an active tiling that is becoming |
665 // recycled takes care of tiles that are no longer in the active tree (eg. | 740 // recycled takes care of tiles that are no longer in the active tree (eg. |
666 // due to a pending invalidation). | 741 // due to a pending invalidation). |
667 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 742 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
668 it->second->SetPriority(ACTIVE_TREE, TilePriority()); | 743 it->second->SetPriority(ACTIVE_TREE, TilePriority()); |
669 } | 744 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 PictureLayerTiling* tiling, | 1019 PictureLayerTiling* tiling, |
945 WhichTree tree) | 1020 WhichTree tree) |
946 : tiling_(tiling), phase_(VISIBLE_RECT), tree_(tree), current_tile_(NULL) { | 1021 : tiling_(tiling), phase_(VISIBLE_RECT), tree_(tree), current_tile_(NULL) { |
947 if (!tiling_->has_visible_rect_tiles_) { | 1022 if (!tiling_->has_visible_rect_tiles_) { |
948 AdvancePhase(); | 1023 AdvancePhase(); |
949 return; | 1024 return; |
950 } | 1025 } |
951 | 1026 |
952 visible_iterator_ = TilingData::Iterator(&tiling_->tiling_data_, | 1027 visible_iterator_ = TilingData::Iterator(&tiling_->tiling_data_, |
953 tiling_->current_visible_rect_, | 1028 tiling_->current_visible_rect_, |
954 true /* include_borders */); | 1029 false /* include_borders */); |
955 if (!visible_iterator_) { | 1030 if (!visible_iterator_) { |
956 AdvancePhase(); | 1031 AdvancePhase(); |
957 return; | 1032 return; |
958 } | 1033 } |
959 | 1034 |
960 current_tile_ = | 1035 current_tile_ = |
961 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | 1036 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); |
962 if (!current_tile_ || !TileNeedsRaster(current_tile_)) | 1037 if (!current_tile_ || !TileNeedsRaster(current_tile_)) |
963 ++(*this); | 1038 ++(*this); |
964 } | 1039 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 DCHECK(*this); | 1176 DCHECK(*this); |
1102 do { | 1177 do { |
1103 ++current_eviction_tiles_index_; | 1178 ++current_eviction_tiles_index_; |
1104 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1179 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1105 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1180 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1106 | 1181 |
1107 return *this; | 1182 return *this; |
1108 } | 1183 } |
1109 | 1184 |
1110 } // namespace cc | 1185 } // namespace cc |
OLD | NEW |