Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 user_scrollable_horizontal(true), | 58 user_scrollable_horizontal(true), |
| 59 user_scrollable_vertical(true), | 59 user_scrollable_vertical(true), |
| 60 main_thread_scrolling_reasons( | 60 main_thread_scrolling_reasons( |
| 61 MainThreadScrollingReason::kNotScrollingOnMain), | 61 MainThreadScrollingReason::kNotScrollingOnMain), |
| 62 is_container_for_fixed_position_layers(false), | 62 is_container_for_fixed_position_layers(false), |
| 63 mutable_properties(MutableProperty::kNone), | 63 mutable_properties(MutableProperty::kNone), |
| 64 scroll_parent(nullptr), | 64 scroll_parent(nullptr), |
| 65 clip_parent(nullptr), | 65 clip_parent(nullptr), |
| 66 has_will_change_transform_hint(false), | 66 has_will_change_transform_hint(false), |
| 67 hide_layer_and_subtree(false), | 67 hide_layer_and_subtree(false), |
| 68 client(nullptr) {} | 68 client(nullptr), |
| 69 scroll_boundary_behavior( | |
| 70 ScrollBoundaryBehavior::kScrollBoundaryBehaviorTypeAuto) {} | |
| 69 | 71 |
| 70 Layer::Inputs::~Inputs() {} | 72 Layer::Inputs::~Inputs() {} |
| 71 | 73 |
| 72 scoped_refptr<Layer> Layer::Create() { | 74 scoped_refptr<Layer> Layer::Create() { |
| 73 return make_scoped_refptr(new Layer()); | 75 return make_scoped_refptr(new Layer()); |
| 74 } | 76 } |
| 75 | 77 |
| 76 Layer::Layer() | 78 Layer::Layer() |
| 77 : ignore_set_needs_commit_(false), | 79 : ignore_set_needs_commit_(false), |
| 78 parent_(nullptr), | 80 parent_(nullptr), |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 auto& scroll_tree = layer_tree_host_->property_trees()->scroll_tree; | 301 auto& scroll_tree = layer_tree_host_->property_trees()->scroll_tree; |
| 300 if (auto* scroll_node = scroll_tree.Node(scroll_tree_index_)) | 302 if (auto* scroll_node = scroll_tree.Node(scroll_tree_index_)) |
| 301 scroll_node->bounds = inputs_.bounds; | 303 scroll_node->bounds = inputs_.bounds; |
| 302 else | 304 else |
| 303 SetPropertyTreesNeedRebuild(); | 305 SetPropertyTreesNeedRebuild(); |
| 304 } | 306 } |
| 305 | 307 |
| 306 SetNeedsCommit(); | 308 SetNeedsCommit(); |
| 307 } | 309 } |
| 308 | 310 |
| 311 void Layer::SetScrollBoundaryBehavior(const ScrollBoundaryBehavior& behavior) { | |
| 312 if (scroll_boundary_behavior() == behavior) | |
| 313 return; | |
| 314 inputs_.scroll_boundary_behavior = behavior; | |
|
ajuma
2017/06/30 20:46:49
This also needs to update the scroll node if there
sunyunjia
2017/07/14 02:59:00
Done.
| |
| 315 | |
| 316 SetNeedsCommit(); | |
| 317 } | |
| 318 | |
| 309 Layer* Layer::RootLayer() { | 319 Layer* Layer::RootLayer() { |
| 310 Layer* layer = this; | 320 Layer* layer = this; |
| 311 while (layer->parent()) | 321 while (layer->parent()) |
| 312 layer = layer->parent(); | 322 layer = layer->parent(); |
| 313 return layer; | 323 return layer; |
| 314 } | 324 } |
| 315 | 325 |
| 316 void Layer::RemoveAllChildren() { | 326 void Layer::RemoveAllChildren() { |
| 317 DCHECK(IsPropertyChangeAllowed()); | 327 DCHECK(IsPropertyChangeAllowed()); |
| 318 while (inputs_.children.size()) { | 328 while (inputs_.children.size()) { |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1197 layer->set_needs_show_scrollbars(true); | 1207 layer->set_needs_show_scrollbars(true); |
| 1198 | 1208 |
| 1199 // If the main thread commits multiple times before the impl thread actually | 1209 // If the main thread commits multiple times before the impl thread actually |
| 1200 // draws, then damage tracking will become incorrect if we simply clobber the | 1210 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1201 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1211 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1202 // union) any update changes that have occurred on the main thread. | 1212 // union) any update changes that have occurred on the main thread. |
| 1203 inputs_.update_rect.Union(layer->update_rect()); | 1213 inputs_.update_rect.Union(layer->update_rect()); |
| 1204 layer->SetUpdateRect(inputs_.update_rect); | 1214 layer->SetUpdateRect(inputs_.update_rect); |
| 1205 | 1215 |
| 1206 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1216 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1217 layer->SetScrollBoundaryBehavior(inputs_.scroll_boundary_behavior); | |
| 1207 layer->SetNeedsPushProperties(); | 1218 layer->SetNeedsPushProperties(); |
| 1208 | 1219 |
| 1209 // Reset any state that should be cleared for the next update. | 1220 // Reset any state that should be cleared for the next update. |
| 1210 needs_show_scrollbars_ = false; | 1221 needs_show_scrollbars_ = false; |
| 1211 subtree_property_changed_ = false; | 1222 subtree_property_changed_ = false; |
| 1212 inputs_.update_rect = gfx::Rect(); | 1223 inputs_.update_rect = gfx::Rect(); |
| 1213 | 1224 |
| 1214 if (mask_layer()) | 1225 if (mask_layer()) |
| 1215 DCHECK_EQ(bounds().ToString(), mask_layer()->bounds().ToString()); | 1226 DCHECK_EQ(bounds().ToString(), mask_layer()->bounds().ToString()); |
| 1216 layer_tree_host_->RemoveLayerShouldPushProperties(this); | 1227 layer_tree_host_->RemoveLayerShouldPushProperties(this); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1441 ->subtree_has_copy_request; | 1452 ->subtree_has_copy_request; |
| 1442 } | 1453 } |
| 1443 | 1454 |
| 1444 gfx::Transform Layer::ScreenSpaceTransform() const { | 1455 gfx::Transform Layer::ScreenSpaceTransform() const { |
| 1445 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1456 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1446 return draw_property_utils::ScreenSpaceTransform( | 1457 return draw_property_utils::ScreenSpaceTransform( |
| 1447 this, layer_tree_host_->property_trees()->transform_tree); | 1458 this, layer_tree_host_->property_trees()->transform_tree); |
| 1448 } | 1459 } |
| 1449 | 1460 |
| 1450 } // namespace cc | 1461 } // namespace cc |
| OLD | NEW |