Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 640063010: cc: Don't swap PictureLayerTilingSet on activate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: noswap: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, 58 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer,
59 PictureLayerImpl* pending_layer) 59 PictureLayerImpl* pending_layer)
60 : active(active_layer), pending(pending_layer) { 60 : active(active_layer), pending(pending_layer) {
61 } 61 }
62 62
63 PictureLayerImpl::Pair::~Pair() { 63 PictureLayerImpl::Pair::~Pair() {
64 } 64 }
65 65
66 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) 66 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl,
67 int id,
68 bool is_mask)
67 : LayerImpl(tree_impl, id), 69 : LayerImpl(tree_impl, id),
68 twin_layer_(nullptr), 70 twin_layer_(nullptr),
71 tilings_(PictureLayerTilingSet::Create(this)),
72 // TODO(danakj): Can this be null to start?
69 raster_source_(PicturePileImpl::Create()), 73 raster_source_(PicturePileImpl::Create()),
70 ideal_page_scale_(0.f), 74 ideal_page_scale_(0.f),
71 ideal_device_scale_(0.f), 75 ideal_device_scale_(0.f),
72 ideal_source_scale_(0.f), 76 ideal_source_scale_(0.f),
73 ideal_contents_scale_(0.f), 77 ideal_contents_scale_(0.f),
74 raster_page_scale_(0.f), 78 raster_page_scale_(0.f),
75 raster_device_scale_(0.f), 79 raster_device_scale_(0.f),
76 raster_source_scale_(0.f), 80 raster_source_scale_(0.f),
77 raster_contents_scale_(0.f), 81 raster_contents_scale_(0.f),
78 low_res_raster_contents_scale_(0.f), 82 low_res_raster_contents_scale_(0.f),
79 raster_source_scale_is_fixed_(false), 83 raster_source_scale_is_fixed_(false),
80 was_screen_space_transform_animating_(false), 84 was_screen_space_transform_animating_(false),
81 needs_post_commit_initialization_(true), 85 needs_post_commit_initialization_(true),
82 should_update_tile_priorities_(false), 86 should_update_tile_priorities_(false),
83 only_used_low_res_last_append_quads_(false), 87 only_used_low_res_last_append_quads_(false),
84 is_mask_(false) { 88 is_mask_(is_mask) {
85 layer_tree_impl()->RegisterPictureLayerImpl(this); 89 layer_tree_impl()->RegisterPictureLayerImpl(this);
86 } 90 }
87 91
88 PictureLayerImpl::~PictureLayerImpl() { 92 PictureLayerImpl::~PictureLayerImpl() {
89 if (twin_layer_) 93 if (twin_layer_)
90 twin_layer_->twin_layer_ = nullptr; 94 twin_layer_->twin_layer_ = nullptr;
91 layer_tree_impl()->UnregisterPictureLayerImpl(this); 95 layer_tree_impl()->UnregisterPictureLayerImpl(this);
92 } 96 }
93 97
94 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( 98 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue(
(...skipping 11 matching lines...) Expand all
106 return make_scoped_ptr( 110 return make_scoped_ptr(
107 new TilingSetRasterQueue(tilings_.get(), prioritize_low_res)); 111 new TilingSetRasterQueue(tilings_.get(), prioritize_low_res));
108 } 112 }
109 113
110 const char* PictureLayerImpl::LayerTypeAsString() const { 114 const char* PictureLayerImpl::LayerTypeAsString() const {
111 return "cc::PictureLayerImpl"; 115 return "cc::PictureLayerImpl";
112 } 116 }
113 117
114 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 118 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
115 LayerTreeImpl* tree_impl) { 119 LayerTreeImpl* tree_impl) {
116 return PictureLayerImpl::Create(tree_impl, id()); 120 return PictureLayerImpl::Create(tree_impl, id(), is_mask_);
117 } 121 }
118 122
119 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 123 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
120 // It's possible this layer was never drawn or updated (e.g. because it was 124 // It's possible this layer was never drawn or updated (e.g. because it was
121 // a descendant of an opacity 0 layer). 125 // a descendant of an opacity 0 layer).
122 DoPostCommitInitializationIfNeeded(); 126 DoPostCommitInitializationIfNeeded();
123 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 127 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
128 DCHECK_EQ(layer_impl->is_mask_, is_mask_);
124 129
125 LayerImpl::PushPropertiesTo(base_layer); 130 LayerImpl::PushPropertiesTo(base_layer);
126 131
127 // Twin relationships should never change once established. 132 // Twin relationships should never change once established.
128 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); 133 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl);
129 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); 134 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this);
130 // The twin relationship does not need to exist before the first 135 // The twin relationship does not need to exist before the first
131 // PushPropertiesTo from pending to active layer since before that the active 136 // PushPropertiesTo from pending to active layer since before that the active
132 // layer can not have a pile or tilings, it has only been created and inserted 137 // layer can not have a pile or tilings, it has only been created and inserted
133 // into the tree at that point. 138 // into the tree at that point.
134 twin_layer_ = layer_impl; 139 twin_layer_ = layer_impl;
135 layer_impl->twin_layer_ = this; 140 layer_impl->twin_layer_ = this;
136 141
137 layer_impl->set_is_mask(is_mask_); 142 // Solid color layers have no tilings.
138 layer_impl->UpdateRasterSource(raster_source_); 143 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
144 // The pending tree should only have a high res (and possibly low res) tiling.
145 DCHECK_LE(tilings_->num_tilings(),
146 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u);
139 147
140 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 148 layer_impl->UpdateRasterSource(raster_source_, &invalidation_,
141 // Tilings would be expensive to push, so we swap. 149 tilings_.get());
142 layer_impl->tilings_.swap(tilings_); 150 DCHECK(invalidation_.IsEmpty());
143 layer_impl->tilings_->SetClient(layer_impl);
144 if (tilings_)
145 tilings_->SetClient(this);
146 151
147 // Ensure that the recycle tree doesn't have any unshared tiles. 152 // After syncing a solid color layer, the active layer has no tilings.
148 if (tilings_ && raster_source_->IsSolidColor()) 153 DCHECK_IMPLIES(raster_source_->IsSolidColor(),
149 tilings_->RemoveAllTilings(); 154 layer_impl->tilings_->num_tilings() == 0);
150
151 // Remove invalidated tiles from what will become a recycle tree.
152 if (tilings_)
153 tilings_->RemoveTilesInRegion(invalidation_);
154 155
155 layer_impl->raster_page_scale_ = raster_page_scale_; 156 layer_impl->raster_page_scale_ = raster_page_scale_;
156 layer_impl->raster_device_scale_ = raster_device_scale_; 157 layer_impl->raster_device_scale_ = raster_device_scale_;
157 layer_impl->raster_source_scale_ = raster_source_scale_; 158 layer_impl->raster_source_scale_ = raster_source_scale_;
158 layer_impl->raster_contents_scale_ = raster_contents_scale_; 159 layer_impl->raster_contents_scale_ = raster_contents_scale_;
159 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; 160 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_;
161
162 layer_impl->SanityCheckTilingState();
163
160 layer_impl->needs_post_commit_initialization_ = false; 164 layer_impl->needs_post_commit_initialization_ = false;
161
162 // The invalidation on this soon-to-be-recycled layer must be cleared to
163 // mirror clearing the invalidation in PictureLayer's version of this function
164 // in case push properties is skipped.
165 layer_impl->invalidation_.Swap(&invalidation_);
166 invalidation_.Clear();
167 needs_post_commit_initialization_ = true; 165 needs_post_commit_initialization_ = true;
168 166
169 // We always need to push properties. 167 // We always need to push properties.
170 // See http://crbug.com/303943 168 // See http://crbug.com/303943
169 // TODO(danakj): Stop always pushing properties since we don't swap tilings.
171 needs_push_properties_ = true; 170 needs_push_properties_ = true;
172 } 171 }
173 172
174 void PictureLayerImpl::UpdateRasterSource(
175 scoped_refptr<RasterSource> raster_source) {
176 bool could_have_tilings = CanHaveTilings();
177 raster_source_.swap(raster_source);
178
179 // Need to call UpdateTiles again if CanHaveTilings changed.
180 if (could_have_tilings != CanHaveTilings()) {
181 layer_tree_impl()->set_needs_update_draw_properties();
182 }
183 }
184
185 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, 173 void PictureLayerImpl::AppendQuads(RenderPass* render_pass,
186 const Occlusion& occlusion_in_content_space, 174 const Occlusion& occlusion_in_content_space,
187 AppendQuadsData* append_quads_data) { 175 AppendQuadsData* append_quads_data) {
188 DCHECK(!needs_post_commit_initialization_); 176 DCHECK(!needs_post_commit_initialization_);
189 // The bounds and the pile size may differ if the pile wasn't updated (ie. 177 // The bounds and the pile size may differ if the pile wasn't updated (ie.
190 // PictureLayer::Update didn't happen). In that case the pile will be empty. 178 // PictureLayer::Update didn't happen). In that case the pile will be empty.
191 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), 179 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(),
192 bounds() == raster_source_->GetSize()) 180 bounds() == raster_source_->GetSize())
193 << " bounds " << bounds().ToString() << " pile " 181 << " bounds " << bounds().ToString() << " pile "
194 << raster_source_->GetSize().ToString(); 182 << raster_source_->GetSize().ToString();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ideal_page_scale_ = 0.f; 466 ideal_page_scale_ = 0.f;
479 ideal_device_scale_ = 0.f; 467 ideal_device_scale_ = 0.f;
480 ideal_contents_scale_ = 0.f; 468 ideal_contents_scale_ = 0.f;
481 ideal_source_scale_ = 0.f; 469 ideal_source_scale_ = 0.f;
482 SanityCheckTilingState(); 470 SanityCheckTilingState();
483 return; 471 return;
484 } 472 }
485 473
486 UpdateIdealScales(); 474 UpdateIdealScales();
487 475
488 DCHECK_IMPLIES(tilings_->num_tilings() == 0, raster_contents_scale_ == 0.f)
489 << "A layer with no tilings shouldn't have valid raster scales";
490 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { 476 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) {
491 RecalculateRasterScales(); 477 RecalculateRasterScales();
492 AddTilingsForRasterScale(); 478 AddTilingsForRasterScale();
493 } 479 }
494 480
495 DCHECK(raster_page_scale_); 481 DCHECK(raster_page_scale_);
496 DCHECK(raster_device_scale_); 482 DCHECK(raster_device_scale_);
497 DCHECK(raster_source_scale_); 483 DCHECK(raster_source_scale_);
498 DCHECK(raster_contents_scale_); 484 DCHECK(raster_contents_scale_);
499 DCHECK(low_res_raster_contents_scale_); 485 DCHECK(low_res_raster_contents_scale_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 return nullptr; 560 return nullptr;
575 return twin_layer_; 561 return twin_layer_;
576 } 562 }
577 563
578 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { 564 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const {
579 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) 565 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree())
580 return nullptr; 566 return nullptr;
581 return twin_layer_; 567 return twin_layer_;
582 } 568 }
583 569
570 void PictureLayerImpl::UpdateRasterSource(
571 scoped_refptr<RasterSource> raster_source,
572 Region* new_invalidation,
573 const PictureLayerTilingSet* pending_set) {
574 // The bounds and the pile size may differ if the pile wasn't updated (ie.
575 // PictureLayer::Update didn't happen). In that case the pile will be empty.
576 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(),
577 bounds() == raster_source->GetSize())
578 << " bounds " << bounds().ToString() << " pile "
579 << raster_source->GetSize().ToString();
580
581 bool could_have_tilings = CanHaveTilings();
582 raster_source_.swap(raster_source);
583
584 // The |new_invalidation| must be cleared before updating tilings since they
585 // access the invalidation through the PictureLayerTilingClient interface.
586 invalidation_.Clear();
587 invalidation_.Swap(new_invalidation);
588
589 bool can_have_tilings = CanHaveTilings();
590
591 // Need to call UpdateTiles again if CanHaveTilings changed.
592 if (could_have_tilings != can_have_tilings)
593 layer_tree_impl()->set_needs_update_draw_properties();
594
595 if (!can_have_tilings) {
596 RemoveAllTilings();
597 return;
598 }
599
600 // We could do this after doing UpdateTiles, which would avoid doing this for
601 // tilings that are going to disappear on the pending tree (if scale changed).
602 // But that would also be more complicated, so we just do it here for now.
603 tilings_->UpdateTilingsToCurrentRasterSource(
604 raster_source_.get(), pending_set, raster_source_->GetSize(),
605 invalidation_, MinimumContentsScale());
606 }
607
584 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { 608 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
585 if (layer_tree_impl()->IsActiveTree()) { 609 if (layer_tree_impl()->IsActiveTree()) {
586 gfx::RectF layer_damage_rect = 610 gfx::RectF layer_damage_rect =
587 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); 611 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale());
588 AddDamageRect(layer_damage_rect); 612 AddDamageRect(layer_damage_rect);
589 } 613 }
590 } 614 }
591 615
592 void PictureLayerImpl::DidBecomeActive() { 616 void PictureLayerImpl::DidBecomeActive() {
593 LayerImpl::DidBecomeActive(); 617 LayerImpl::DidBecomeActive();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) 665 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
642 return &twin_layer->invalidation_; 666 return &twin_layer->invalidation_;
643 return nullptr; 667 return nullptr;
644 } 668 }
645 669
646 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( 670 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling(
647 const PictureLayerTiling* tiling) const { 671 const PictureLayerTiling* tiling) const {
648 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); 672 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
649 if (!twin_layer) 673 if (!twin_layer)
650 return nullptr; 674 return nullptr;
651 // TODO(danakj): Remove this when no longer swapping tilings.
652 if (!twin_layer->tilings_)
653 return nullptr;
654 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale()); 675 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale());
655 } 676 }
656 677
657 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( 678 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling(
658 const PictureLayerTiling* tiling) { 679 const PictureLayerTiling* tiling) {
659 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); 680 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
660 if (!recycled_twin || !recycled_twin->tilings_) 681 if (!recycled_twin || !recycled_twin->tilings_)
661 return nullptr; 682 return nullptr;
662 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale()); 683 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale());
663 } 684 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 tile_height = RoundUp(tile_height, kTileRoundUp); 779 tile_height = RoundUp(tile_height, kTileRoundUp);
759 tile_height = std::min(tile_height, default_tile_height); 780 tile_height = std::min(tile_height, default_tile_height);
760 } 781 }
761 782
762 // Under no circumstance should we be larger than the max texture size. 783 // Under no circumstance should we be larger than the max texture size.
763 tile_width = std::min(tile_width, max_texture_size); 784 tile_width = std::min(tile_width, max_texture_size);
764 tile_height = std::min(tile_height, max_texture_size); 785 tile_height = std::min(tile_height, max_texture_size);
765 return gfx::Size(tile_width, tile_height); 786 return gfx::Size(tile_width, tile_height);
766 } 787 }
767 788
768 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
769 DCHECK(!other->needs_post_commit_initialization_);
770 DCHECK(other->tilings_);
771
772 if (!DrawsContent()) {
773 RemoveAllTilings();
774 return;
775 }
776
777 raster_page_scale_ = other->raster_page_scale_;
778 raster_device_scale_ = other->raster_device_scale_;
779 raster_source_scale_ = other->raster_source_scale_;
780 raster_contents_scale_ = other->raster_contents_scale_;
781 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_;
782
783 bool synced_high_res_tiling = false;
784 if (CanHaveTilings()) {
785 synced_high_res_tiling = tilings_->SyncTilings(
786 *other->tilings_, raster_source_->GetSize(), invalidation_,
787 MinimumContentsScale(), raster_source_.get());
788 } else {
789 RemoveAllTilings();
790 }
791
792 // If our MinimumContentsScale has changed to prevent the twin's high res
793 // tiling from being synced, we should reset the raster scale and let it be
794 // recalculated (1) again. This can happen if our bounds shrink to the point
795 // where min contents scale grows.
796 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we
797 // should refactor this code a little bit and actually recalculate this.
798 // However, this is a larger undertaking, so this will work for now.
799 if (!synced_high_res_tiling)
800 ResetRasterScale();
801 else
802 SanityCheckTilingState();
803 }
804
805 void PictureLayerImpl::SyncTiling(
806 const PictureLayerTiling* tiling) {
807 if (!tilings_)
808 return;
809 if (!CanHaveTilingWithScale(tiling->contents_scale()))
810 return;
811 tilings_->AddTiling(tiling->contents_scale(), raster_source_->GetSize());
812
813 // If this tree needs update draw properties, then the tiling will
814 // get updated prior to drawing or activation. If this tree does not
815 // need update draw properties, then its transforms are up to date and
816 // we can create tiles for this tiling immediately.
817 if (!layer_tree_impl()->needs_update_draw_properties() &&
818 should_update_tile_priorities_) {
819 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking
820 // when we stop using the pending tree in the browser compositor. If we want
821 // to support occlusion tracking here, we need to dirty the draw properties
822 // or save occlusion as a draw property.
823 UpdateTilePriorities(Occlusion());
824 }
825 }
826
827 void PictureLayerImpl::GetContentsResourceId( 789 void PictureLayerImpl::GetContentsResourceId(
828 ResourceProvider::ResourceId* resource_id, 790 ResourceProvider::ResourceId* resource_id,
829 gfx::Size* resource_size) const { 791 gfx::Size* resource_size) const {
830 DCHECK_EQ(bounds().ToString(), raster_source_->GetSize().ToString()); 792 // The bounds and the pile size may differ if the pile wasn't updated (ie.
793 // PictureLayer::Update didn't happen). In that case the pile will be empty.
794 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(),
795 bounds() == raster_source_->GetSize())
796 << " bounds " << bounds().ToString() << " pile "
797 << raster_source_->GetSize().ToString();
831 gfx::Rect content_rect(bounds()); 798 gfx::Rect content_rect(bounds());
832 PictureLayerTilingSet::CoverageIterator iter( 799 PictureLayerTilingSet::CoverageIterator iter(
833 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); 800 tilings_.get(), 1.f, content_rect, ideal_contents_scale_);
834 801
835 // Mask resource not ready yet. 802 // Mask resource not ready yet.
836 if (!iter || !*iter) { 803 if (!iter || !*iter) {
837 *resource_id = 0; 804 *resource_id = 0;
838 return; 805 return;
839 } 806 }
840 807
841 // Masks only supported if they fit on exactly one tile. 808 // Masks only supported if they fit on exactly one tile.
842 DCHECK(iter.geometry_rect() == content_rect) 809 DCHECK(iter.geometry_rect() == content_rect)
843 << "iter rect " << iter.geometry_rect().ToString() << " content rect " 810 << "iter rect " << iter.geometry_rect().ToString() << " content rect "
844 << content_rect.ToString(); 811 << content_rect.ToString();
845 812
846 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); 813 const ManagedTileState::DrawInfo& draw_info = iter->draw_info();
847 if (!draw_info.IsReadyToDraw() || 814 if (!draw_info.IsReadyToDraw() ||
848 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { 815 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) {
849 *resource_id = 0; 816 *resource_id = 0;
850 return; 817 return;
851 } 818 }
852 819
853 *resource_id = draw_info.get_resource_id(); 820 *resource_id = draw_info.get_resource_id();
854 *resource_size = iter.texture_size(); 821 *resource_size = iter.texture_size();
855 } 822 }
856 823
857 void PictureLayerImpl::DoPostCommitInitialization() { 824 void PictureLayerImpl::DoPostCommitInitialization() {
825 // TODO(danakj): Remove this.
858 DCHECK(needs_post_commit_initialization_); 826 DCHECK(needs_post_commit_initialization_);
859 DCHECK(layer_tree_impl()->IsPendingTree()); 827 DCHECK(layer_tree_impl()->IsPendingTree());
860
861 if (!tilings_)
862 tilings_ = PictureLayerTilingSet::Create(this);
863
864 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
865 if (twin_layer) {
866 // If the twin has never been pushed to, do not sync from it.
867 // This can happen if this function is called during activation.
868 if (!twin_layer->needs_post_commit_initialization_)
869 SyncFromActiveLayer(twin_layer);
870 }
871
872 needs_post_commit_initialization_ = false; 828 needs_post_commit_initialization_ = false;
873 } 829 }
874 830
875 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 831 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
876 DCHECK(CanHaveTilingWithScale(contents_scale)) << 832 DCHECK(CanHaveTilingWithScale(contents_scale)) <<
877 "contents_scale: " << contents_scale; 833 "contents_scale: " << contents_scale;
878 834
879 PictureLayerTiling* tiling = 835 PictureLayerTiling* tiling =
880 tilings_->AddTiling(contents_scale, raster_source_->GetSize()); 836 tilings_->AddTiling(contents_scale, raster_source_->GetSize());
881 837
882 DCHECK(raster_source_->HasRecordings()); 838 DCHECK(raster_source_->HasRecordings());
883 839
884 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
885 twin_layer->SyncTiling(tiling);
886
887 return tiling; 840 return tiling;
888 } 841 }
889 842
890 void PictureLayerImpl::RemoveAllTilings() { 843 void PictureLayerImpl::RemoveAllTilings() {
891 if (tilings_) 844 if (tilings_)
892 tilings_->RemoveAllTilings(); 845 tilings_->RemoveAllTilings();
893 // If there are no tilings, then raster scales are no longer meaningful. 846 // If there are no tilings, then raster scales are no longer meaningful.
894 ResetRasterScale(); 847 ResetRasterScale();
895 } 848 }
896 849
(...skipping 25 matching lines...) Expand all
922 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating) 875 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating)
923 low_res = AddTiling(low_res_raster_contents_scale_); 876 low_res = AddTiling(low_res_raster_contents_scale_);
924 877
925 // Set low-res if we have one. 878 // Set low-res if we have one.
926 if (low_res && low_res != high_res) 879 if (low_res && low_res != high_res)
927 low_res->set_resolution(LOW_RESOLUTION); 880 low_res->set_resolution(LOW_RESOLUTION);
928 881
929 // Make sure we always have one high-res (even if high == low). 882 // Make sure we always have one high-res (even if high == low).
930 high_res->set_resolution(HIGH_RESOLUTION); 883 high_res->set_resolution(HIGH_RESOLUTION);
931 884
885 if (layer_tree_impl()->IsPendingTree()) {
886 // On the pending tree, drop any tilings that are non-ideal since we don't
887 // need them to activate anyway.
888 tilings_->RemoveNonIdealTilings();
889 }
890
932 SanityCheckTilingState(); 891 SanityCheckTilingState();
933 } 892 }
934 893
935 bool PictureLayerImpl::ShouldAdjustRasterScale() const { 894 bool PictureLayerImpl::ShouldAdjustRasterScale() const {
936 if (was_screen_space_transform_animating_ != 895 if (was_screen_space_transform_animating_ !=
937 draw_properties().screen_space_transform_is_animating) 896 draw_properties().screen_space_transform_is_animating)
938 return true; 897 return true;
939 898
940 if (draw_properties().screen_space_transform_is_animating && 899 if (draw_properties().screen_space_transform_is_animating &&
941 raster_contents_scale_ != ideal_contents_scale_ && 900 raster_contents_scale_ != ideal_contents_scale_ &&
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; 1065 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr;
1107 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); 1066 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
1108 PictureLayerTilingSet* recycled_twin_set = 1067 PictureLayerTilingSet* recycled_twin_set =
1109 recycled_twin ? recycled_twin->tilings_.get() : nullptr; 1068 recycled_twin ? recycled_twin->tilings_.get() : nullptr;
1110 1069
1111 tilings_->CleanUpTilings(min_acceptable_high_res_scale, 1070 tilings_->CleanUpTilings(min_acceptable_high_res_scale,
1112 max_acceptable_high_res_scale, used_tilings, 1071 max_acceptable_high_res_scale, used_tilings,
1113 layer_tree_impl()->create_low_res_tiling(), twin_set, 1072 layer_tree_impl()->create_low_res_tiling(), twin_set,
1114 recycled_twin_set); 1073 recycled_twin_set);
1115 1074
1116 if (twin_set && twin_set->num_tilings() == 0)
1117 twin->ResetRasterScale();
1118
1119 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0) 1075 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0)
1120 recycled_twin->ResetRasterScale(); 1076 recycled_twin->ResetRasterScale();
1121 1077
1122 DCHECK_GT(tilings_->num_tilings(), 0u); 1078 DCHECK_GT(tilings_->num_tilings(), 0u);
1123 SanityCheckTilingState(); 1079 SanityCheckTilingState();
1124 } 1080 }
1125 1081
1126 float PictureLayerImpl::MinimumContentsScale() const { 1082 float PictureLayerImpl::MinimumContentsScale() const {
1127 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; 1083 float setting_min = layer_tree_impl()->settings().minimum_contents_scale;
1128 1084
(...skipping 22 matching lines...) Expand all
1151 should_update_tile_priorities_ = false; 1107 should_update_tile_priorities_ = false;
1152 } 1108 }
1153 1109
1154 bool PictureLayerImpl::CanHaveTilings() const { 1110 bool PictureLayerImpl::CanHaveTilings() const {
1155 if (raster_source_->IsSolidColor()) 1111 if (raster_source_->IsSolidColor())
1156 return false; 1112 return false;
1157 if (!DrawsContent()) 1113 if (!DrawsContent())
1158 return false; 1114 return false;
1159 if (!raster_source_->HasRecordings()) 1115 if (!raster_source_->HasRecordings())
1160 return false; 1116 return false;
1117 // If the |raster_source_| has a recording it should have non-empty bounds.
1118 DCHECK(!raster_source_->GetSize().IsEmpty());
1161 return true; 1119 return true;
1162 } 1120 }
1163 1121
1164 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { 1122 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const {
1165 if (!CanHaveTilings()) 1123 if (!CanHaveTilings())
1166 return false; 1124 return false;
1167 if (contents_scale < MinimumContentsScale()) 1125 if (contents_scale < MinimumContentsScale())
1168 return false; 1126 return false;
1169 return true; 1127 return true;
1170 } 1128 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 1313
1356 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1314 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1357 if (!layer_tree_impl()->IsActiveTree()) 1315 if (!layer_tree_impl()->IsActiveTree())
1358 return true; 1316 return true;
1359 1317
1360 return AllTilesRequiredAreReadyToDraw( 1318 return AllTilesRequiredAreReadyToDraw(
1361 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1319 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1362 } 1320 }
1363 1321
1364 } // namespace cc 1322 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698