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 uninitialized_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 uninitialized_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 |
405 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { | 408 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { |
406 if (layer_tree_impl()->IsActiveTree()) { | 409 if (layer_tree_impl()->IsActiveTree()) { |
407 gfx::RectF layer_damage_rect = | 410 gfx::RectF layer_damage_rect = |
408 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 411 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
409 AddDamageRect(layer_damage_rect); | 412 AddDamageRect(layer_damage_rect); |
| 413 |
| 414 DCHECK_EQ(0u, uninitialized_tiles_required_for_activation_count_); |
| 415 } else if (layer_tree_impl()->IsPendingTree()) { |
| 416 if (tile->required_for_activation()) { |
| 417 DCHECK_GT(uninitialized_tiles_required_for_activation_count_, 0u); |
| 418 --uninitialized_tiles_required_for_activation_count_; |
| 419 } |
410 } | 420 } |
411 } | 421 } |
412 | 422 |
413 void PictureLayerImpl::DidBecomeActive() { | 423 void PictureLayerImpl::DidBecomeActive() { |
414 LayerImpl::DidBecomeActive(); | 424 LayerImpl::DidBecomeActive(); |
415 tilings_->DidBecomeActive(); | 425 tilings_->DidBecomeActive(); |
416 layer_tree_impl()->DidModifyTilePriorities(); | 426 layer_tree_impl()->DidModifyTilePriorities(); |
417 } | 427 } |
418 | 428 |
419 void PictureLayerImpl::DidBeginTracing() { | 429 void PictureLayerImpl::DidBeginTracing() { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 736 |
727 const ManagedTileState::TileVersion& tile_version = | 737 const ManagedTileState::TileVersion& tile_version = |
728 iter->GetTileVersionForDrawing(); | 738 iter->GetTileVersionForDrawing(); |
729 if (!tile_version.IsReadyToDraw() || | 739 if (!tile_version.IsReadyToDraw() || |
730 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | 740 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) |
731 return 0; | 741 return 0; |
732 | 742 |
733 return tile_version.get_resource_id(); | 743 return tile_version.get_resource_id(); |
734 } | 744 } |
735 | 745 |
736 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 746 void PictureLayerImpl::MarkVisibleResourcesAsRequired() { |
737 DCHECK(layer_tree_impl()->IsPendingTree()); | 747 DCHECK(layer_tree_impl()->IsPendingTree()); |
738 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); | 748 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); |
739 DCHECK(ideal_contents_scale_); | 749 DCHECK(ideal_contents_scale_); |
740 DCHECK_GT(tilings_->num_tilings(), 0u); | 750 DCHECK_GT(tilings_->num_tilings(), 0u); |
741 | 751 |
742 // The goal of this function is to find the minimum set of tiles that need to | 752 // The goal of this function is to find the minimum set of tiles that need to |
743 // be ready to draw in order to activate without flashing content from a | 753 // be ready to draw in order to activate without flashing content from a |
744 // higher res on the active tree to a lower res on the pending tree. | 754 // higher res on the active tree to a lower res on the pending tree. |
745 | 755 |
746 gfx::Rect rect(visible_content_rect()); | 756 gfx::Rect rect(visible_content_rect()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 MarkVisibleTilesAsRequired( | 844 MarkVisibleTilesAsRequired( |
835 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | 845 low_res, twin_low_res, contents_scale_x(), rect, missing_region); |
836 } | 846 } |
837 } | 847 } |
838 | 848 |
839 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 849 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
840 PictureLayerTiling* tiling, | 850 PictureLayerTiling* tiling, |
841 const PictureLayerTiling* optional_twin_tiling, | 851 const PictureLayerTiling* optional_twin_tiling, |
842 float contents_scale, | 852 float contents_scale, |
843 const gfx::Rect& rect, | 853 const gfx::Rect& rect, |
844 const Region& missing_region) const { | 854 const Region& missing_region) { |
845 bool twin_had_missing_tile = false; | 855 bool twin_had_missing_tile = false; |
846 for (PictureLayerTiling::CoverageIterator iter(tiling, | 856 for (PictureLayerTiling::CoverageIterator iter(tiling, |
847 contents_scale, | 857 contents_scale, |
848 rect); | 858 rect); |
849 iter; | 859 iter; |
850 ++iter) { | 860 ++iter) { |
851 Tile* tile = *iter; | 861 Tile* tile = *iter; |
852 // A null tile (i.e. missing recording) can just be skipped. | 862 // A null tile (i.e. missing recording) can just be skipped. |
853 if (!tile) | 863 if (!tile) |
854 continue; | 864 continue; |
855 | 865 |
856 // If the missing region doesn't cover it, this tile is fully | 866 // If the missing region doesn't cover it, this tile is fully |
857 // covered by acceptable tiles at other scales. | 867 // covered by acceptable tiles at other scales. |
858 if (!missing_region.Intersects(iter.geometry_rect())) | 868 if (!missing_region.Intersects(iter.geometry_rect())) |
859 continue; | 869 continue; |
860 | 870 |
861 // If the twin tile doesn't exist (i.e. missing recording or so far away | 871 // If the twin tile doesn't exist (i.e. missing recording or so far away |
862 // that it is outside the visible tile rect) or this tile is shared between | 872 // that it is outside the visible tile rect) or this tile is shared between |
863 // with the twin, then this tile isn't required to prevent flashing. | 873 // with the twin, then this tile isn't required to prevent flashing. |
864 if (optional_twin_tiling) { | 874 if (optional_twin_tiling) { |
865 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); | 875 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); |
866 if (!twin_tile || twin_tile == tile) { | 876 if (!twin_tile || twin_tile == tile) { |
867 twin_had_missing_tile = true; | 877 twin_had_missing_tile = true; |
868 continue; | 878 continue; |
869 } | 879 } |
870 } | 880 } |
871 | 881 DCHECK(!tile->required_for_activation()); |
872 tile->MarkRequiredForActivation(); | 882 tile->MarkRequiredForActivation(); |
| 883 if (!tile->IsReadyToDraw()) |
| 884 ++uninitialized_tiles_required_for_activation_count_; |
873 } | 885 } |
874 return twin_had_missing_tile; | 886 return twin_had_missing_tile; |
875 } | 887 } |
876 | 888 |
877 void PictureLayerImpl::DoPostCommitInitialization() { | 889 void PictureLayerImpl::DoPostCommitInitialization() { |
878 DCHECK(needs_post_commit_initialization_); | 890 DCHECK(needs_post_commit_initialization_); |
879 DCHECK(layer_tree_impl()->IsPendingTree()); | 891 DCHECK(layer_tree_impl()->IsPendingTree()); |
880 | 892 |
881 if (!tilings_) | 893 if (!tilings_) |
882 tilings_.reset(new PictureLayerTilingSet(this, bounds())); | 894 tilings_.reset(new PictureLayerTilingSet(this, bounds())); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 return iterator_index_ < iterators_.size(); | 1536 return iterator_index_ < iterators_.size(); |
1525 } | 1537 } |
1526 | 1538 |
1527 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1539 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1528 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1540 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1529 return it->get_type() == iteration_stage_ && | 1541 return it->get_type() == iteration_stage_ && |
1530 (**it)->required_for_activation() == required_for_activation_; | 1542 (**it)->required_for_activation() == required_for_activation_; |
1531 } | 1543 } |
1532 | 1544 |
1533 } // namespace cc | 1545 } // namespace cc |
OLD | NEW |