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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 raster_device_scale_(0.f), | 49 raster_device_scale_(0.f), |
50 raster_source_scale_(0.f), | 50 raster_source_scale_(0.f), |
51 raster_contents_scale_(0.f), | 51 raster_contents_scale_(0.f), |
52 low_res_raster_contents_scale_(0.f), | 52 low_res_raster_contents_scale_(0.f), |
53 raster_source_scale_was_animating_(false), | 53 raster_source_scale_was_animating_(false), |
54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), | 54 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), |
55 needs_post_commit_initialization_(true), | 55 needs_post_commit_initialization_(true), |
56 should_update_tile_priorities_(false), | 56 should_update_tile_priorities_(false), |
57 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), | 57 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), |
58 use_gpu_rasterization_(false), | 58 use_gpu_rasterization_(false), |
59 layer_needs_to_register_itself_(true) {} | 59 layer_needs_to_register_itself_(true), |
| 60 unitialized_tiles_required_for_activation_count_(0u) { |
| 61 } |
60 | 62 |
61 PictureLayerImpl::~PictureLayerImpl() { | 63 PictureLayerImpl::~PictureLayerImpl() { |
62 if (!layer_needs_to_register_itself_) | 64 if (!layer_needs_to_register_itself_) |
63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); | 65 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); |
64 } | 66 } |
65 | 67 |
66 const char* PictureLayerImpl::LayerTypeAsString() const { | 68 const char* PictureLayerImpl::LayerTypeAsString() const { |
67 return "cc::PictureLayerImpl"; | 69 return "cc::PictureLayerImpl"; |
68 } | 70 } |
69 | 71 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 390 } |
389 | 391 |
390 WhichTree tree = | 392 WhichTree tree = |
391 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 393 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
392 | 394 |
393 tilings_->UpdateTilePriorities(tree, | 395 tilings_->UpdateTilePriorities(tree, |
394 visible_rect_in_content_space, | 396 visible_rect_in_content_space, |
395 contents_scale_x(), | 397 contents_scale_x(), |
396 current_frame_time_in_seconds); | 398 current_frame_time_in_seconds); |
397 | 399 |
| 400 unitialized_tiles_required_for_activation_count_ = 0u; |
398 if (layer_tree_impl()->IsPendingTree()) | 401 if (layer_tree_impl()->IsPendingTree()) |
399 MarkVisibleResourcesAsRequired(); | 402 MarkVisibleResourcesAsRequired(); |
400 | 403 |
401 // Tile priorities were modified. | 404 // Tile priorities were modified. |
402 layer_tree_impl()->DidModifyTilePriorities(); | 405 layer_tree_impl()->DidModifyTilePriorities(); |
403 } | 406 } |
404 | 407 |
| 408 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { |
| 409 if (layer_tree_impl()->IsActiveTree()) { |
| 410 DCHECK_EQ(0u, unitialized_tiles_required_for_activation_count_); |
| 411 return; |
| 412 } |
| 413 |
| 414 if (tile->required_for_activation()) { |
| 415 DCHECK_GT(unitialized_tiles_required_for_activation_count_, 0u); |
| 416 --unitialized_tiles_required_for_activation_count_; |
| 417 } |
| 418 } |
| 419 |
405 void PictureLayerImpl::DidBecomeActive() { | 420 void PictureLayerImpl::DidBecomeActive() { |
406 LayerImpl::DidBecomeActive(); | 421 LayerImpl::DidBecomeActive(); |
407 tilings_->DidBecomeActive(); | 422 tilings_->DidBecomeActive(); |
408 layer_tree_impl()->DidModifyTilePriorities(); | 423 layer_tree_impl()->DidModifyTilePriorities(); |
409 } | 424 } |
410 | 425 |
411 void PictureLayerImpl::DidBeginTracing() { | 426 void PictureLayerImpl::DidBeginTracing() { |
412 pile_->DidBeginTracing(); | 427 pile_->DidBeginTracing(); |
413 } | 428 } |
414 | 429 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 734 |
720 const ManagedTileState::TileVersion& tile_version = | 735 const ManagedTileState::TileVersion& tile_version = |
721 iter->GetTileVersionForDrawing(); | 736 iter->GetTileVersionForDrawing(); |
722 if (!tile_version.IsReadyToDraw() || | 737 if (!tile_version.IsReadyToDraw() || |
723 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | 738 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) |
724 return 0; | 739 return 0; |
725 | 740 |
726 return tile_version.get_resource_id(); | 741 return tile_version.get_resource_id(); |
727 } | 742 } |
728 | 743 |
729 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 744 void PictureLayerImpl::MarkVisibleResourcesAsRequired() { |
730 DCHECK(layer_tree_impl()->IsPendingTree()); | 745 DCHECK(layer_tree_impl()->IsPendingTree()); |
731 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); | 746 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); |
732 DCHECK(ideal_contents_scale_); | 747 DCHECK(ideal_contents_scale_); |
733 DCHECK_GT(tilings_->num_tilings(), 0u); | 748 DCHECK_GT(tilings_->num_tilings(), 0u); |
734 | 749 |
735 // The goal of this function is to find the minimum set of tiles that need to | 750 // The goal of this function is to find the minimum set of tiles that need to |
736 // be ready to draw in order to activate without flashing content from a | 751 // be ready to draw in order to activate without flashing content from a |
737 // higher res on the active tree to a lower res on the pending tree. | 752 // higher res on the active tree to a lower res on the pending tree. |
738 | 753 |
739 gfx::Rect rect(visible_content_rect()); | 754 gfx::Rect rect(visible_content_rect()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 MarkVisibleTilesAsRequired( | 842 MarkVisibleTilesAsRequired( |
828 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | 843 low_res, twin_low_res, contents_scale_x(), rect, missing_region); |
829 } | 844 } |
830 } | 845 } |
831 | 846 |
832 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 847 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
833 PictureLayerTiling* tiling, | 848 PictureLayerTiling* tiling, |
834 const PictureLayerTiling* optional_twin_tiling, | 849 const PictureLayerTiling* optional_twin_tiling, |
835 float contents_scale, | 850 float contents_scale, |
836 const gfx::Rect& rect, | 851 const gfx::Rect& rect, |
837 const Region& missing_region) const { | 852 const Region& missing_region) { |
838 bool twin_had_missing_tile = false; | 853 bool twin_had_missing_tile = false; |
839 for (PictureLayerTiling::CoverageIterator iter(tiling, | 854 for (PictureLayerTiling::CoverageIterator iter(tiling, |
840 contents_scale, | 855 contents_scale, |
841 rect); | 856 rect); |
842 iter; | 857 iter; |
843 ++iter) { | 858 ++iter) { |
844 Tile* tile = *iter; | 859 Tile* tile = *iter; |
845 // A null tile (i.e. missing recording) can just be skipped. | 860 // A null tile (i.e. missing recording) can just be skipped. |
846 if (!tile) | 861 if (!tile) |
847 continue; | 862 continue; |
848 | 863 |
849 // If the missing region doesn't cover it, this tile is fully | 864 // If the missing region doesn't cover it, this tile is fully |
850 // covered by acceptable tiles at other scales. | 865 // covered by acceptable tiles at other scales. |
851 if (!missing_region.Intersects(iter.geometry_rect())) | 866 if (!missing_region.Intersects(iter.geometry_rect())) |
852 continue; | 867 continue; |
853 | 868 |
854 // If the twin tile doesn't exist (i.e. missing recording or so far away | 869 // If the twin tile doesn't exist (i.e. missing recording or so far away |
855 // that it is outside the visible tile rect) or this tile is shared between | 870 // that it is outside the visible tile rect) or this tile is shared between |
856 // with the twin, then this tile isn't required to prevent flashing. | 871 // with the twin, then this tile isn't required to prevent flashing. |
857 if (optional_twin_tiling) { | 872 if (optional_twin_tiling) { |
858 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); | 873 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); |
859 if (!twin_tile || twin_tile == tile) { | 874 if (!twin_tile || twin_tile == tile) { |
860 twin_had_missing_tile = true; | 875 twin_had_missing_tile = true; |
861 continue; | 876 continue; |
862 } | 877 } |
863 } | 878 } |
864 | 879 DCHECK(!tile->required_for_activation()); |
865 tile->MarkRequiredForActivation(); | 880 tile->MarkRequiredForActivation(); |
| 881 if (!tile->IsReadyToDraw()) |
| 882 ++unitialized_tiles_required_for_activation_count_; |
866 } | 883 } |
867 return twin_had_missing_tile; | 884 return twin_had_missing_tile; |
868 } | 885 } |
869 | 886 |
870 void PictureLayerImpl::DoPostCommitInitialization() { | 887 void PictureLayerImpl::DoPostCommitInitialization() { |
871 DCHECK(needs_post_commit_initialization_); | 888 DCHECK(needs_post_commit_initialization_); |
872 DCHECK(layer_tree_impl()->IsPendingTree()); | 889 DCHECK(layer_tree_impl()->IsPendingTree()); |
873 | 890 |
874 if (!tilings_) | 891 if (!tilings_) |
875 tilings_.reset(new PictureLayerTilingSet(this, bounds())); | 892 tilings_.reset(new PictureLayerTilingSet(this, bounds())); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 return iterator_index_ < iterators_.size(); | 1534 return iterator_index_ < iterators_.size(); |
1518 } | 1535 } |
1519 | 1536 |
1520 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1537 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1521 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1538 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1522 return it->get_type() == iteration_stage_ && | 1539 return it->get_type() == iteration_stage_ && |
1523 (**it)->required_for_activation() == required_for_activation_; | 1540 (**it)->required_for_activation() == required_for_activation_; |
1524 } | 1541 } |
1525 | 1542 |
1526 } // namespace cc | 1543 } // namespace cc |
OLD | NEW |