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 <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 synced_scroll_offset()); | 94 synced_scroll_offset()); |
95 } | 95 } |
96 | 96 |
97 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { | 97 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { |
98 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 98 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
99 DCHECK_EQ(layer_impl->is_mask_, is_mask_); | 99 DCHECK_EQ(layer_impl->is_mask_, is_mask_); |
100 | 100 |
101 LayerImpl::PushPropertiesTo(base_layer); | 101 LayerImpl::PushPropertiesTo(base_layer); |
102 | 102 |
103 // Twin relationships should never change once established. | 103 // Twin relationships should never change once established. |
104 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); | 104 DCHECK(!twin_layer_ || twin_layer_ == layer_impl); |
105 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 105 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this); |
106 // The twin relationship does not need to exist before the first | 106 // The twin relationship does not need to exist before the first |
107 // PushPropertiesTo from pending to active layer since before that the active | 107 // PushPropertiesTo from pending to active layer since before that the active |
108 // layer can not have a pile or tilings, it has only been created and inserted | 108 // layer can not have a pile or tilings, it has only been created and inserted |
109 // into the tree at that point. | 109 // into the tree at that point. |
110 twin_layer_ = layer_impl; | 110 twin_layer_ = layer_impl; |
111 layer_impl->twin_layer_ = this; | 111 layer_impl->twin_layer_ = this; |
112 | 112 |
113 layer_impl->SetNearestNeighbor(nearest_neighbor_); | 113 layer_impl->SetNearestNeighbor(nearest_neighbor_); |
114 | 114 |
115 // Solid color layers have no tilings. | 115 // Solid color layers have no tilings. |
116 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); | 116 DCHECK(!raster_source_->IsSolidColor() || tilings_->num_tilings() == 0); |
117 // The pending tree should only have a high res (and possibly low res) tiling. | 117 // The pending tree should only have a high res (and possibly low res) tiling. |
118 DCHECK_LE(tilings_->num_tilings(), | 118 DCHECK_LE(tilings_->num_tilings(), |
119 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); | 119 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); |
120 | 120 |
121 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_); | 121 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_); |
122 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, | 122 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, |
123 tilings_.get()); | 123 tilings_.get()); |
124 DCHECK(invalidation_.IsEmpty()); | 124 DCHECK(invalidation_.IsEmpty()); |
125 | 125 |
126 // After syncing a solid color layer, the active layer has no tilings. | 126 // After syncing a solid color layer, the active layer has no tilings. |
127 DCHECK_IMPLIES(raster_source_->IsSolidColor(), | 127 DCHECK(!raster_source_->IsSolidColor() || |
128 layer_impl->tilings_->num_tilings() == 0); | 128 layer_impl->tilings_->num_tilings() == 0); |
129 | 129 |
130 layer_impl->raster_page_scale_ = raster_page_scale_; | 130 layer_impl->raster_page_scale_ = raster_page_scale_; |
131 layer_impl->raster_device_scale_ = raster_device_scale_; | 131 layer_impl->raster_device_scale_ = raster_device_scale_; |
132 layer_impl->raster_source_scale_ = raster_source_scale_; | 132 layer_impl->raster_source_scale_ = raster_source_scale_; |
133 layer_impl->raster_contents_scale_ = raster_contents_scale_; | 133 layer_impl->raster_contents_scale_ = raster_contents_scale_; |
134 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; | 134 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; |
135 | 135 |
136 layer_impl->SanityCheckTilingState(); | 136 layer_impl->SanityCheckTilingState(); |
137 | 137 |
138 // We always need to push properties. | 138 // We always need to push properties. |
139 // See http://crbug.com/303943 | 139 // See http://crbug.com/303943 |
140 // TODO(danakj): Stop always pushing properties since we don't swap tilings. | 140 // TODO(danakj): Stop always pushing properties since we don't swap tilings. |
141 needs_push_properties_ = true; | 141 needs_push_properties_ = true; |
142 } | 142 } |
143 | 143 |
144 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, | 144 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
145 AppendQuadsData* append_quads_data) { | 145 AppendQuadsData* append_quads_data) { |
146 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 146 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
147 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 147 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
148 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), | 148 DCHECK(raster_source_->GetSize().IsEmpty() || |
149 bounds() == raster_source_->GetSize()) | 149 bounds() == raster_source_->GetSize()) |
150 << " bounds " << bounds().ToString() << " pile " | 150 << " bounds " << bounds().ToString() << " pile " |
151 << raster_source_->GetSize().ToString(); | 151 << raster_source_->GetSize().ToString(); |
152 | 152 |
153 SharedQuadState* shared_quad_state = | 153 SharedQuadState* shared_quad_state = |
154 render_pass->CreateAndAppendSharedQuadState(); | 154 render_pass->CreateAndAppendSharedQuadState(); |
155 | 155 |
156 if (raster_source_->IsSolidColor()) { | 156 if (raster_source_->IsSolidColor()) { |
157 PopulateSharedQuadState(shared_quad_state); | 157 PopulateSharedQuadState(shared_quad_state); |
158 | 158 |
159 AppendDebugBorderQuad( | 159 AppendDebugBorderQuad( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 return nullptr; | 502 return nullptr; |
503 return twin_layer_; | 503 return twin_layer_; |
504 } | 504 } |
505 | 505 |
506 void PictureLayerImpl::UpdateRasterSource( | 506 void PictureLayerImpl::UpdateRasterSource( |
507 scoped_refptr<RasterSource> raster_source, | 507 scoped_refptr<RasterSource> raster_source, |
508 Region* new_invalidation, | 508 Region* new_invalidation, |
509 const PictureLayerTilingSet* pending_set) { | 509 const PictureLayerTilingSet* pending_set) { |
510 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 510 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
511 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 511 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
512 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), | 512 DCHECK(raster_source->GetSize().IsEmpty() || |
513 bounds() == raster_source->GetSize()) | 513 bounds() == raster_source->GetSize()) |
514 << " bounds " << bounds().ToString() << " pile " | 514 << " bounds " << bounds().ToString() << " pile " |
515 << raster_source->GetSize().ToString(); | 515 << raster_source->GetSize().ToString(); |
516 | 516 |
517 // The |raster_source_| is initially null, so have to check for that for the | 517 // The |raster_source_| is initially null, so have to check for that for the |
518 // first frame. | 518 // first frame. |
519 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); | 519 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); |
520 raster_source_.swap(raster_source); | 520 raster_source_.swap(raster_source); |
521 | 521 |
522 // The |new_invalidation| must be cleared before updating tilings since they | 522 // The |new_invalidation| must be cleared before updating tilings since they |
523 // access the invalidation through the PictureLayerTilingClient interface. | 523 // access the invalidation through the PictureLayerTilingClient interface. |
524 invalidation_.Clear(); | 524 invalidation_.Clear(); |
525 invalidation_.Swap(new_invalidation); | 525 invalidation_.Swap(new_invalidation); |
526 | 526 |
527 bool can_have_tilings = CanHaveTilings(); | 527 bool can_have_tilings = CanHaveTilings(); |
528 DCHECK_IMPLIES( | 528 DCHECK(!pending_set || |
529 pending_set, | 529 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); |
530 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); | |
531 | 530 |
532 // Need to call UpdateTiles again if CanHaveTilings changed. | 531 // Need to call UpdateTiles again if CanHaveTilings changed. |
533 if (could_have_tilings != can_have_tilings) | 532 if (could_have_tilings != can_have_tilings) |
534 layer_tree_impl()->set_needs_update_draw_properties(); | 533 layer_tree_impl()->set_needs_update_draw_properties(); |
535 | 534 |
536 if (!can_have_tilings) { | 535 if (!can_have_tilings) { |
537 RemoveAllTilings(); | 536 RemoveAllTilings(); |
538 return; | 537 return; |
539 } | 538 } |
540 | 539 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 // Under no circumstance should we be larger than the max texture size. | 749 // Under no circumstance should we be larger than the max texture size. |
751 tile_width = std::min(tile_width, max_texture_size); | 750 tile_width = std::min(tile_width, max_texture_size); |
752 tile_height = std::min(tile_height, max_texture_size); | 751 tile_height = std::min(tile_height, max_texture_size); |
753 return gfx::Size(tile_width, tile_height); | 752 return gfx::Size(tile_width, tile_height); |
754 } | 753 } |
755 | 754 |
756 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 755 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, |
757 gfx::Size* resource_size) const { | 756 gfx::Size* resource_size) const { |
758 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 757 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
759 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 758 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
760 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), | 759 DCHECK(raster_source_->GetSize().IsEmpty() || |
761 bounds() == raster_source_->GetSize()) | 760 bounds() == raster_source_->GetSize()) |
762 << " bounds " << bounds().ToString() << " pile " | 761 << " bounds " << bounds().ToString() << " pile " |
763 << raster_source_->GetSize().ToString(); | 762 << raster_source_->GetSize().ToString(); |
764 gfx::Rect content_rect(bounds()); | 763 gfx::Rect content_rect(bounds()); |
765 PictureLayerTilingSet::CoverageIterator iter( | 764 PictureLayerTilingSet::CoverageIterator iter( |
766 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); | 765 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); |
767 | 766 |
768 // Mask resource not ready yet. | 767 // Mask resource not ready yet. |
769 if (!iter || !*iter) { | 768 if (!iter || !*iter) { |
770 *resource_id = 0; | 769 *resource_id = 0; |
771 return; | 770 return; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1234 |
1236 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1235 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1237 return !layer_tree_impl()->IsRecycleTree(); | 1236 return !layer_tree_impl()->IsRecycleTree(); |
1238 } | 1237 } |
1239 | 1238 |
1240 bool PictureLayerImpl::HasValidTilePriorities() const { | 1239 bool PictureLayerImpl::HasValidTilePriorities() const { |
1241 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1240 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1242 } | 1241 } |
1243 | 1242 |
1244 } // namespace cc | 1243 } // namespace cc |
OLD | NEW |