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 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 117 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); |
118 // The twin relationship does not need to exist before the first | 118 // The twin relationship does not need to exist before the first |
119 // PushPropertiesTo from pending to active layer since before that the active | 119 // PushPropertiesTo from pending to active layer since before that the active |
120 // layer can not have a pile or tilings, it has only been created and inserted | 120 // layer can not have a pile or tilings, it has only been created and inserted |
121 // into the tree at that point. | 121 // into the tree at that point. |
122 twin_layer_ = layer_impl; | 122 twin_layer_ = layer_impl; |
123 layer_impl->twin_layer_ = this; | 123 layer_impl->twin_layer_ = this; |
124 | 124 |
125 layer_impl->UpdateRasterSource(raster_source_); | 125 layer_impl->UpdateRasterSource(raster_source_); |
126 | 126 |
127 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); | 127 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
128 // Tilings would be expensive to push, so we swap. | 128 // Tilings would be expensive to push, so we swap. |
129 layer_impl->tilings_.swap(tilings_); | 129 layer_impl->tilings_.swap(tilings_); |
130 layer_impl->tilings_->SetClient(layer_impl); | 130 layer_impl->tilings_->SetClient(layer_impl); |
131 if (tilings_) | 131 if (tilings_) |
132 tilings_->SetClient(this); | 132 tilings_->SetClient(this); |
133 | 133 |
134 // Ensure that the recycle tree doesn't have any unshared tiles. | 134 // Ensure that the recycle tree doesn't have any unshared tiles. |
135 if (tilings_ && raster_source_->IsSolidColor()) | 135 if (tilings_ && raster_source_->IsSolidColor()) |
136 tilings_->RemoveAllTilings(); | 136 tilings_->RemoveAllTilings(); |
137 | 137 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // Bugs: crbug.com/397198, crbug.com/396908 | 625 // Bugs: crbug.com/397198, crbug.com/396908 |
626 if (!raster_source_->IsMask()) | 626 if (!raster_source_->IsMask()) |
627 flags = Tile::USE_PICTURE_ANALYSIS; | 627 flags = Tile::USE_PICTURE_ANALYSIS; |
628 | 628 |
629 return layer_tree_impl()->tile_manager()->CreateTile( | 629 return layer_tree_impl()->tile_manager()->CreateTile( |
630 raster_source_.get(), content_rect.size(), content_rect, | 630 raster_source_.get(), content_rect.size(), content_rect, |
631 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), | 631 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), |
632 flags); | 632 flags); |
633 } | 633 } |
634 | 634 |
635 RasterSource* PictureLayerImpl::GetRasterSource() { | |
636 return raster_source_.get(); | |
637 } | |
638 | |
639 const Region* PictureLayerImpl::GetPendingInvalidation() { | 635 const Region* PictureLayerImpl::GetPendingInvalidation() { |
640 if (layer_tree_impl()->IsPendingTree()) | 636 if (layer_tree_impl()->IsPendingTree()) |
641 return &invalidation_; | 637 return &invalidation_; |
642 DCHECK(layer_tree_impl()->IsActiveTree()); | 638 DCHECK(layer_tree_impl()->IsActiveTree()); |
643 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 639 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
644 return &twin_layer->invalidation_; | 640 return &twin_layer->invalidation_; |
645 return nullptr; | 641 return nullptr; |
646 } | 642 } |
647 | 643 |
648 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 644 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 } | 777 } |
782 | 778 |
783 raster_page_scale_ = other->raster_page_scale_; | 779 raster_page_scale_ = other->raster_page_scale_; |
784 raster_device_scale_ = other->raster_device_scale_; | 780 raster_device_scale_ = other->raster_device_scale_; |
785 raster_source_scale_ = other->raster_source_scale_; | 781 raster_source_scale_ = other->raster_source_scale_; |
786 raster_contents_scale_ = other->raster_contents_scale_; | 782 raster_contents_scale_ = other->raster_contents_scale_; |
787 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 783 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
788 | 784 |
789 bool synced_high_res_tiling = false; | 785 bool synced_high_res_tiling = false; |
790 if (CanHaveTilings()) { | 786 if (CanHaveTilings()) { |
791 synced_high_res_tiling = | 787 synced_high_res_tiling = tilings_->SyncTilings( |
792 tilings_->SyncTilings(*other->tilings_, raster_source_->GetSize(), | 788 *other->tilings_, raster_source_->GetSize(), invalidation_, |
793 invalidation_, MinimumContentsScale()); | 789 MinimumContentsScale(), raster_source_.get()); |
794 } else { | 790 } else { |
795 RemoveAllTilings(); | 791 RemoveAllTilings(); |
796 } | 792 } |
797 | 793 |
798 // If our MinimumContentsScale has changed to prevent the twin's high res | 794 // If our MinimumContentsScale has changed to prevent the twin's high res |
799 // tiling from being synced, we should reset the raster scale and let it be | 795 // tiling from being synced, we should reset the raster scale and let it be |
800 // recalculated (1) again. This can happen if our bounds shrink to the point | 796 // recalculated (1) again. This can happen if our bounds shrink to the point |
801 // where min contents scale grows. | 797 // where min contents scale grows. |
802 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | 798 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we |
803 // should refactor this code a little bit and actually recalculate this. | 799 // should refactor this code a little bit and actually recalculate this. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 854 |
859 *resource_id = draw_info.get_resource_id(); | 855 *resource_id = draw_info.get_resource_id(); |
860 *resource_size = iter.texture_size(); | 856 *resource_size = iter.texture_size(); |
861 } | 857 } |
862 | 858 |
863 void PictureLayerImpl::DoPostCommitInitialization() { | 859 void PictureLayerImpl::DoPostCommitInitialization() { |
864 DCHECK(needs_post_commit_initialization_); | 860 DCHECK(needs_post_commit_initialization_); |
865 DCHECK(layer_tree_impl()->IsPendingTree()); | 861 DCHECK(layer_tree_impl()->IsPendingTree()); |
866 | 862 |
867 if (!tilings_) | 863 if (!tilings_) |
868 tilings_ = make_scoped_ptr(new PictureLayerTilingSet(this)); | 864 tilings_ = PictureLayerTilingSet::Create(this); |
869 | 865 |
870 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 866 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
871 if (twin_layer) { | 867 if (twin_layer) { |
872 // If the twin has never been pushed to, do not sync from it. | 868 // If the twin has never been pushed to, do not sync from it. |
873 // This can happen if this function is called during activation. | 869 // This can happen if this function is called during activation. |
874 if (!twin_layer->needs_post_commit_initialization_) | 870 if (!twin_layer->needs_post_commit_initialization_) |
875 SyncFromActiveLayer(twin_layer); | 871 SyncFromActiveLayer(twin_layer); |
876 } | 872 } |
877 | 873 |
878 needs_post_commit_initialization_ = false; | 874 needs_post_commit_initialization_ = false; |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1708 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1713 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1709 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1714 return tiling_range.end - 1 - current_tiling_range_offset; | 1710 return tiling_range.end - 1 - current_tiling_range_offset; |
1715 } | 1711 } |
1716 } | 1712 } |
1717 NOTREACHED(); | 1713 NOTREACHED(); |
1718 return 0; | 1714 return 0; |
1719 } | 1715 } |
1720 | 1716 |
1721 } // namespace cc | 1717 } // namespace cc |
OLD | NEW |