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

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

Issue 1421483005: Reland: Remove DCHECK_IMPLIES/CHECK_IMPLIES. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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.cc ('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 <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 synced_scroll_offset()); 93 synced_scroll_offset());
94 } 94 }
95 95
96 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { 96 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
97 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 97 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
98 DCHECK_EQ(layer_impl->is_mask_, is_mask_); 98 DCHECK_EQ(layer_impl->is_mask_, is_mask_);
99 99
100 LayerImpl::PushPropertiesTo(base_layer); 100 LayerImpl::PushPropertiesTo(base_layer);
101 101
102 // Twin relationships should never change once established. 102 // Twin relationships should never change once established.
103 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); 103 DCHECK(!twin_layer_ || twin_layer_ == layer_impl);
104 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); 104 DCHECK(!twin_layer_ || layer_impl->twin_layer_ == this);
105 // The twin relationship does not need to exist before the first 105 // The twin relationship does not need to exist before the first
106 // PushPropertiesTo from pending to active layer since before that the active 106 // PushPropertiesTo from pending to active layer since before that the active
107 // layer can not have a pile or tilings, it has only been created and inserted 107 // layer can not have a pile or tilings, it has only been created and inserted
108 // into the tree at that point. 108 // into the tree at that point.
109 twin_layer_ = layer_impl; 109 twin_layer_ = layer_impl;
110 layer_impl->twin_layer_ = this; 110 layer_impl->twin_layer_ = this;
111 111
112 layer_impl->SetNearestNeighbor(nearest_neighbor_); 112 layer_impl->SetNearestNeighbor(nearest_neighbor_);
113 113
114 // Solid color layers have no tilings. 114 // Solid color layers have no tilings.
115 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 115 DCHECK(!raster_source_->IsSolidColor() || tilings_->num_tilings() == 0);
116 // The pending tree should only have a high res (and possibly low res) tiling. 116 // The pending tree should only have a high res (and possibly low res) tiling.
117 DCHECK_LE(tilings_->num_tilings(), 117 DCHECK_LE(tilings_->num_tilings(),
118 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); 118 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u);
119 119
120 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_); 120 layer_impl->set_gpu_raster_max_texture_size(gpu_raster_max_texture_size_);
121 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, 121 layer_impl->UpdateRasterSource(raster_source_, &invalidation_,
122 tilings_.get()); 122 tilings_.get());
123 DCHECK(invalidation_.IsEmpty()); 123 DCHECK(invalidation_.IsEmpty());
124 124
125 // After syncing a solid color layer, the active layer has no tilings. 125 // After syncing a solid color layer, the active layer has no tilings.
126 DCHECK_IMPLIES(raster_source_->IsSolidColor(), 126 DCHECK(!raster_source_->IsSolidColor() ||
127 layer_impl->tilings_->num_tilings() == 0); 127 layer_impl->tilings_->num_tilings() == 0);
128 128
129 layer_impl->raster_page_scale_ = raster_page_scale_; 129 layer_impl->raster_page_scale_ = raster_page_scale_;
130 layer_impl->raster_device_scale_ = raster_device_scale_; 130 layer_impl->raster_device_scale_ = raster_device_scale_;
131 layer_impl->raster_source_scale_ = raster_source_scale_; 131 layer_impl->raster_source_scale_ = raster_source_scale_;
132 layer_impl->raster_contents_scale_ = raster_contents_scale_; 132 layer_impl->raster_contents_scale_ = raster_contents_scale_;
133 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; 133 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_;
134 134
135 layer_impl->SanityCheckTilingState(); 135 layer_impl->SanityCheckTilingState();
136 136
137 // We always need to push properties. 137 // We always need to push properties.
138 // See http://crbug.com/303943 138 // See http://crbug.com/303943
139 // TODO(danakj): Stop always pushing properties since we don't swap tilings. 139 // TODO(danakj): Stop always pushing properties since we don't swap tilings.
140 needs_push_properties_ = true; 140 needs_push_properties_ = true;
141 } 141 }
142 142
143 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, 143 void PictureLayerImpl::AppendQuads(RenderPass* render_pass,
144 AppendQuadsData* append_quads_data) { 144 AppendQuadsData* append_quads_data) {
145 // The bounds and the pile size may differ if the pile wasn't updated (ie. 145 // The bounds and the pile size may differ if the pile wasn't updated (ie.
146 // PictureLayer::Update didn't happen). In that case the pile will be empty. 146 // PictureLayer::Update didn't happen). In that case the pile will be empty.
147 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), 147 DCHECK(raster_source_->GetSize().IsEmpty() ||
148 bounds() == raster_source_->GetSize()) 148 bounds() == raster_source_->GetSize())
149 << " bounds " << bounds().ToString() << " pile " 149 << " bounds " << bounds().ToString() << " pile "
150 << raster_source_->GetSize().ToString(); 150 << raster_source_->GetSize().ToString();
151 151
152 SharedQuadState* shared_quad_state = 152 SharedQuadState* shared_quad_state =
153 render_pass->CreateAndAppendSharedQuadState(); 153 render_pass->CreateAndAppendSharedQuadState();
154 154
155 if (raster_source_->IsSolidColor()) { 155 if (raster_source_->IsSolidColor()) {
156 PopulateSharedQuadState(shared_quad_state); 156 PopulateSharedQuadState(shared_quad_state);
157 157
158 AppendDebugBorderQuad( 158 AppendDebugBorderQuad(
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 return nullptr; 522 return nullptr;
523 return twin_layer_; 523 return twin_layer_;
524 } 524 }
525 525
526 void PictureLayerImpl::UpdateRasterSource( 526 void PictureLayerImpl::UpdateRasterSource(
527 scoped_refptr<DisplayListRasterSource> raster_source, 527 scoped_refptr<DisplayListRasterSource> raster_source,
528 Region* new_invalidation, 528 Region* new_invalidation,
529 const PictureLayerTilingSet* pending_set) { 529 const PictureLayerTilingSet* pending_set) {
530 // The bounds and the pile size may differ if the pile wasn't updated (ie. 530 // The bounds and the pile size may differ if the pile wasn't updated (ie.
531 // PictureLayer::Update didn't happen). In that case the pile will be empty. 531 // PictureLayer::Update didn't happen). In that case the pile will be empty.
532 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), 532 DCHECK(raster_source->GetSize().IsEmpty() ||
533 bounds() == raster_source->GetSize()) 533 bounds() == raster_source->GetSize())
534 << " bounds " << bounds().ToString() << " pile " 534 << " bounds " << bounds().ToString() << " pile "
535 << raster_source->GetSize().ToString(); 535 << raster_source->GetSize().ToString();
536 536
537 // The |raster_source_| is initially null, so have to check for that for the 537 // The |raster_source_| is initially null, so have to check for that for the
538 // first frame. 538 // first frame.
539 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); 539 bool could_have_tilings = raster_source_.get() && CanHaveTilings();
540 raster_source_.swap(raster_source); 540 raster_source_.swap(raster_source);
541 541
542 // The |new_invalidation| must be cleared before updating tilings since they 542 // The |new_invalidation| must be cleared before updating tilings since they
543 // access the invalidation through the PictureLayerTilingClient interface. 543 // access the invalidation through the PictureLayerTilingClient interface.
544 invalidation_.Clear(); 544 invalidation_.Clear();
545 invalidation_.Swap(new_invalidation); 545 invalidation_.Swap(new_invalidation);
546 546
547 bool can_have_tilings = CanHaveTilings(); 547 bool can_have_tilings = CanHaveTilings();
548 DCHECK_IMPLIES( 548 DCHECK(!pending_set ||
549 pending_set, 549 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings());
550 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings());
551 550
552 // Need to call UpdateTiles again if CanHaveTilings changed. 551 // Need to call UpdateTiles again if CanHaveTilings changed.
553 if (could_have_tilings != can_have_tilings) 552 if (could_have_tilings != can_have_tilings)
554 layer_tree_impl()->set_needs_update_draw_properties(); 553 layer_tree_impl()->set_needs_update_draw_properties();
555 554
556 if (!can_have_tilings) { 555 if (!can_have_tilings) {
557 RemoveAllTilings(); 556 RemoveAllTilings();
558 return; 557 return;
559 } 558 }
560 559
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // Under no circumstance should we be larger than the max texture size. 771 // Under no circumstance should we be larger than the max texture size.
773 tile_width = std::min(tile_width, max_texture_size); 772 tile_width = std::min(tile_width, max_texture_size);
774 tile_height = std::min(tile_height, max_texture_size); 773 tile_height = std::min(tile_height, max_texture_size);
775 return gfx::Size(tile_width, tile_height); 774 return gfx::Size(tile_width, tile_height);
776 } 775 }
777 776
778 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, 777 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id,
779 gfx::Size* resource_size) const { 778 gfx::Size* resource_size) const {
780 // The bounds and the pile size may differ if the pile wasn't updated (ie. 779 // The bounds and the pile size may differ if the pile wasn't updated (ie.
781 // PictureLayer::Update didn't happen). In that case the pile will be empty. 780 // PictureLayer::Update didn't happen). In that case the pile will be empty.
782 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), 781 DCHECK(raster_source_->GetSize().IsEmpty() ||
783 bounds() == raster_source_->GetSize()) 782 bounds() == raster_source_->GetSize())
784 << " bounds " << bounds().ToString() << " pile " 783 << " bounds " << bounds().ToString() << " pile "
785 << raster_source_->GetSize().ToString(); 784 << raster_source_->GetSize().ToString();
786 gfx::Rect content_rect(bounds()); 785 gfx::Rect content_rect(bounds());
787 PictureLayerTilingSet::CoverageIterator iter( 786 PictureLayerTilingSet::CoverageIterator iter(
788 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); 787 tilings_.get(), 1.f, content_rect, ideal_contents_scale_);
789 788
790 // Mask resource not ready yet. 789 // Mask resource not ready yet.
791 if (!iter || !*iter) { 790 if (!iter || !*iter) {
792 *resource_id = 0; 791 *resource_id = 0;
793 return; 792 return;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 return; 912 return;
914 913
915 // We should have a high resolution tiling at raster_contents_scale, so if the 914 // We should have a high resolution tiling at raster_contents_scale, so if the
916 // low res one is the same then we shouldn't try to override this tiling by 915 // low res one is the same then we shouldn't try to override this tiling by
917 // marking it as a low res. 916 // marking it as a low res.
918 if (raster_contents_scale_ == low_res_raster_contents_scale_) 917 if (raster_contents_scale_ == low_res_raster_contents_scale_)
919 return; 918 return;
920 919
921 PictureLayerTiling* low_res = 920 PictureLayerTiling* low_res =
922 tilings_->FindTilingWithScale(low_res_raster_contents_scale_); 921 tilings_->FindTilingWithScale(low_res_raster_contents_scale_);
923 DCHECK_IMPLIES(low_res, low_res->resolution() != HIGH_RESOLUTION); 922 DCHECK(!low_res || low_res->resolution() != HIGH_RESOLUTION);
924 923
925 // Only create new low res tilings when the transform is static. This 924 // Only create new low res tilings when the transform is static. This
926 // prevents wastefully creating a paired low res tiling for every new high 925 // prevents wastefully creating a paired low res tiling for every new high
927 // res tiling during a pinch or a CSS animation. 926 // res tiling during a pinch or a CSS animation.
928 bool is_pinching = layer_tree_impl()->PinchGestureActive(); 927 bool is_pinching = layer_tree_impl()->PinchGestureActive();
929 bool is_animating = draw_properties().screen_space_transform_is_animating; 928 bool is_animating = draw_properties().screen_space_transform_is_animating;
930 if (!is_pinching && !is_animating) { 929 if (!is_pinching && !is_animating) {
931 if (!low_res) 930 if (!low_res)
932 low_res = AddTiling(low_res_raster_contents_scale_); 931 low_res = AddTiling(low_res_raster_contents_scale_);
933 low_res->set_resolution(LOW_RESOLUTION); 932 low_res->set_resolution(LOW_RESOLUTION);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1262
1264 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1263 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1265 return !layer_tree_impl()->IsRecycleTree(); 1264 return !layer_tree_impl()->IsRecycleTree();
1266 } 1265 }
1267 1266
1268 bool PictureLayerImpl::HasValidTilePriorities() const { 1267 bool PictureLayerImpl::HasValidTilePriorities() const {
1269 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1268 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1270 } 1269 }
1271 1270
1272 } // namespace cc 1271 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698