| 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 } | |
| 62 | 60 |
| 63 PictureLayerImpl::~PictureLayerImpl() { | 61 PictureLayerImpl::~PictureLayerImpl() { |
| 64 if (!layer_needs_to_register_itself_) | 62 if (!layer_needs_to_register_itself_) |
| 65 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); | 63 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); |
| 66 } | 64 } |
| 67 | 65 |
| 68 const char* PictureLayerImpl::LayerTypeAsString() const { | 66 const char* PictureLayerImpl::LayerTypeAsString() const { |
| 69 return "cc::PictureLayerImpl"; | 67 return "cc::PictureLayerImpl"; |
| 70 } | 68 } |
| 71 | 69 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 398 } |
| 401 | 399 |
| 402 WhichTree tree = | 400 WhichTree tree = |
| 403 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 401 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 404 | 402 |
| 405 tilings_->UpdateTilePriorities(tree, | 403 tilings_->UpdateTilePriorities(tree, |
| 406 visible_rect_in_content_space, | 404 visible_rect_in_content_space, |
| 407 contents_scale_x(), | 405 contents_scale_x(), |
| 408 current_frame_time_in_seconds); | 406 current_frame_time_in_seconds); |
| 409 | 407 |
| 410 uninitialized_tiles_required_for_activation_count_ = 0; | |
| 411 if (layer_tree_impl()->IsPendingTree()) | 408 if (layer_tree_impl()->IsPendingTree()) |
| 412 MarkVisibleResourcesAsRequired(); | 409 MarkVisibleResourcesAsRequired(); |
| 413 | 410 |
| 414 // Tile priorities were modified. | 411 // Tile priorities were modified. |
| 415 layer_tree_impl()->DidModifyTilePriorities(); | 412 layer_tree_impl()->DidModifyTilePriorities(); |
| 416 } | 413 } |
| 417 | 414 |
| 418 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { | 415 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { |
| 419 if (layer_tree_impl()->IsActiveTree()) { | 416 if (layer_tree_impl()->IsActiveTree()) { |
| 420 gfx::RectF layer_damage_rect = | 417 gfx::RectF layer_damage_rect = |
| 421 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 418 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
| 422 AddDamageRect(layer_damage_rect); | 419 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_; | |
| 429 } | |
| 430 } | 420 } |
| 431 } | 421 } |
| 432 | 422 |
| 433 void PictureLayerImpl::DidBecomeActive() { | 423 void PictureLayerImpl::DidBecomeActive() { |
| 434 LayerImpl::DidBecomeActive(); | 424 LayerImpl::DidBecomeActive(); |
| 435 tilings_->DidBecomeActive(); | 425 tilings_->DidBecomeActive(); |
| 436 layer_tree_impl()->DidModifyTilePriorities(); | 426 layer_tree_impl()->DidModifyTilePriorities(); |
| 437 } | 427 } |
| 438 | 428 |
| 439 void PictureLayerImpl::DidBeginTracing() { | 429 void PictureLayerImpl::DidBeginTracing() { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 736 |
| 747 const ManagedTileState::TileVersion& tile_version = | 737 const ManagedTileState::TileVersion& tile_version = |
| 748 iter->GetTileVersionForDrawing(); | 738 iter->GetTileVersionForDrawing(); |
| 749 if (!tile_version.IsReadyToDraw() || | 739 if (!tile_version.IsReadyToDraw() || |
| 750 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | 740 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) |
| 751 return 0; | 741 return 0; |
| 752 | 742 |
| 753 return tile_version.get_resource_id(); | 743 return tile_version.get_resource_id(); |
| 754 } | 744 } |
| 755 | 745 |
| 756 void PictureLayerImpl::MarkVisibleResourcesAsRequired() { | 746 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { |
| 757 DCHECK(layer_tree_impl()->IsPendingTree()); | 747 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 758 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); | 748 DCHECK(!layer_tree_impl()->needs_update_draw_properties()); |
| 759 DCHECK(ideal_contents_scale_); | 749 DCHECK(ideal_contents_scale_); |
| 760 DCHECK_GT(tilings_->num_tilings(), 0u); | 750 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 761 | 751 |
| 762 // 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 |
| 763 // 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 |
| 764 // 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. |
| 765 | 755 |
| 766 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... |
| 854 MarkVisibleTilesAsRequired( | 844 MarkVisibleTilesAsRequired( |
| 855 low_res, twin_low_res, contents_scale_x(), rect, missing_region); | 845 low_res, twin_low_res, contents_scale_x(), rect, missing_region); |
| 856 } | 846 } |
| 857 } | 847 } |
| 858 | 848 |
| 859 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 849 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
| 860 PictureLayerTiling* tiling, | 850 PictureLayerTiling* tiling, |
| 861 const PictureLayerTiling* optional_twin_tiling, | 851 const PictureLayerTiling* optional_twin_tiling, |
| 862 float contents_scale, | 852 float contents_scale, |
| 863 const gfx::Rect& rect, | 853 const gfx::Rect& rect, |
| 864 const Region& missing_region) { | 854 const Region& missing_region) const { |
| 865 bool twin_had_missing_tile = false; | 855 bool twin_had_missing_tile = false; |
| 866 for (PictureLayerTiling::CoverageIterator iter(tiling, | 856 for (PictureLayerTiling::CoverageIterator iter(tiling, |
| 867 contents_scale, | 857 contents_scale, |
| 868 rect); | 858 rect); |
| 869 iter; | 859 iter; |
| 870 ++iter) { | 860 ++iter) { |
| 871 Tile* tile = *iter; | 861 Tile* tile = *iter; |
| 872 // A null tile (i.e. missing recording) can just be skipped. | 862 // A null tile (i.e. missing recording) can just be skipped. |
| 873 if (!tile) | 863 if (!tile) |
| 874 continue; | 864 continue; |
| 875 | 865 |
| 876 // 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 |
| 877 // covered by acceptable tiles at other scales. | 867 // covered by acceptable tiles at other scales. |
| 878 if (!missing_region.Intersects(iter.geometry_rect())) | 868 if (!missing_region.Intersects(iter.geometry_rect())) |
| 879 continue; | 869 continue; |
| 880 | 870 |
| 881 // 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 |
| 882 // 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 |
| 883 // 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. |
| 884 if (optional_twin_tiling) { | 874 if (optional_twin_tiling) { |
| 885 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); | 875 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); |
| 886 if (!twin_tile || twin_tile == tile) { | 876 if (!twin_tile || twin_tile == tile) { |
| 887 twin_had_missing_tile = true; | 877 twin_had_missing_tile = true; |
| 888 continue; | 878 continue; |
| 889 } | 879 } |
| 890 } | 880 } |
| 891 DCHECK(!tile->required_for_activation()); | 881 |
| 892 tile->MarkRequiredForActivation(); | 882 tile->MarkRequiredForActivation(); |
| 893 if (!tile->IsReadyToDraw()) | |
| 894 ++uninitialized_tiles_required_for_activation_count_; | |
| 895 } | 883 } |
| 896 return twin_had_missing_tile; | 884 return twin_had_missing_tile; |
| 897 } | 885 } |
| 898 | 886 |
| 899 void PictureLayerImpl::DoPostCommitInitialization() { | 887 void PictureLayerImpl::DoPostCommitInitialization() { |
| 900 DCHECK(needs_post_commit_initialization_); | 888 DCHECK(needs_post_commit_initialization_); |
| 901 DCHECK(layer_tree_impl()->IsPendingTree()); | 889 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 902 | 890 |
| 903 if (!tilings_) | 891 if (!tilings_) |
| 904 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... |
| 1546 return iterator_index_ < iterators_.size(); | 1534 return iterator_index_ < iterators_.size(); |
| 1547 } | 1535 } |
| 1548 | 1536 |
| 1549 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1537 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1550 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1538 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1551 return it->get_type() == iteration_stage_ && | 1539 return it->get_type() == iteration_stage_ && |
| 1552 (**it)->required_for_activation() == required_for_activation_; | 1540 (**it)->required_for_activation() == required_for_activation_; |
| 1553 } | 1541 } |
| 1554 | 1542 |
| 1555 } // namespace cc | 1543 } // namespace cc |
| OLD | NEW |