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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Twin relationships should never change once established. | 115 // Twin relationships should never change once established. |
116 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); | 116 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); |
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_); | |
126 | |
127 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); | 125 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); |
128 // Tilings would be expensive to push, so we swap. | 126 // Tilings would be expensive to push, so we swap. |
129 layer_impl->tilings_.swap(tilings_); | 127 layer_impl->tilings_.swap(tilings_); |
130 layer_impl->tilings_->SetClient(layer_impl); | 128 layer_impl->tilings_->SetClient(layer_impl); |
131 if (tilings_) | 129 if (tilings_) { |
132 tilings_->SetClient(this); | 130 tilings_->SetClient(this); |
| 131 tilings_->SetRasterSource(raster_source_.get()); |
| 132 } |
| 133 |
| 134 layer_impl->UpdateRasterSource(raster_source_); |
133 | 135 |
134 // Ensure that the recycle tree doesn't have any unshared tiles. | 136 // Ensure that the recycle tree doesn't have any unshared tiles. |
135 if (tilings_ && raster_source_->IsSolidColor()) | 137 if (tilings_ && raster_source_->IsSolidColor()) |
136 tilings_->RemoveAllTilings(); | 138 tilings_->RemoveAllTilings(); |
137 | 139 |
138 // Remove invalidated tiles from what will become a recycle tree. | 140 // Remove invalidated tiles from what will become a recycle tree. |
139 if (tilings_) | 141 if (tilings_) |
140 tilings_->RemoveTilesInRegion(invalidation_); | 142 tilings_->RemoveTilesInRegion(invalidation_); |
141 | 143 |
142 layer_impl->raster_page_scale_ = raster_page_scale_; | 144 layer_impl->raster_page_scale_ = raster_page_scale_; |
(...skipping 17 matching lines...) Expand all Loading... |
160 | 162 |
161 void PictureLayerImpl::UpdateRasterSource( | 163 void PictureLayerImpl::UpdateRasterSource( |
162 scoped_refptr<RasterSource> raster_source) { | 164 scoped_refptr<RasterSource> raster_source) { |
163 bool could_have_tilings = CanHaveTilings(); | 165 bool could_have_tilings = CanHaveTilings(); |
164 raster_source_.swap(raster_source); | 166 raster_source_.swap(raster_source); |
165 | 167 |
166 // Need to call UpdateTiles again if CanHaveTilings changed. | 168 // Need to call UpdateTiles again if CanHaveTilings changed. |
167 if (could_have_tilings != CanHaveTilings()) { | 169 if (could_have_tilings != CanHaveTilings()) { |
168 layer_tree_impl()->set_needs_update_draw_properties(); | 170 layer_tree_impl()->set_needs_update_draw_properties(); |
169 } | 171 } |
| 172 |
| 173 if (tilings_) |
| 174 tilings_->SetRasterSource(raster_source_.get()); |
170 } | 175 } |
171 | 176 |
172 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, | 177 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
173 const Occlusion& occlusion_in_content_space, | 178 const Occlusion& occlusion_in_content_space, |
174 AppendQuadsData* append_quads_data) { | 179 AppendQuadsData* append_quads_data) { |
175 DCHECK(!needs_post_commit_initialization_); | 180 DCHECK(!needs_post_commit_initialization_); |
176 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 181 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
177 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 182 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
178 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), | 183 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), |
179 bounds() == raster_source_->GetSize()) | 184 bounds() == raster_source_->GetSize()) |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // Bugs: crbug.com/397198, crbug.com/396908 | 630 // Bugs: crbug.com/397198, crbug.com/396908 |
626 if (!raster_source_->IsMask()) | 631 if (!raster_source_->IsMask()) |
627 flags = Tile::USE_PICTURE_ANALYSIS; | 632 flags = Tile::USE_PICTURE_ANALYSIS; |
628 | 633 |
629 return layer_tree_impl()->tile_manager()->CreateTile( | 634 return layer_tree_impl()->tile_manager()->CreateTile( |
630 raster_source_.get(), content_rect.size(), content_rect, | 635 raster_source_.get(), content_rect.size(), content_rect, |
631 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), | 636 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), |
632 flags); | 637 flags); |
633 } | 638 } |
634 | 639 |
635 RasterSource* PictureLayerImpl::GetRasterSource() { | |
636 return raster_source_.get(); | |
637 } | |
638 | |
639 const Region* PictureLayerImpl::GetPendingInvalidation() { | 640 const Region* PictureLayerImpl::GetPendingInvalidation() { |
640 if (layer_tree_impl()->IsPendingTree()) | 641 if (layer_tree_impl()->IsPendingTree()) |
641 return &invalidation_; | 642 return &invalidation_; |
642 DCHECK(layer_tree_impl()->IsActiveTree()); | 643 DCHECK(layer_tree_impl()->IsActiveTree()); |
643 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 644 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
644 return &twin_layer->invalidation_; | 645 return &twin_layer->invalidation_; |
645 return nullptr; | 646 return nullptr; |
646 } | 647 } |
647 | 648 |
648 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 649 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 859 |
859 *resource_id = draw_info.get_resource_id(); | 860 *resource_id = draw_info.get_resource_id(); |
860 *resource_size = iter.texture_size(); | 861 *resource_size = iter.texture_size(); |
861 } | 862 } |
862 | 863 |
863 void PictureLayerImpl::DoPostCommitInitialization() { | 864 void PictureLayerImpl::DoPostCommitInitialization() { |
864 DCHECK(needs_post_commit_initialization_); | 865 DCHECK(needs_post_commit_initialization_); |
865 DCHECK(layer_tree_impl()->IsPendingTree()); | 866 DCHECK(layer_tree_impl()->IsPendingTree()); |
866 | 867 |
867 if (!tilings_) | 868 if (!tilings_) |
868 tilings_ = make_scoped_ptr(new PictureLayerTilingSet(this)); | 869 tilings_ = PictureLayerTilingSet::Create(this, raster_source_.get()); |
869 | 870 |
870 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 871 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
871 if (twin_layer) { | 872 if (twin_layer) { |
872 // If the twin has never been pushed to, do not sync from it. | 873 // If the twin has never been pushed to, do not sync from it. |
873 // This can happen if this function is called during activation. | 874 // This can happen if this function is called during activation. |
874 if (!twin_layer->needs_post_commit_initialization_) | 875 if (!twin_layer->needs_post_commit_initialization_) |
875 SyncFromActiveLayer(twin_layer); | 876 SyncFromActiveLayer(twin_layer); |
876 } | 877 } |
877 | 878 |
878 needs_post_commit_initialization_ = false; | 879 needs_post_commit_initialization_ = false; |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1713 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1713 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1714 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1714 return tiling_range.end - 1 - current_tiling_range_offset; | 1715 return tiling_range.end - 1 - current_tiling_range_offset; |
1715 } | 1716 } |
1716 } | 1717 } |
1717 NOTREACHED(); | 1718 NOTREACHED(); |
1718 return 0; | 1719 return 0; |
1719 } | 1720 } |
1720 | 1721 |
1721 } // namespace cc | 1722 } // namespace cc |
OLD | NEW |