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

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: YetAnotherRebase 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, 65 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer,
66 PictureLayerImpl* pending_layer) 66 PictureLayerImpl* pending_layer)
67 : active(active_layer), pending(pending_layer) { 67 : active(active_layer), pending(pending_layer) {
68 } 68 }
69 69
70 PictureLayerImpl::Pair::~Pair() { 70 PictureLayerImpl::Pair::~Pair() {
71 } 71 }
72 72
73 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) 73 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl,
74 int id,
75 bool is_mask)
74 : LayerImpl(tree_impl, id), 76 : LayerImpl(tree_impl, id),
75 twin_layer_(nullptr), 77 twin_layer_(nullptr),
78 tilings_(PictureLayerTilingSet::Create(this)),
79 // TODO(danakj): Can this be null to start?
76 raster_source_(PicturePileImpl::Create()), 80 raster_source_(PicturePileImpl::Create()),
77 ideal_page_scale_(0.f), 81 ideal_page_scale_(0.f),
78 ideal_device_scale_(0.f), 82 ideal_device_scale_(0.f),
79 ideal_source_scale_(0.f), 83 ideal_source_scale_(0.f),
80 ideal_contents_scale_(0.f), 84 ideal_contents_scale_(0.f),
81 raster_page_scale_(0.f), 85 raster_page_scale_(0.f),
82 raster_device_scale_(0.f), 86 raster_device_scale_(0.f),
83 raster_source_scale_(0.f), 87 raster_source_scale_(0.f),
84 raster_contents_scale_(0.f), 88 raster_contents_scale_(0.f),
85 low_res_raster_contents_scale_(0.f), 89 low_res_raster_contents_scale_(0.f),
86 raster_source_scale_is_fixed_(false), 90 raster_source_scale_is_fixed_(false),
87 was_screen_space_transform_animating_(false), 91 was_screen_space_transform_animating_(false),
88 needs_post_commit_initialization_(true), 92 needs_post_commit_initialization_(true),
89 should_update_tile_priorities_(false), 93 should_update_tile_priorities_(false),
90 only_used_low_res_last_append_quads_(false), 94 only_used_low_res_last_append_quads_(false),
91 is_mask_(false) { 95 is_mask_(is_mask) {
92 layer_tree_impl()->RegisterPictureLayerImpl(this); 96 layer_tree_impl()->RegisterPictureLayerImpl(this);
93 } 97 }
94 98
95 PictureLayerImpl::~PictureLayerImpl() { 99 PictureLayerImpl::~PictureLayerImpl() {
96 if (twin_layer_) 100 if (twin_layer_)
97 twin_layer_->twin_layer_ = nullptr; 101 twin_layer_->twin_layer_ = nullptr;
98 layer_tree_impl()->UnregisterPictureLayerImpl(this); 102 layer_tree_impl()->UnregisterPictureLayerImpl(this);
99 } 103 }
100 104
101 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( 105 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue(
(...skipping 11 matching lines...) Expand all
113 return make_scoped_ptr( 117 return make_scoped_ptr(
114 new TilingSetRasterQueue(tilings_.get(), prioritize_low_res)); 118 new TilingSetRasterQueue(tilings_.get(), prioritize_low_res));
115 } 119 }
116 120
117 const char* PictureLayerImpl::LayerTypeAsString() const { 121 const char* PictureLayerImpl::LayerTypeAsString() const {
118 return "cc::PictureLayerImpl"; 122 return "cc::PictureLayerImpl";
119 } 123 }
120 124
121 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( 125 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
122 LayerTreeImpl* tree_impl) { 126 LayerTreeImpl* tree_impl) {
123 return PictureLayerImpl::Create(tree_impl, id()); 127 return PictureLayerImpl::Create(tree_impl, id(), is_mask_);
124 } 128 }
125 129
126 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 130 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
127 // It's possible this layer was never drawn or updated (e.g. because it was 131 // It's possible this layer was never drawn or updated (e.g. because it was
128 // a descendant of an opacity 0 layer). 132 // a descendant of an opacity 0 layer).
129 DoPostCommitInitializationIfNeeded(); 133 DoPostCommitInitializationIfNeeded();
130 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 134 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
135 DCHECK_EQ(layer_impl->is_mask_, is_mask_);
131 136
132 LayerImpl::PushPropertiesTo(base_layer); 137 LayerImpl::PushPropertiesTo(base_layer);
133 138
134 // Twin relationships should never change once established. 139 // Twin relationships should never change once established.
135 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); 140 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl);
136 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); 141 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this);
137 // The twin relationship does not need to exist before the first 142 // The twin relationship does not need to exist before the first
138 // PushPropertiesTo from pending to active layer since before that the active 143 // PushPropertiesTo from pending to active layer since before that the active
139 // layer can not have a pile or tilings, it has only been created and inserted 144 // layer can not have a pile or tilings, it has only been created and inserted
140 // into the tree at that point. 145 // into the tree at that point.
141 twin_layer_ = layer_impl; 146 twin_layer_ = layer_impl;
142 layer_impl->twin_layer_ = this; 147 layer_impl->twin_layer_ = this;
143 148
144 layer_impl->set_is_mask(is_mask_); 149 // Solid color layers have no tilings.
145 layer_impl->UpdateRasterSource(raster_source_); 150 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
151 // The pending tree should only have a high res (and possibly low res) tiling.
152 DCHECK_LE(tilings_->num_tilings(),
153 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u);
146 154
147 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 155 layer_impl->UpdateRasterSource(raster_source_, &invalidation_,
148 // Tilings would be expensive to push, so we swap. 156 tilings_.get());
149 layer_impl->tilings_.swap(tilings_); 157 DCHECK(invalidation_.IsEmpty());
150 layer_impl->tilings_->SetClient(layer_impl);
151 if (tilings_)
152 tilings_->SetClient(this);
153 158
154 // Ensure that the recycle tree doesn't have any unshared tiles. 159 // After syncing a solid color layer, the active layer has no tilings.
155 if (tilings_ && raster_source_->IsSolidColor()) 160 DCHECK_IMPLIES(raster_source_->IsSolidColor(),
156 tilings_->RemoveAllTilings(); 161 !layer_impl->tilings_->num_tilings());
157
158 // Remove invalidated tiles from what will become a recycle tree.
159 if (tilings_)
160 tilings_->RemoveTilesInRegion(invalidation_);
161 162
162 layer_impl->raster_page_scale_ = raster_page_scale_; 163 layer_impl->raster_page_scale_ = raster_page_scale_;
163 layer_impl->raster_device_scale_ = raster_device_scale_; 164 layer_impl->raster_device_scale_ = raster_device_scale_;
164 layer_impl->raster_source_scale_ = raster_source_scale_; 165 layer_impl->raster_source_scale_ = raster_source_scale_;
165 layer_impl->raster_contents_scale_ = raster_contents_scale_; 166 layer_impl->raster_contents_scale_ = raster_contents_scale_;
166 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; 167 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_;
168
169 layer_impl->SanityCheckTilingState();
170
167 layer_impl->needs_post_commit_initialization_ = false; 171 layer_impl->needs_post_commit_initialization_ = false;
168
169 // The invalidation on this soon-to-be-recycled layer must be cleared to
170 // mirror clearing the invalidation in PictureLayer's version of this function
171 // in case push properties is skipped.
172 layer_impl->invalidation_.Swap(&invalidation_);
173 invalidation_.Clear();
174 needs_post_commit_initialization_ = true; 172 needs_post_commit_initialization_ = true;
175 173
176 // We always need to push properties. 174 // We always need to push properties.
177 // See http://crbug.com/303943 175 // See http://crbug.com/303943
176 // TODO(danakj): Stop always pushing properties since we don't swap tilings.
178 needs_push_properties_ = true; 177 needs_push_properties_ = true;
179 } 178 }
180 179
181 void PictureLayerImpl::UpdateRasterSource(
182 scoped_refptr<RasterSource> raster_source) {
183 bool could_have_tilings = CanHaveTilings();
184 raster_source_.swap(raster_source);
185
186 // Need to call UpdateTiles again if CanHaveTilings changed.
187 if (could_have_tilings != CanHaveTilings()) {
188 layer_tree_impl()->set_needs_update_draw_properties();
189 }
190 }
191
192 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, 180 void PictureLayerImpl::AppendQuads(RenderPass* render_pass,
193 const Occlusion& occlusion_in_content_space, 181 const Occlusion& occlusion_in_content_space,
194 AppendQuadsData* append_quads_data) { 182 AppendQuadsData* append_quads_data) {
195 DCHECK(!needs_post_commit_initialization_); 183 DCHECK(!needs_post_commit_initialization_);
196 // The bounds and the pile size may differ if the pile wasn't updated (ie. 184 // The bounds and the pile size may differ if the pile wasn't updated (ie.
197 // PictureLayer::Update didn't happen). In that case the pile will be empty. 185 // PictureLayer::Update didn't happen). In that case the pile will be empty.
198 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), 186 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(),
199 bounds() == raster_source_->GetSize()) 187 bounds() == raster_source_->GetSize())
200 << " bounds " << bounds().ToString() << " pile " 188 << " bounds " << bounds().ToString() << " pile "
201 << raster_source_->GetSize().ToString(); 189 << raster_source_->GetSize().ToString();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 ideal_page_scale_ = 0.f; 473 ideal_page_scale_ = 0.f;
486 ideal_device_scale_ = 0.f; 474 ideal_device_scale_ = 0.f;
487 ideal_contents_scale_ = 0.f; 475 ideal_contents_scale_ = 0.f;
488 ideal_source_scale_ = 0.f; 476 ideal_source_scale_ = 0.f;
489 SanityCheckTilingState(); 477 SanityCheckTilingState();
490 return; 478 return;
491 } 479 }
492 480
493 UpdateIdealScales(); 481 UpdateIdealScales();
494 482
495 DCHECK_IMPLIES(tilings_->num_tilings() == 0, raster_contents_scale_ == 0.f)
496 << "A layer with no tilings shouldn't have valid raster scales";
497 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { 483 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) {
498 RecalculateRasterScales(); 484 RecalculateRasterScales();
499 AddTilingsForRasterScale(); 485 AddTilingsForRasterScale();
500 } 486 }
501 487
502 DCHECK(raster_page_scale_); 488 DCHECK(raster_page_scale_);
503 DCHECK(raster_device_scale_); 489 DCHECK(raster_device_scale_);
504 DCHECK(raster_source_scale_); 490 DCHECK(raster_source_scale_);
505 DCHECK(raster_contents_scale_); 491 DCHECK(raster_contents_scale_);
506 DCHECK(low_res_raster_contents_scale_); 492 DCHECK(low_res_raster_contents_scale_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 return nullptr; 567 return nullptr;
582 return twin_layer_; 568 return twin_layer_;
583 } 569 }
584 570
585 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { 571 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const {
586 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) 572 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree())
587 return nullptr; 573 return nullptr;
588 return twin_layer_; 574 return twin_layer_;
589 } 575 }
590 576
577 void PictureLayerImpl::UpdateRasterSource(
578 scoped_refptr<RasterSource> raster_source,
579 Region* new_invalidation,
580 const PictureLayerTilingSet* pending_set) {
581 // The bounds and the pile size may differ if the pile wasn't updated (ie.
582 // PictureLayer::Update didn't happen). In that case the pile will be empty.
583 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(),
584 bounds() == raster_source->GetSize())
585 << " bounds " << bounds().ToString() << " pile "
586 << raster_source->GetSize().ToString();
587
588 bool could_have_tilings = CanHaveTilings();
589 raster_source_.swap(raster_source);
590
591 // The |new_invalidation| must be cleared before updating tilings since they
592 // access the invalidation through the PictureLayerTilingClient interface.
593 invalidation_.Clear();
594 invalidation_.Swap(new_invalidation);
595 LOG(ERROR) << "Clear pending invalidation";
596
597 bool can_have_tilings = CanHaveTilings();
598
599 // Need to call UpdateTiles again if CanHaveTilings changed.
600 if (could_have_tilings != can_have_tilings)
601 layer_tree_impl()->set_needs_update_draw_properties();
602
603 if (!can_have_tilings) {
604 RemoveAllTilings();
605 return;
606 }
607
608 // We could do this after doing UpdateTiles, which would avoid doing this for
609 // tilings that are going to disappear on the pending tree (if scale changed).
610 // But that would also be more complicated, so we just do it here for now.
611 tilings_->UpdateTilingsToCurrentRasterSource(
612 raster_source_.get(), pending_set, raster_source_->GetSize(),
613 invalidation_, MinimumContentsScale());
614 }
615
591 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { 616 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
592 if (layer_tree_impl()->IsActiveTree()) { 617 if (layer_tree_impl()->IsActiveTree()) {
593 gfx::RectF layer_damage_rect = 618 gfx::RectF layer_damage_rect =
594 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); 619 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale());
595 AddDamageRect(layer_damage_rect); 620 AddDamageRect(layer_damage_rect);
596 } 621 }
597 } 622 }
598 623
599 void PictureLayerImpl::DidBecomeActive() { 624 void PictureLayerImpl::DidBecomeActive() {
600 LayerImpl::DidBecomeActive(); 625 LayerImpl::DidBecomeActive();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) 677 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
653 return &twin_layer->invalidation_; 678 return &twin_layer->invalidation_;
654 return nullptr; 679 return nullptr;
655 } 680 }
656 681
657 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( 682 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling(
658 const PictureLayerTiling* tiling) const { 683 const PictureLayerTiling* tiling) const {
659 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); 684 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
660 if (!twin_layer) 685 if (!twin_layer)
661 return nullptr; 686 return nullptr;
662 // TODO(danakj): Remove this when no longer swapping tilings.
663 if (!twin_layer->tilings_)
664 return nullptr;
665 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale()); 687 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale());
666 } 688 }
667 689
668 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( 690 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling(
669 const PictureLayerTiling* tiling) { 691 const PictureLayerTiling* tiling) {
670 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); 692 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
671 if (!recycled_twin || !recycled_twin->tilings_) 693 if (!recycled_twin || !recycled_twin->tilings_)
672 return nullptr; 694 return nullptr;
673 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale()); 695 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale());
674 } 696 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 tile_height = RoundUp(tile_height, kTileRoundUp); 795 tile_height = RoundUp(tile_height, kTileRoundUp);
774 tile_height = std::min(tile_height, default_tile_height); 796 tile_height = std::min(tile_height, default_tile_height);
775 } 797 }
776 798
777 // Under no circumstance should we be larger than the max texture size. 799 // Under no circumstance should we be larger than the max texture size.
778 tile_width = std::min(tile_width, max_texture_size); 800 tile_width = std::min(tile_width, max_texture_size);
779 tile_height = std::min(tile_height, max_texture_size); 801 tile_height = std::min(tile_height, max_texture_size);
780 return gfx::Size(tile_width, tile_height); 802 return gfx::Size(tile_width, tile_height);
781 } 803 }
782 804
783 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
784 DCHECK(!other->needs_post_commit_initialization_);
785 DCHECK(other->tilings_);
786
787 if (!DrawsContent()) {
788 RemoveAllTilings();
789 return;
790 }
791
792 raster_page_scale_ = other->raster_page_scale_;
793 raster_device_scale_ = other->raster_device_scale_;
794 raster_source_scale_ = other->raster_source_scale_;
795 raster_contents_scale_ = other->raster_contents_scale_;
796 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_;
797
798 bool synced_high_res_tiling = false;
799 if (CanHaveTilings()) {
800 synced_high_res_tiling = tilings_->SyncTilings(
801 *other->tilings_, raster_source_->GetSize(), invalidation_,
802 MinimumContentsScale(), raster_source_.get());
803 } else {
804 RemoveAllTilings();
805 }
806
807 // If our MinimumContentsScale has changed to prevent the twin's high res
808 // tiling from being synced, we should reset the raster scale and let it be
809 // recalculated (1) again. This can happen if our bounds shrink to the point
810 // where min contents scale grows.
811 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we
812 // should refactor this code a little bit and actually recalculate this.
813 // However, this is a larger undertaking, so this will work for now.
814 if (!synced_high_res_tiling)
815 ResetRasterScale();
816 else
817 SanityCheckTilingState();
818 }
819
820 void PictureLayerImpl::SyncTiling(
821 const PictureLayerTiling* tiling) {
822 if (!tilings_)
823 return;
824 if (!CanHaveTilingWithScale(tiling->contents_scale()))
825 return;
826 tilings_->AddTiling(tiling->contents_scale(), raster_source_->GetSize());
827
828 // If this tree needs update draw properties, then the tiling will
829 // get updated prior to drawing or activation. If this tree does not
830 // need update draw properties, then its transforms are up to date and
831 // we can create tiles for this tiling immediately.
832 if (!layer_tree_impl()->needs_update_draw_properties() &&
833 should_update_tile_priorities_) {
834 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking
835 // when we stop using the pending tree in the browser compositor. If we want
836 // to support occlusion tracking here, we need to dirty the draw properties
837 // or save occlusion as a draw property.
838 UpdateTilePriorities(Occlusion());
839 }
840 }
841
842 void PictureLayerImpl::GetContentsResourceId( 805 void PictureLayerImpl::GetContentsResourceId(
843 ResourceProvider::ResourceId* resource_id, 806 ResourceProvider::ResourceId* resource_id,
844 gfx::Size* resource_size) const { 807 gfx::Size* resource_size) const {
845 DCHECK_EQ(bounds().ToString(), raster_source_->GetSize().ToString()); 808 // The bounds and the pile size may differ if the pile wasn't updated (ie.
809 // PictureLayer::Update didn't happen). In that case the pile will be empty.
810 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(),
811 bounds() == raster_source_->GetSize())
812 << " bounds " << bounds().ToString() << " pile "
813 << raster_source_->GetSize().ToString();
846 gfx::Rect content_rect(bounds()); 814 gfx::Rect content_rect(bounds());
847 PictureLayerTilingSet::CoverageIterator iter( 815 PictureLayerTilingSet::CoverageIterator iter(
848 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); 816 tilings_.get(), 1.f, content_rect, ideal_contents_scale_);
849 817
850 // Mask resource not ready yet. 818 // Mask resource not ready yet.
851 if (!iter || !*iter) { 819 if (!iter || !*iter) {
852 *resource_id = 0; 820 *resource_id = 0;
853 return; 821 return;
854 } 822 }
855 823
856 // Masks only supported if they fit on exactly one tile. 824 // Masks only supported if they fit on exactly one tile.
857 DCHECK(iter.geometry_rect() == content_rect) 825 DCHECK(iter.geometry_rect() == content_rect)
858 << "iter rect " << iter.geometry_rect().ToString() << " content rect " 826 << "iter rect " << iter.geometry_rect().ToString() << " content rect "
859 << content_rect.ToString(); 827 << content_rect.ToString();
860 828
861 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); 829 const ManagedTileState::DrawInfo& draw_info = iter->draw_info();
862 if (!draw_info.IsReadyToDraw() || 830 if (!draw_info.IsReadyToDraw() ||
863 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { 831 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) {
864 *resource_id = 0; 832 *resource_id = 0;
865 return; 833 return;
866 } 834 }
867 835
868 *resource_id = draw_info.get_resource_id(); 836 *resource_id = draw_info.get_resource_id();
869 *resource_size = iter.texture_size(); 837 *resource_size = iter.texture_size();
870 } 838 }
871 839
872 void PictureLayerImpl::DoPostCommitInitialization() { 840 void PictureLayerImpl::DoPostCommitInitialization() {
841 // TODO(danakj): Remove this.
873 DCHECK(needs_post_commit_initialization_); 842 DCHECK(needs_post_commit_initialization_);
874 DCHECK(layer_tree_impl()->IsPendingTree()); 843 DCHECK(layer_tree_impl()->IsPendingTree());
875
876 if (!tilings_)
877 tilings_ = PictureLayerTilingSet::Create(this);
878
879 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer();
880 if (twin_layer) {
881 // If the twin has never been pushed to, do not sync from it.
882 // This can happen if this function is called during activation.
883 if (!twin_layer->needs_post_commit_initialization_)
884 SyncFromActiveLayer(twin_layer);
885 }
886
887 needs_post_commit_initialization_ = false; 844 needs_post_commit_initialization_ = false;
888 } 845 }
889 846
890 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 847 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
891 DCHECK(CanHaveTilingWithScale(contents_scale)) << 848 DCHECK(CanHaveTilingWithScale(contents_scale)) <<
892 "contents_scale: " << contents_scale; 849 "contents_scale: " << contents_scale;
893 850
894 PictureLayerTiling* tiling = 851 PictureLayerTiling* tiling =
895 tilings_->AddTiling(contents_scale, raster_source_->GetSize()); 852 tilings_->AddTiling(contents_scale, raster_source_->GetSize());
896 853
897 DCHECK(raster_source_->HasRecordings()); 854 DCHECK(raster_source_->HasRecordings());
898 855
899 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer())
900 twin_layer->SyncTiling(tiling);
901
902 return tiling; 856 return tiling;
903 } 857 }
904 858
905 void PictureLayerImpl::RemoveAllTilings() { 859 void PictureLayerImpl::RemoveAllTilings() {
906 if (tilings_) 860 if (tilings_)
907 tilings_->RemoveAllTilings(); 861 tilings_->RemoveAllTilings();
908 // If there are no tilings, then raster scales are no longer meaningful. 862 // If there are no tilings, then raster scales are no longer meaningful.
909 ResetRasterScale(); 863 ResetRasterScale();
910 } 864 }
911 865
(...skipping 25 matching lines...) Expand all
937 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating) 891 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating)
938 low_res = AddTiling(low_res_raster_contents_scale_); 892 low_res = AddTiling(low_res_raster_contents_scale_);
939 893
940 // Set low-res if we have one. 894 // Set low-res if we have one.
941 if (low_res && low_res != high_res) 895 if (low_res && low_res != high_res)
942 low_res->set_resolution(LOW_RESOLUTION); 896 low_res->set_resolution(LOW_RESOLUTION);
943 897
944 // Make sure we always have one high-res (even if high == low). 898 // Make sure we always have one high-res (even if high == low).
945 high_res->set_resolution(HIGH_RESOLUTION); 899 high_res->set_resolution(HIGH_RESOLUTION);
946 900
901 if (layer_tree_impl()->IsPendingTree()) {
902 // On the pending tree, drop any tilings that are non-ideal since we don't
903 // need them to activate anyway.
904 tilings_->RemoveNonIdealTilings();
905 }
906
947 SanityCheckTilingState(); 907 SanityCheckTilingState();
948 } 908 }
949 909
950 bool PictureLayerImpl::ShouldAdjustRasterScale() const { 910 bool PictureLayerImpl::ShouldAdjustRasterScale() const {
951 if (was_screen_space_transform_animating_ != 911 if (was_screen_space_transform_animating_ !=
952 draw_properties().screen_space_transform_is_animating) 912 draw_properties().screen_space_transform_is_animating)
953 return true; 913 return true;
954 914
955 if (draw_properties().screen_space_transform_is_animating && 915 if (draw_properties().screen_space_transform_is_animating &&
956 raster_contents_scale_ != ideal_contents_scale_ && 916 raster_contents_scale_ != ideal_contents_scale_ &&
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; 1081 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr;
1122 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); 1082 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
1123 PictureLayerTilingSet* recycled_twin_set = 1083 PictureLayerTilingSet* recycled_twin_set =
1124 recycled_twin ? recycled_twin->tilings_.get() : nullptr; 1084 recycled_twin ? recycled_twin->tilings_.get() : nullptr;
1125 1085
1126 tilings_->CleanUpTilings(min_acceptable_high_res_scale, 1086 tilings_->CleanUpTilings(min_acceptable_high_res_scale,
1127 max_acceptable_high_res_scale, used_tilings, 1087 max_acceptable_high_res_scale, used_tilings,
1128 layer_tree_impl()->create_low_res_tiling(), twin_set, 1088 layer_tree_impl()->create_low_res_tiling(), twin_set,
1129 recycled_twin_set); 1089 recycled_twin_set);
1130 1090
1131 if (twin_set && twin_set->num_tilings() == 0)
1132 twin->ResetRasterScale();
1133
1134 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0) 1091 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0)
1135 recycled_twin->ResetRasterScale(); 1092 recycled_twin->ResetRasterScale();
1136 1093
1137 DCHECK_GT(tilings_->num_tilings(), 0u); 1094 DCHECK_GT(tilings_->num_tilings(), 0u);
1138 SanityCheckTilingState(); 1095 SanityCheckTilingState();
1139 } 1096 }
1140 1097
1141 float PictureLayerImpl::MinimumContentsScale() const { 1098 float PictureLayerImpl::MinimumContentsScale() const {
1142 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; 1099 float setting_min = layer_tree_impl()->settings().minimum_contents_scale;
1143 1100
(...skipping 22 matching lines...) Expand all
1166 should_update_tile_priorities_ = false; 1123 should_update_tile_priorities_ = false;
1167 } 1124 }
1168 1125
1169 bool PictureLayerImpl::CanHaveTilings() const { 1126 bool PictureLayerImpl::CanHaveTilings() const {
1170 if (raster_source_->IsSolidColor()) 1127 if (raster_source_->IsSolidColor())
1171 return false; 1128 return false;
1172 if (!DrawsContent()) 1129 if (!DrawsContent())
1173 return false; 1130 return false;
1174 if (!raster_source_->HasRecordings()) 1131 if (!raster_source_->HasRecordings())
1175 return false; 1132 return false;
1133 // If the |raster_source_| has a recording it should have non-empty bounds.
1134 DCHECK(!raster_source_->GetSize().IsEmpty());
1176 return true; 1135 return true;
1177 } 1136 }
1178 1137
1179 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { 1138 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const {
1180 if (!CanHaveTilings()) 1139 if (!CanHaveTilings())
1181 return false; 1140 return false;
1182 if (contents_scale < MinimumContentsScale()) 1141 if (contents_scale < MinimumContentsScale())
1183 return false; 1142 return false;
1184 return true; 1143 return true;
1185 } 1144 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 1329
1371 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1330 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1372 if (!layer_tree_impl()->IsActiveTree()) 1331 if (!layer_tree_impl()->IsActiveTree())
1373 return true; 1332 return true;
1374 1333
1375 return AllTilesRequiredAreReadyToDraw( 1334 return AllTilesRequiredAreReadyToDraw(
1376 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1335 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1377 } 1336 }
1378 1337
1379 } // namespace cc 1338 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698