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_(0) { | |
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 } | 400 } |
399 | 401 |
400 WhichTree tree = | 402 WhichTree tree = |
401 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 403 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
402 | 404 |
403 tilings_->UpdateTilePriorities(tree, | 405 tilings_->UpdateTilePriorities(tree, |
404 visible_rect_in_content_space, | 406 visible_rect_in_content_space, |
405 contents_scale_x(), | 407 contents_scale_x(), |
406 current_frame_time_in_seconds); | 408 current_frame_time_in_seconds); |
407 | 409 |
410 uninitialized_tiles_required_for_activation_count_ = 0; | |
408 if (layer_tree_impl()->IsPendingTree()) | 411 if (layer_tree_impl()->IsPendingTree()) |
409 MarkVisibleResourcesAsRequired(); | 412 MarkVisibleResourcesAsRequired(); |
410 | 413 |
411 // Tile priorities were modified. | 414 // Tile priorities were modified. |
412 layer_tree_impl()->DidModifyTilePriorities(); | 415 layer_tree_impl()->DidModifyTilePriorities(); |
413 } | 416 } |
414 | 417 |
415 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { | 418 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { |
416 if (layer_tree_impl()->IsActiveTree()) { | 419 if (layer_tree_impl()->IsActiveTree()) { |
417 gfx::RectF layer_damage_rect = | 420 gfx::RectF layer_damage_rect = |
418 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 421 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
419 AddDamageRect(layer_damage_rect); | 422 AddDamageRect(layer_damage_rect); |
423 | |
424 DCHECK_EQ(0, uninitialized_tiles_required_for_activation_count_); | |
425 } else if (layer_tree_impl()->IsPendingTree()) { | |
426 if (tile->required_for_activation()) { | |
427 DCHECK_GT(uninitialized_tiles_required_for_activation_count_, 0); | |
428 --uninitialized_tiles_required_for_activation_count_; | |
reveman
2014/05/01 14:17:00
what if 2 different versions of the tile have been
vmpstr
2014/05/01 17:42:13
That's a good point, this count doesn't account fo
| |
429 } | |
420 } | 430 } |
421 } | 431 } |
422 | 432 |
423 void PictureLayerImpl::DidBecomeActive() { | 433 void PictureLayerImpl::DidBecomeActive() { |
424 LayerImpl::DidBecomeActive(); | 434 LayerImpl::DidBecomeActive(); |
425 tilings_->DidBecomeActive(); | 435 tilings_->DidBecomeActive(); |
426 layer_tree_impl()->DidModifyTilePriorities(); | 436 layer_tree_impl()->DidModifyTilePriorities(); |
427 } | 437 } |
428 | 438 |
429 void PictureLayerImpl::DidBeginTracing() { | 439 void PictureLayerImpl::DidBeginTracing() { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 | 746 |
737 const ManagedTileState::TileVersion& tile_version = | 747 const ManagedTileState::TileVersion& tile_version = |
738 iter->GetTileVersionForDrawing(); | 748 iter->GetTileVersionForDrawing(); |
739 if (!tile_version.IsReadyToDraw() || | 749 if (!tile_version.IsReadyToDraw() || |
740 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | 750 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) |
741 return 0; | 751 return 0; |
742 | 752 |
743 return tile_version.get_resource_id(); | 753 return tile_version.get_resource_id(); |
744 } | 754 } |
745 | 755 |
746 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 756 void PictureLayerImpl::MarkVisibleResourcesAsRequired() { |
747 DCHECK(layer_tree_impl()->IsPendingTree()); | 757 DCHECK(layer_tree_impl()->IsPendingTree()); |
748 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); | 758 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); |
749 DCHECK(ideal_contents_scale_); | 759 DCHECK(ideal_contents_scale_); |
750 DCHECK_GT(tilings_->num_tilings(), 0u); | 760 DCHECK_GT(tilings_->num_tilings(), 0u); |
751 | 761 |
752 // The goal of this function is to find the minimum set of tiles that need to | 762 // The goal of this function is to find the minimum set of tiles that need to |
753 // be ready to draw in order to activate without flashing content from a | 763 // be ready to draw in order to activate without flashing content from a |
754 // higher res on the active tree to a lower res on the pending tree. | 764 // higher res on the active tree to a lower res on the pending tree. |
755 | 765 |
756 gfx::Rect rect(visible_content_rect()); | 766 gfx::Rect rect(visible_content_rect()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 MarkVisibleTilesAsRequired( | 854 MarkVisibleTilesAsRequired( |
845 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | 855 low_res, twin_low_res, contents_scale_x(), rect, missing_region); |
846 } | 856 } |
847 } | 857 } |
848 | 858 |
849 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 859 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
850 PictureLayerTiling* tiling, | 860 PictureLayerTiling* tiling, |
851 const PictureLayerTiling* optional_twin_tiling, | 861 const PictureLayerTiling* optional_twin_tiling, |
852 float contents_scale, | 862 float contents_scale, |
853 const gfx::Rect& rect, | 863 const gfx::Rect& rect, |
854 const Region& missing_region) const { | 864 const Region& missing_region) { |
855 bool twin_had_missing_tile = false; | 865 bool twin_had_missing_tile = false; |
856 for (PictureLayerTiling::CoverageIterator iter(tiling, | 866 for (PictureLayerTiling::CoverageIterator iter(tiling, |
857 contents_scale, | 867 contents_scale, |
858 rect); | 868 rect); |
859 iter; | 869 iter; |
860 ++iter) { | 870 ++iter) { |
861 Tile* tile = *iter; | 871 Tile* tile = *iter; |
862 // A null tile (i.e. missing recording) can just be skipped. | 872 // A null tile (i.e. missing recording) can just be skipped. |
863 if (!tile) | 873 if (!tile) |
864 continue; | 874 continue; |
865 | 875 |
866 // If the missing region doesn't cover it, this tile is fully | 876 // If the missing region doesn't cover it, this tile is fully |
867 // covered by acceptable tiles at other scales. | 877 // covered by acceptable tiles at other scales. |
868 if (!missing_region.Intersects(iter.geometry_rect())) | 878 if (!missing_region.Intersects(iter.geometry_rect())) |
869 continue; | 879 continue; |
870 | 880 |
871 // If the twin tile doesn't exist (i.e. missing recording or so far away | 881 // If the twin tile doesn't exist (i.e. missing recording or so far away |
872 // that it is outside the visible tile rect) or this tile is shared between | 882 // that it is outside the visible tile rect) or this tile is shared between |
873 // with the twin, then this tile isn't required to prevent flashing. | 883 // with the twin, then this tile isn't required to prevent flashing. |
874 if (optional_twin_tiling) { | 884 if (optional_twin_tiling) { |
875 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); | 885 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); |
876 if (!twin_tile || twin_tile == tile) { | 886 if (!twin_tile || twin_tile == tile) { |
877 twin_had_missing_tile = true; | 887 twin_had_missing_tile = true; |
878 continue; | 888 continue; |
879 } | 889 } |
880 } | 890 } |
881 | 891 DCHECK(!tile->required_for_activation()); |
882 tile->MarkRequiredForActivation(); | 892 tile->MarkRequiredForActivation(); |
893 if (!tile->IsReadyToDraw()) | |
894 ++uninitialized_tiles_required_for_activation_count_; | |
883 } | 895 } |
884 return twin_had_missing_tile; | 896 return twin_had_missing_tile; |
885 } | 897 } |
886 | 898 |
887 void PictureLayerImpl::DoPostCommitInitialization() { | 899 void PictureLayerImpl::DoPostCommitInitialization() { |
888 DCHECK(needs_post_commit_initialization_); | 900 DCHECK(needs_post_commit_initialization_); |
889 DCHECK(layer_tree_impl()->IsPendingTree()); | 901 DCHECK(layer_tree_impl()->IsPendingTree()); |
890 | 902 |
891 if (!tilings_) | 903 if (!tilings_) |
892 tilings_.reset(new PictureLayerTilingSet(this, bounds())); | 904 tilings_.reset(new PictureLayerTilingSet(this, bounds())); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1534 return iterator_index_ < iterators_.size(); | 1546 return iterator_index_ < iterators_.size(); |
1535 } | 1547 } |
1536 | 1548 |
1537 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1549 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1538 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1550 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1539 return it->get_type() == iteration_stage_ && | 1551 return it->get_type() == iteration_stage_ && |
1540 (**it)->required_for_activation() == required_for_activation_; | 1552 (**it)->required_for_activation() == required_for_activation_; |
1541 } | 1553 } |
1542 | 1554 |
1543 } // namespace cc | 1555 } // namespace cc |
OLD | NEW |