Chromium Code Reviews| 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); | |
| 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 | |
| 175 // Drop tiles outside the new layer bounds if the layer shrank. | 201 // Drop tiles outside the new layer bounds if the layer shrank. |
| 176 SetLiveTilesRect( | 202 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
| 177 gfx::IntersectRects(live_tiles_rect_, gfx::Rect(content_bounds))); | 203 for (int i = after_right + 1; i <= before_right; ++i) { |
| 178 tiling_data_.SetTilingSize(content_bounds); | 204 for (int j = before_top; j <= before_bottom; ++j) |
| 205 RemoveTileAt(i, j, recycled_twin); | |
| 206 } | |
| 207 for (int i = before_left; i <= before_right; ++i) { | |
| 208 for (int j = after_bottom + 1; j <= before_bottom; ++j) | |
| 209 RemoveTileAt(i, j, recycled_twin); | |
| 210 } | |
| 211 | |
| 212 // If the layer grew, new tiles may exist inside the same live tiles rect. | |
| 213 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
| 214 for (int i = before_right + 1; i <= after_right; ++i) { | |
| 215 for (int j = before_top; j <= after_bottom; ++j) | |
| 216 CreateTile(i, j, twin_tiling); | |
| 217 } | |
| 218 for (int i = before_left; i <= before_right; ++i) { | |
| 219 for (int j = before_bottom + 1; j <= after_bottom; ++j) | |
| 220 CreateTile(i, j, twin_tiling); | |
| 221 } | |
| 222 | |
| 179 tile_size = client_->CalculateTileSize(content_bounds); | 223 tile_size = client_->CalculateTileSize(content_bounds); |
| 180 } | 224 } |
| 181 | 225 |
| 182 if (tile_size != tiling_data_.max_texture_size()) { | 226 if (tile_size != tiling_data_.max_texture_size()) { |
| 183 tiling_data_.SetMaxTextureSize(tile_size); | 227 tiling_data_.SetMaxTextureSize(tile_size); |
| 184 // When the tile size changes, the TilingData positions no longer work | 228 // When the tile size changes, the TilingData positions no longer work |
| 185 // as valid keys to the TileMap, so just drop all tiles. | 229 // as valid keys to the TileMap, so just drop all tiles. |
| 186 Reset(); | 230 Reset(); |
| 187 } else { | 231 } else { |
| 188 Invalidate(layer_invalidation); | 232 Invalidate(layer_invalidation); |
| 189 } | 233 } |
| 190 | 234 |
| 191 PicturePileImpl* pile = client_->GetPile(); | 235 PicturePileImpl* pile = client_->GetPile(); |
| 192 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 236 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
| 193 it->second->set_picture_pile(pile); | 237 it->second->set_picture_pile(pile); |
| 238 VerifyLiveTilesRect(); | |
| 194 } | 239 } |
| 195 | 240 |
| 196 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { | 241 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { |
| 197 bool recreate_invalidated_tiles = false; | 242 bool recreate_invalidated_tiles = false; |
| 198 DoInvalidate(layer_region, recreate_invalidated_tiles); | 243 DoInvalidate(layer_region, recreate_invalidated_tiles); |
| 199 } | 244 } |
| 200 | 245 |
| 201 void PictureLayerTiling::Invalidate(const Region& layer_region) { | 246 void PictureLayerTiling::Invalidate(const Region& layer_region) { |
| 202 bool recreate_invalidated_tiles = true; | 247 bool recreate_invalidated_tiles = true; |
| 203 DoInvalidate(layer_region, recreate_invalidated_tiles); | 248 DoInvalidate(layer_region, recreate_invalidated_tiles); |
| 204 } | 249 } |
| 205 | 250 |
| 206 void PictureLayerTiling::DoInvalidate(const Region& layer_region, | 251 void PictureLayerTiling::DoInvalidate(const Region& layer_region, |
| 207 bool recreate_invalidated_tiles) { | 252 bool recreate_invalidated_tiles) { |
| 208 std::vector<TileMapKey> new_tile_keys; | 253 std::vector<TileMapKey> new_tile_keys; |
| 209 gfx::Rect expanded_live_tiles_rect = | 254 gfx::Rect expanded_live_tiles_rect = |
| 210 tiling_data_.ExpandRectIgnoringBordersToTileBoundsWithBorders( | 255 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
| 211 live_tiles_rect_); | |
| 212 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | 256 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { |
| 213 gfx::Rect layer_rect = iter.rect(); | 257 gfx::Rect layer_rect = iter.rect(); |
| 214 gfx::Rect content_rect = | 258 gfx::Rect content_rect = |
| 215 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 259 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
| 260 // Consider tiles inside the live tiles rect even if only their border | |
| 261 // pixels intersect the invalidation. But don't consider tiles outside | |
| 262 // the live tiles rect with the same conditions, as they won't exist. | |
| 263 int border_pixels = tiling_data_.border_texels(); | |
| 264 content_rect.Inset(-border_pixels, -border_pixels); | |
| 216 // Avoid needless work by not bothering to invalidate where there aren't | 265 // Avoid needless work by not bothering to invalidate where there aren't |
| 217 // tiles. | 266 // tiles. |
| 218 content_rect.Intersect(expanded_live_tiles_rect); | 267 content_rect.Intersect(expanded_live_tiles_rect); |
| 219 if (content_rect.IsEmpty()) | 268 if (content_rect.IsEmpty()) |
| 220 continue; | 269 continue; |
| 221 bool include_borders = true; | 270 // Since the content_rect includes border pixels already, don't include |
| 271 // borders when iterating to double count them. | |
| 272 bool include_borders = false; | |
| 222 for (TilingData::Iterator iter( | 273 for (TilingData::Iterator iter( |
| 223 &tiling_data_, content_rect, include_borders); | 274 &tiling_data_, content_rect, include_borders); |
| 224 iter; | 275 iter; |
| 225 ++iter) { | 276 ++iter) { |
| 226 TileMapKey key(iter.index()); | 277 // There is no recycled twin since this is run on the pending tiling. |
| 227 TileMap::iterator find = tiles_.find(key); | 278 DCHECK_EQ(static_cast<PictureLayerTiling*>(NULL), |
| 228 if (find == tiles_.end()) | 279 client_->GetRecycledTwinTiling(this)); |
| 229 continue; | 280 PictureLayerTiling* recycled_twin = NULL; |
| 230 | 281 if (RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin)) |
| 231 ReleaseTile(find->second.get(), client_->GetTree()); | 282 new_tile_keys.push_back(iter.index()); |
| 232 | |
| 233 tiles_.erase(find); | |
| 234 new_tile_keys.push_back(key); | |
| 235 } | 283 } |
| 236 } | 284 } |
| 237 | 285 |
| 238 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { | 286 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { |
| 239 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | 287 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 | 288 // 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. | 289 // we have to make our own tile here. |
| 242 const PictureLayerTiling* twin_tiling = NULL; | 290 const PictureLayerTiling* twin_tiling = NULL; |
| 243 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); | 291 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); |
| 244 } | 292 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 return texture_rect; | 436 return texture_rect; |
| 389 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); | 437 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); |
| 390 | 438 |
| 391 return texture_rect; | 439 return texture_rect; |
| 392 } | 440 } |
| 393 | 441 |
| 394 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 442 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
| 395 return tiling_->tiling_data_.max_texture_size(); | 443 return tiling_->tiling_data_.max_texture_size(); |
| 396 } | 444 } |
| 397 | 445 |
| 446 bool PictureLayerTiling::RemoveTileAt(int i, | |
|
danakj
2014/08/27 18:06:42
Oh, this bears mentioning. While I was at it and r
| |
| 447 int j, | |
| 448 PictureLayerTiling* recycled_twin) { | |
| 449 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); | |
| 450 if (found == tiles_.end()) | |
| 451 return false; | |
| 452 ReleaseTile(found->second.get(), client_->GetTree()); | |
| 453 tiles_.erase(found); | |
| 454 if (recycled_twin) { | |
| 455 // Recycled twin does not also have a recycled twin, so pass NULL. | |
| 456 recycled_twin->RemoveTileAt(i, j, NULL); | |
| 457 } | |
| 458 return true; | |
| 459 } | |
| 460 | |
| 398 void PictureLayerTiling::Reset() { | 461 void PictureLayerTiling::Reset() { |
| 399 live_tiles_rect_ = gfx::Rect(); | 462 live_tiles_rect_ = gfx::Rect(); |
| 400 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 463 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); |
| 464 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
| 401 ReleaseTile(it->second.get(), client_->GetTree()); | 465 ReleaseTile(it->second.get(), client_->GetTree()); |
| 466 if (recycled_twin) | |
| 467 recycled_twin->RemoveTileAt(it->first.first, it->first.second, NULL); | |
| 468 } | |
| 402 tiles_.clear(); | 469 tiles_.clear(); |
| 403 } | 470 } |
| 404 | 471 |
| 405 gfx::Rect PictureLayerTiling::ComputeSkewport( | 472 gfx::Rect PictureLayerTiling::ComputeSkewport( |
| 406 double current_frame_time_in_seconds, | 473 double current_frame_time_in_seconds, |
| 407 const gfx::Rect& visible_rect_in_content_space) const { | 474 const gfx::Rect& visible_rect_in_content_space) const { |
| 408 gfx::Rect skewport = visible_rect_in_content_space; | 475 gfx::Rect skewport = visible_rect_in_content_space; |
| 409 if (last_impl_frame_time_in_seconds_ == 0.0) | 476 if (last_impl_frame_time_in_seconds_ == 0.0) |
| 410 return skewport; | 477 return skewport; |
| 411 | 478 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 | 565 |
| 499 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; | 566 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
| 500 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 567 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
| 501 | 568 |
| 502 eviction_tiles_cache_valid_ = false; | 569 eviction_tiles_cache_valid_ = false; |
| 503 | 570 |
| 504 TilePriority now_priority(resolution_, TilePriority::NOW, 0); | 571 TilePriority now_priority(resolution_, TilePriority::NOW, 0); |
| 505 float content_to_screen_scale = ideal_contents_scale / contents_scale_; | 572 float content_to_screen_scale = ideal_contents_scale / contents_scale_; |
| 506 | 573 |
| 507 // Assign now priority to all visible tiles. | 574 // Assign now priority to all visible tiles. |
| 508 bool include_borders = true; | 575 bool include_borders = false; |
| 509 has_visible_rect_tiles_ = false; | 576 has_visible_rect_tiles_ = false; |
| 510 for (TilingData::Iterator iter( | 577 for (TilingData::Iterator iter( |
| 511 &tiling_data_, visible_rect_in_content_space, include_borders); | 578 &tiling_data_, visible_rect_in_content_space, include_borders); |
| 512 iter; | 579 iter; |
| 513 ++iter) { | 580 ++iter) { |
| 514 TileMap::iterator find = tiles_.find(iter.index()); | 581 TileMap::iterator find = tiles_.find(iter.index()); |
| 515 if (find == tiles_.end()) | 582 if (find == tiles_.end()) |
| 516 continue; | 583 continue; |
| 517 has_visible_rect_tiles_ = true; | 584 has_visible_rect_tiles_ = true; |
| 518 Tile* tile = find->second.get(); | 585 Tile* tile = find->second.get(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 tile->SetPriority(tree, priority); | 667 tile->SetPriority(tree, priority); |
| 601 } | 668 } |
| 602 | 669 |
| 603 // Update iteration rects. | 670 // Update iteration rects. |
| 604 current_visible_rect_ = visible_rect_in_content_space; | 671 current_visible_rect_ = visible_rect_in_content_space; |
| 605 current_skewport_rect_ = skewport; | 672 current_skewport_rect_ = skewport; |
| 606 current_soon_border_rect_ = soon_border_rect; | 673 current_soon_border_rect_ = soon_border_rect; |
| 607 current_eventually_rect_ = eventually_rect; | 674 current_eventually_rect_ = eventually_rect; |
| 608 } | 675 } |
| 609 | 676 |
| 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( | 677 void PictureLayerTiling::SetLiveTilesRect( |
| 620 const gfx::Rect& new_live_tiles_rect) { | 678 const gfx::Rect& new_live_tiles_rect) { |
| 679 DCHECK(gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)); | |
| 680 | |
| 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 |