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