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

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

Issue 1924933002: cc : Stop pushing properties not used by LayerImpl to LayerImpl (4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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/layer_impl.h ('k') | cc/layers/layer_impl_test_properties.h » ('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/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 27 matching lines...) Expand all
38 #include "ui/gfx/geometry/box_f.h" 38 #include "ui/gfx/geometry/box_f.h"
39 #include "ui/gfx/geometry/point_conversions.h" 39 #include "ui/gfx/geometry/point_conversions.h"
40 #include "ui/gfx/geometry/quad_f.h" 40 #include "ui/gfx/geometry/quad_f.h"
41 #include "ui/gfx/geometry/rect_conversions.h" 41 #include "ui/gfx/geometry/rect_conversions.h"
42 #include "ui/gfx/geometry/size_conversions.h" 42 #include "ui/gfx/geometry/size_conversions.h"
43 #include "ui/gfx/geometry/vector2d_conversions.h" 43 #include "ui/gfx/geometry/vector2d_conversions.h"
44 44
45 namespace cc { 45 namespace cc {
46 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) 46 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
47 : parent_(nullptr), 47 : parent_(nullptr),
48 scroll_parent_(nullptr),
49 clip_parent_(nullptr),
50 mask_layer_id_(-1), 48 mask_layer_id_(-1),
51 mask_layer_(nullptr), 49 mask_layer_(nullptr),
52 replica_layer_id_(-1), 50 replica_layer_id_(-1),
53 replica_layer_(nullptr), 51 replica_layer_(nullptr),
54 layer_id_(id), 52 layer_id_(id),
55 layer_tree_impl_(tree_impl), 53 layer_tree_impl_(tree_impl),
56 test_properties_(nullptr), 54 test_properties_(nullptr),
57 scroll_clip_layer_id_(Layer::INVALID_ID), 55 scroll_clip_layer_id_(Layer::INVALID_ID),
58 main_thread_scrolling_reasons_( 56 main_thread_scrolling_reasons_(
59 MainThreadScrollingReason::kNotScrollingOnMain), 57 MainThreadScrollingReason::kNotScrollingOnMain),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 layer_tree_impl_->RemoveLayer(child->id()); 139 layer_tree_impl_->RemoveLayer(child->id());
142 children_.clear(); 140 children_.clear();
143 } 141 }
144 142
145 void LayerImpl::ClearLinksToOtherLayers() { 143 void LayerImpl::ClearLinksToOtherLayers() {
146 children_.clear(); 144 children_.clear();
147 mask_layer_ = nullptr; 145 mask_layer_ = nullptr;
148 replica_layer_ = nullptr; 146 replica_layer_ = nullptr;
149 } 147 }
150 148
151 void LayerImpl::SetScrollParent(LayerImpl* parent) {
152 if (scroll_parent_ == parent)
153 return;
154
155 if (parent)
156 DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent);
157
158 scroll_parent_ = parent;
159 SetNeedsPushProperties();
160 }
161
162 void LayerImpl::SetDebugInfo( 149 void LayerImpl::SetDebugInfo(
163 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { 150 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) {
164 owned_debug_info_ = std::move(debug_info); 151 owned_debug_info_ = std::move(debug_info);
165 debug_info_ = owned_debug_info_.get(); 152 debug_info_ = owned_debug_info_.get();
166 SetNeedsPushProperties(); 153 SetNeedsPushProperties();
167 } 154 }
168 155
169 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) {
170 if (scroll_children_.get() == children)
171 return;
172 scroll_children_.reset(children);
173 SetNeedsPushProperties();
174 }
175
176 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { 156 void LayerImpl::DistributeScroll(ScrollState* scroll_state) {
177 DCHECK(scroll_state); 157 DCHECK(scroll_state);
178 if (scroll_state->FullyConsumed()) 158 if (scroll_state->FullyConsumed())
179 return; 159 return;
180 160
181 scroll_state->DistributeToScrollChainDescendant(); 161 scroll_state->DistributeToScrollChainDescendant();
182 162
183 // If the scroll doesn't propagate, and we're currently scrolling 163 // If the scroll doesn't propagate, and we're currently scrolling
184 // a layer other than this one, prevent the scroll from 164 // a layer other than this one, prevent the scroll from
185 // propagating to this layer. 165 // propagating to this layer.
186 if (!scroll_state->should_propagate() && 166 if (!scroll_state->should_propagate() &&
187 scroll_state->delta_consumed_for_scroll_sequence() && 167 scroll_state->delta_consumed_for_scroll_sequence() &&
188 scroll_state->current_native_scrolling_node()->owner_id != id()) { 168 scroll_state->current_native_scrolling_node()->owner_id != id()) {
189 return; 169 return;
190 } 170 }
191 171
192 ApplyScroll(scroll_state); 172 ApplyScroll(scroll_state);
193 } 173 }
194 174
195 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { 175 void LayerImpl::ApplyScroll(ScrollState* scroll_state) {
196 DCHECK(scroll_state); 176 DCHECK(scroll_state);
197 ScrollNode* node = layer_tree_impl()->property_trees()->scroll_tree.Node( 177 ScrollNode* node = layer_tree_impl()->property_trees()->scroll_tree.Node(
198 scroll_tree_index()); 178 scroll_tree_index());
199 layer_tree_impl()->ApplyScroll(node, scroll_state); 179 layer_tree_impl()->ApplyScroll(node, scroll_state);
200 } 180 }
201 181
202 void LayerImpl::SetClipParent(LayerImpl* ancestor) {
203 if (clip_parent_ == ancestor)
204 return;
205
206 clip_parent_ = ancestor;
207 SetNeedsPushProperties();
208 }
209
210 void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) {
211 if (clip_children_.get() == children)
212 return;
213 clip_children_.reset(children);
214 SetNeedsPushProperties();
215 }
216
217 void LayerImpl::SetTransformTreeIndex(int index) { 182 void LayerImpl::SetTransformTreeIndex(int index) {
218 transform_tree_index_ = index; 183 transform_tree_index_ = index;
219 SetNeedsPushProperties(); 184 SetNeedsPushProperties();
220 } 185 }
221 186
222 void LayerImpl::SetClipTreeIndex(int index) { 187 void LayerImpl::SetClipTreeIndex(int index) {
223 clip_tree_index_ = index; 188 clip_tree_index_ = index;
224 SetNeedsPushProperties(); 189 SetNeedsPushProperties();
225 } 190 }
226 191
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 475 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
511 476
512 layer->Set3dSortingContextId(sorting_context_id_); 477 layer->Set3dSortingContextId(sorting_context_id_);
513 478
514 layer->SetTransformTreeIndex(transform_tree_index_); 479 layer->SetTransformTreeIndex(transform_tree_index_);
515 layer->SetClipTreeIndex(clip_tree_index_); 480 layer->SetClipTreeIndex(clip_tree_index_);
516 layer->SetEffectTreeIndex(effect_tree_index_); 481 layer->SetEffectTreeIndex(effect_tree_index_);
517 layer->SetScrollTreeIndex(scroll_tree_index_); 482 layer->SetScrollTreeIndex(scroll_tree_index_);
518 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 483 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
519 484
520 LayerImpl* scroll_parent = nullptr;
521 if (scroll_parent_) {
522 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
523 DCHECK(scroll_parent);
524 }
525
526 layer->SetScrollParent(scroll_parent);
527 if (scroll_children_) {
528 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>;
529 for (std::set<LayerImpl*>::iterator it = scroll_children_->begin();
530 it != scroll_children_->end();
531 ++it) {
532 DCHECK_EQ((*it)->scroll_parent(), this);
533 LayerImpl* scroll_child =
534 layer->layer_tree_impl()->LayerById((*it)->id());
535 DCHECK(scroll_child);
536 scroll_children->insert(scroll_child);
537 }
538 layer->SetScrollChildren(scroll_children);
539 } else {
540 layer->SetScrollChildren(nullptr);
541 }
542
543 LayerImpl* clip_parent = nullptr;
544 if (clip_parent_) {
545 clip_parent = layer->layer_tree_impl()->LayerById(
546 clip_parent_->id());
547 DCHECK(clip_parent);
548 }
549
550 layer->SetClipParent(clip_parent);
551 if (clip_children_) {
552 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>;
553 for (std::set<LayerImpl*>::iterator it = clip_children_->begin();
554 it != clip_children_->end(); ++it)
555 clip_children->insert(layer->layer_tree_impl()->LayerById((*it)->id()));
556 layer->SetClipChildren(clip_children);
557 } else {
558 layer->SetClipChildren(nullptr);
559 }
560
561 layer->PassCopyRequests(&copy_requests_); 485 layer->PassCopyRequests(&copy_requests_);
562 486
563 // If the main thread commits multiple times before the impl thread actually 487 // If the main thread commits multiple times before the impl thread actually
564 // draws, then damage tracking will become incorrect if we simply clobber the 488 // draws, then damage tracking will become incorrect if we simply clobber the
565 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 489 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
566 // union) any update changes that have occurred on the main thread. 490 // union) any update changes that have occurred on the main thread.
567 update_rect_.Union(layer->update_rect()); 491 update_rect_.Union(layer->update_rect());
568 layer->SetUpdateRect(update_rect_); 492 layer->SetUpdateRect(update_rect_);
569 493
570 if (owned_debug_info_) 494 if (owned_debug_info_)
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 state->BeginDictionary("mask_layer"); 1283 state->BeginDictionary("mask_layer");
1360 mask_layer_->AsValueInto(state); 1284 mask_layer_->AsValueInto(state);
1361 state->EndDictionary(); 1285 state->EndDictionary();
1362 } 1286 }
1363 if (replica_layer_) { 1287 if (replica_layer_) {
1364 state->BeginDictionary("replica_layer"); 1288 state->BeginDictionary("replica_layer");
1365 replica_layer_->AsValueInto(state); 1289 replica_layer_->AsValueInto(state);
1366 state->EndDictionary(); 1290 state->EndDictionary();
1367 } 1291 }
1368 1292
1369 if (scroll_parent_)
1370 state->SetInteger("scroll_parent", scroll_parent_->id());
1371
1372 if (clip_parent_)
1373 state->SetInteger("clip_parent", clip_parent_->id());
1374
1375 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1293 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1376 state->SetBoolean("contents_opaque", contents_opaque()); 1294 state->SetBoolean("contents_opaque", contents_opaque());
1377 1295
1378 state->SetBoolean("has_animation_bounds", 1296 state->SetBoolean("has_animation_bounds",
1379 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); 1297 layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1380 1298
1381 gfx::BoxF box; 1299 gfx::BoxF box;
1382 if (LayerUtils::GetAnimationBounds(*this, &box)) 1300 if (LayerUtils::GetAnimationBounds(*this, &box))
1383 MathUtil::AddToTracedValue("animation_bounds", box, state); 1301 MathUtil::AddToTracedValue("animation_bounds", box, state);
1384 1302
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 .layer_transforms_should_scale_layer_contents) { 1441 .layer_transforms_should_scale_layer_contents) {
1524 return default_scale; 1442 return default_scale;
1525 } 1443 }
1526 1444
1527 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1445 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1528 DrawTransform(), default_scale); 1446 DrawTransform(), default_scale);
1529 return std::max(transform_scales.x(), transform_scales.y()); 1447 return std::max(transform_scales.x(), transform_scales.y());
1530 } 1448 }
1531 1449
1532 } // namespace cc 1450 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_test_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698