Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 namespace cc { | 50 namespace cc { |
| 51 | 51 |
| 52 LayerTreeImpl::LayerTreeImpl( | 52 LayerTreeImpl::LayerTreeImpl( |
| 53 LayerTreeHostImpl* layer_tree_host_impl, | 53 LayerTreeHostImpl* layer_tree_host_impl, |
| 54 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 54 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 55 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 55 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
| 56 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) | 56 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
| 57 : layer_tree_host_impl_(layer_tree_host_impl), | 57 : layer_tree_host_impl_(layer_tree_host_impl), |
| 58 source_frame_number_(-1), | 58 source_frame_number_(-1), |
| 59 is_first_frame_after_commit_tracker_(-1), | 59 is_first_frame_after_commit_tracker_(-1), |
| 60 hud_layer_(0), | 60 root_layer_(nullptr), |
| 61 hud_layer_(nullptr), | |
| 61 background_color_(0), | 62 background_color_(0), |
| 62 has_transparent_background_(false), | 63 has_transparent_background_(false), |
| 63 last_scrolled_layer_id_(Layer::INVALID_ID), | 64 last_scrolled_layer_id_(Layer::INVALID_ID), |
| 64 overscroll_elasticity_layer_id_(Layer::INVALID_ID), | 65 overscroll_elasticity_layer_id_(Layer::INVALID_ID), |
| 65 page_scale_layer_id_(Layer::INVALID_ID), | 66 page_scale_layer_id_(Layer::INVALID_ID), |
| 66 inner_viewport_scroll_layer_id_(Layer::INVALID_ID), | 67 inner_viewport_scroll_layer_id_(Layer::INVALID_ID), |
| 67 outer_viewport_scroll_layer_id_(Layer::INVALID_ID), | 68 outer_viewport_scroll_layer_id_(Layer::INVALID_ID), |
| 68 page_scale_factor_(page_scale_factor), | 69 page_scale_factor_(page_scale_factor), |
| 69 min_page_scale_factor_(0), | 70 min_page_scale_factor_(0), |
| 70 max_page_scale_factor_(0), | 71 max_page_scale_factor_(0), |
| 71 device_scale_factor_(1.f), | 72 device_scale_factor_(1.f), |
| 72 painted_device_scale_factor_(1.f), | 73 painted_device_scale_factor_(1.f), |
| 73 elastic_overscroll_(elastic_overscroll), | 74 elastic_overscroll_(elastic_overscroll), |
| 75 layers_(new OwnedLayerImplList), | |
| 74 viewport_size_invalid_(false), | 76 viewport_size_invalid_(false), |
| 75 needs_update_draw_properties_(true), | 77 needs_update_draw_properties_(true), |
| 76 needs_full_tree_sync_(true), | 78 needs_full_tree_sync_(true), |
| 77 next_activation_forces_redraw_(false), | 79 next_activation_forces_redraw_(false), |
| 78 has_ever_been_drawn_(false), | 80 has_ever_been_drawn_(false), |
| 79 render_surface_layer_list_id_(0), | 81 render_surface_layer_list_id_(0), |
| 80 have_scroll_event_handlers_(false), | 82 have_scroll_event_handlers_(false), |
| 81 event_listener_properties_(), | 83 event_listener_properties_(), |
| 82 top_controls_shrink_blink_size_(false), | 84 top_controls_shrink_blink_size_(false), |
| 83 top_controls_height_(0), | 85 top_controls_height_(0), |
| 84 top_controls_shown_ratio_(top_controls_shown_ratio) { | 86 top_controls_shown_ratio_(top_controls_shown_ratio) { |
| 85 property_trees()->is_main_thread = false; | 87 property_trees()->is_main_thread = false; |
| 86 } | 88 } |
| 87 | 89 |
| 88 LayerTreeImpl::~LayerTreeImpl() { | 90 LayerTreeImpl::~LayerTreeImpl() { |
| 89 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS | 91 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS |
| 90 : SwapPromise::ACTIVATION_FAILS); | 92 : SwapPromise::ACTIVATION_FAILS); |
| 91 | 93 |
| 92 // Need to explicitly clear the tree prior to destroying this so that | 94 // Need to explicitly clear the tree prior to destroying this so that |
| 93 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 95 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
| 94 DCHECK(!root_layer_); | 96 DCHECK(!root_layer_); |
| 95 DCHECK(layers_with_copy_output_request_.empty()); | 97 DCHECK(layers_with_copy_output_request_.empty()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void LayerTreeImpl::Shutdown() { | 100 void LayerTreeImpl::Shutdown() { |
| 101 if (root_layer_) | |
| 102 RemoveLayer(root_layer_->id()); | |
| 99 root_layer_ = nullptr; | 103 root_layer_ = nullptr; |
| 100 } | 104 } |
| 101 | 105 |
| 102 void LayerTreeImpl::ReleaseResources() { | 106 void LayerTreeImpl::ReleaseResources() { |
| 103 if (root_layer_) { | 107 if (root_layer_) { |
| 104 LayerTreeHostCommon::CallFunctionForSubtree( | 108 LayerTreeHostCommon::CallFunctionForSubtree( |
| 105 root_layer_.get(), [](LayerImpl* layer) { layer->ReleaseResources(); }); | 109 root_layer_, [](LayerImpl* layer) { layer->ReleaseResources(); }); |
| 106 } | 110 } |
| 107 } | 111 } |
| 108 | 112 |
| 109 void LayerTreeImpl::RecreateResources() { | 113 void LayerTreeImpl::RecreateResources() { |
| 110 if (root_layer_) { | 114 if (root_layer_) { |
| 111 LayerTreeHostCommon::CallFunctionForSubtree( | 115 LayerTreeHostCommon::CallFunctionForSubtree( |
| 112 root_layer_.get(), | 116 root_layer_, [](LayerImpl* layer) { layer->RecreateResources(); }); |
| 113 [](LayerImpl* layer) { layer->RecreateResources(); }); | |
| 114 } | 117 } |
| 115 } | 118 } |
| 116 | 119 |
| 117 void LayerTreeImpl::GatherFrameTimingRequestIds( | 120 void LayerTreeImpl::GatherFrameTimingRequestIds( |
| 118 std::vector<int64_t>* request_ids) { | 121 std::vector<int64_t>* request_ids) { |
| 119 if (!root_layer_) | 122 if (!root_layer_) |
| 120 return; | 123 return; |
| 121 | 124 |
| 122 // TODO(vmpstr): Early out if there are no requests on any of the layers. For | 125 // TODO(vmpstr): Early out if there are no requests on any of the layers. For |
| 123 // that, we need to inform LayerTreeImpl whenever there are requests when we | 126 // that, we need to inform LayerTreeImpl whenever there are requests when we |
| 124 // get them. | 127 // get them. |
| 125 LayerTreeHostCommon::CallFunctionForSubtree( | 128 LayerTreeHostCommon::CallFunctionForSubtree( |
| 126 root_layer_.get(), [request_ids](LayerImpl* layer) { | 129 root_layer_, [request_ids](LayerImpl* layer) { |
| 127 layer->GatherFrameTimingRequestIds(request_ids); | 130 layer->GatherFrameTimingRequestIds(request_ids); |
| 128 }); | 131 }); |
| 129 } | 132 } |
| 130 | 133 |
| 131 bool LayerTreeImpl::IsViewportLayerId(int id) const { | 134 bool LayerTreeImpl::IsViewportLayerId(int id) const { |
| 132 if (id == inner_viewport_scroll_layer_id_ || | 135 if (id == inner_viewport_scroll_layer_id_ || |
| 133 id == outer_viewport_scroll_layer_id_) | 136 id == outer_viewport_scroll_layer_id_) |
| 134 return true; | 137 return true; |
| 135 if (InnerViewportContainerLayer() && | 138 if (InnerViewportContainerLayer() && |
| 136 id == InnerViewportContainerLayer()->id()) | 139 id == InnerViewportContainerLayer()->id()) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 if (scrollbar_needs_animation) { | 265 if (scrollbar_needs_animation) { |
| 263 ScrollbarAnimationController* controller = | 266 ScrollbarAnimationController* controller = |
| 264 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 267 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
| 265 scroll_layer_id); | 268 scroll_layer_id); |
| 266 if (controller) | 269 if (controller) |
| 267 controller->DidScrollUpdate(scroll_layer_size_did_change); | 270 controller->DidScrollUpdate(scroll_layer_size_did_change); |
| 268 } | 271 } |
| 269 } | 272 } |
| 270 | 273 |
| 271 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { | 274 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
| 272 root_layer_ = std::move(layer); | 275 if (root_layer_ && layer.get() != root_layer_) |
| 273 | 276 RemoveLayer(root_layer_->id()); |
| 277 root_layer_ = layer.get(); | |
| 278 if (layer) | |
| 279 AddLayer(std::move(layer)); | |
| 274 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); | 280 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
| 275 } | 281 } |
| 276 | 282 |
| 277 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { | 283 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { |
| 278 return LayerById(inner_viewport_scroll_layer_id_); | 284 return LayerById(inner_viewport_scroll_layer_id_); |
| 279 } | 285 } |
| 280 | 286 |
| 281 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { | 287 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { |
| 282 return LayerById(outer_viewport_scroll_layer_id_); | 288 return LayerById(outer_viewport_scroll_layer_id_); |
| 283 } | 289 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 299 | 305 |
| 300 if (InnerViewportScrollLayer()) | 306 if (InnerViewportScrollLayer()) |
| 301 offset += InnerViewportScrollLayer()->MaxScrollOffset(); | 307 offset += InnerViewportScrollLayer()->MaxScrollOffset(); |
| 302 | 308 |
| 303 if (OuterViewportScrollLayer()) | 309 if (OuterViewportScrollLayer()) |
| 304 offset += OuterViewportScrollLayer()->MaxScrollOffset(); | 310 offset += OuterViewportScrollLayer()->MaxScrollOffset(); |
| 305 | 311 |
| 306 return offset; | 312 return offset; |
| 307 } | 313 } |
| 308 | 314 |
| 309 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { | 315 scoped_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { |
| 310 render_surface_layer_list_.clear(); | 316 render_surface_layer_list_.clear(); |
| 311 set_needs_update_draw_properties(); | 317 set_needs_update_draw_properties(); |
| 312 return std::move(root_layer_); | 318 scoped_ptr<OwnedLayerImplList> ret = std::move(layers_); |
| 319 layers_.reset(new OwnedLayerImplList); | |
| 320 return ret; | |
| 321 } | |
| 322 | |
| 323 void LayerTreeImpl::ClearLayers() { | |
| 324 SetRootLayer(nullptr); | |
| 325 DCHECK(layers_->empty()); | |
| 313 } | 326 } |
| 314 | 327 |
| 315 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, | 328 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, |
| 316 ClipTree* clip_tree) { | 329 ClipTree* clip_tree) { |
| 317 if (layer && layer->masks_to_bounds()) { | 330 if (layer && layer->masks_to_bounds()) { |
| 318 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index()); | 331 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index()); |
| 319 if (clip_node) { | 332 if (clip_node) { |
| 320 DCHECK_EQ(layer->id(), clip_node->owner_id); | 333 DCHECK_EQ(layer->id(), clip_node->owner_id); |
| 321 gfx::SizeF bounds = gfx::SizeF(layer->bounds()); | 334 gfx::SizeF bounds = gfx::SizeF(layer->bounds()); |
| 322 if (clip_node->data.clip.size() != bounds) { | 335 if (clip_node->data.clip.size() != bounds) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 424 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
| 412 LayerTreeHostCommon::FindLayerInSubtree(target_tree->root_layer(), | 425 LayerTreeHostCommon::FindLayerInSubtree(target_tree->root_layer(), |
| 413 hud_layer()->id()))); | 426 hud_layer()->id()))); |
| 414 else | 427 else |
| 415 target_tree->set_hud_layer(NULL); | 428 target_tree->set_hud_layer(NULL); |
| 416 | 429 |
| 417 target_tree->has_ever_been_drawn_ = false; | 430 target_tree->has_ever_been_drawn_ = false; |
| 418 } | 431 } |
| 419 | 432 |
| 420 LayerListIterator LayerTreeImpl::begin() { | 433 LayerListIterator LayerTreeImpl::begin() { |
| 421 return LayerListIterator(root_layer_.get()); | 434 return LayerListIterator(root_layer_); |
| 422 } | 435 } |
| 423 | 436 |
| 424 LayerListIterator LayerTreeImpl::end() { | 437 LayerListIterator LayerTreeImpl::end() { |
| 425 return LayerListIterator(nullptr); | 438 return LayerListIterator(nullptr); |
| 426 } | 439 } |
| 427 | 440 |
| 428 LayerListReverseIterator LayerTreeImpl::rbegin() { | 441 LayerListReverseIterator LayerTreeImpl::rbegin() { |
| 429 return LayerListReverseIterator(root_layer_.get()); | 442 return LayerListReverseIterator(root_layer_); |
| 430 } | 443 } |
| 431 | 444 |
| 432 LayerListReverseIterator LayerTreeImpl::rend() { | 445 LayerListReverseIterator LayerTreeImpl::rend() { |
| 433 return LayerListReverseIterator(nullptr); | 446 return LayerListReverseIterator(nullptr); |
| 434 } | 447 } |
| 435 | 448 |
| 436 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { | 449 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { |
| 437 if (!layer->element_id() || !layer->mutable_properties()) | 450 if (!layer->element_id() || !layer->mutable_properties()) |
| 438 return; | 451 return; |
| 439 | 452 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 return gfx::ScaleSize(InnerViewportContainerLayer()->BoundsForScrolling(), | 717 return gfx::ScaleSize(InnerViewportContainerLayer()->BoundsForScrolling(), |
| 705 1.0f / current_page_scale_factor()); | 718 1.0f / current_page_scale_factor()); |
| 706 } | 719 } |
| 707 | 720 |
| 708 gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { | 721 gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { |
| 709 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 722 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 710 ? OuterViewportScrollLayer() | 723 ? OuterViewportScrollLayer() |
| 711 : InnerViewportScrollLayer(); | 724 : InnerViewportScrollLayer(); |
| 712 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 725 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
| 713 return gfx::Rect(); | 726 return gfx::Rect(); |
| 714 LayerImpl* layer = root_scroll_layer->children()[0].get(); | 727 LayerImpl* layer = root_scroll_layer->children()[0]; |
| 715 return MathUtil::MapEnclosingClippedRect(layer->ScreenSpaceTransform(), | 728 return MathUtil::MapEnclosingClippedRect(layer->ScreenSpaceTransform(), |
| 716 gfx::Rect(layer->bounds())); | 729 gfx::Rect(layer->bounds())); |
| 717 } | 730 } |
| 718 | 731 |
| 719 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { | 732 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { |
| 720 DCHECK(IsActiveTree()); | 733 DCHECK(IsActiveTree()); |
| 721 | 734 |
| 722 page_scale_factor()->AbortCommit(); | 735 page_scale_factor()->AbortCommit(); |
| 723 top_controls_shown_ratio()->AbortCommit(); | 736 top_controls_shown_ratio()->AbortCommit(); |
| 724 elastic_overscroll()->AbortCommit(); | 737 elastic_overscroll()->AbortCommit(); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", | 952 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 940 "layers_updated_count", layers_updated_count); | 953 "layers_updated_count", layers_updated_count); |
| 941 } | 954 } |
| 942 | 955 |
| 943 DCHECK(!needs_update_draw_properties_) | 956 DCHECK(!needs_update_draw_properties_) |
| 944 << "CalcDrawProperties should not set_needs_update_draw_properties()"; | 957 << "CalcDrawProperties should not set_needs_update_draw_properties()"; |
| 945 return true; | 958 return true; |
| 946 } | 959 } |
| 947 | 960 |
| 948 void LayerTreeImpl::BuildPropertyTreesForTesting() { | 961 void LayerTreeImpl::BuildPropertyTreesForTesting() { |
| 949 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer_.get()); | 962 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer_); |
| 950 property_trees_.transform_tree.set_source_to_parent_updates_allowed(true); | 963 property_trees_.transform_tree.set_source_to_parent_updates_allowed(true); |
| 951 PropertyTreeBuilder::BuildPropertyTrees( | 964 PropertyTreeBuilder::BuildPropertyTrees( |
| 952 root_layer_.get(), PageScaleLayer(), InnerViewportScrollLayer(), | 965 root_layer_, PageScaleLayer(), InnerViewportScrollLayer(), |
| 953 OuterViewportScrollLayer(), OverscrollElasticityLayer(), | 966 OuterViewportScrollLayer(), OverscrollElasticityLayer(), |
| 954 elastic_overscroll()->Current(IsActiveTree()), | 967 elastic_overscroll()->Current(IsActiveTree()), |
| 955 current_page_scale_factor(), device_scale_factor(), | 968 current_page_scale_factor(), device_scale_factor(), |
| 956 gfx::Rect(DrawViewportSize()), layer_tree_host_impl_->DrawTransform(), | 969 gfx::Rect(DrawViewportSize()), layer_tree_host_impl_->DrawTransform(), |
| 957 &property_trees_); | 970 &property_trees_); |
| 958 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); | 971 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); |
| 959 } | 972 } |
| 960 | 973 |
| 961 void LayerTreeImpl::IncrementRenderSurfaceListIdForTesting() { | 974 void LayerTreeImpl::IncrementRenderSurfaceListIdForTesting() { |
| 962 render_surface_layer_list_id_++; | 975 render_surface_layer_list_id_++; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 985 gfx::SizeF content_size = | 998 gfx::SizeF content_size = |
| 986 root_scroll_layer->children()[0]->BoundsForScrolling(); | 999 root_scroll_layer->children()[0]->BoundsForScrolling(); |
| 987 gfx::SizeF viewport_size = | 1000 gfx::SizeF viewport_size = |
| 988 root_scroll_layer->scroll_clip_layer()->BoundsForScrolling(); | 1001 root_scroll_layer->scroll_clip_layer()->BoundsForScrolling(); |
| 989 | 1002 |
| 990 content_size.SetToMax(viewport_size); | 1003 content_size.SetToMax(viewport_size); |
| 991 return content_size; | 1004 return content_size; |
| 992 } | 1005 } |
| 993 | 1006 |
| 994 LayerImpl* LayerTreeImpl::LayerById(int id) const { | 1007 LayerImpl* LayerTreeImpl::LayerById(int id) const { |
| 995 LayerIdMap::const_iterator iter = layer_id_map_.find(id); | 1008 LayerImplMap::const_iterator iter = layer_id_map_.find(id); |
| 996 return iter != layer_id_map_.end() ? iter->second : NULL; | 1009 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 997 } | 1010 } |
| 998 | 1011 |
| 999 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { | 1012 void LayerTreeImpl::AddLayerShouldPushProperties(LayerImpl* layer) { |
| 1000 layers_that_should_push_properties_.insert(layer); | 1013 layers_that_should_push_properties_.insert(layer); |
| 1001 } | 1014 } |
| 1002 | 1015 |
| 1003 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { | 1016 void LayerTreeImpl::RemoveLayerShouldPushProperties(LayerImpl* layer) { |
| 1004 layers_that_should_push_properties_.erase(layer); | 1017 layers_that_should_push_properties_.erase(layer); |
| 1005 } | 1018 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1020 layer_tree_host_impl_->animation_host()->RegisterLayer( | 1033 layer_tree_host_impl_->animation_host()->RegisterLayer( |
| 1021 layer->id(), | 1034 layer->id(), |
| 1022 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); | 1035 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
| 1023 } | 1036 } |
| 1024 | 1037 |
| 1025 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 1038 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 1026 DCHECK(LayerById(layer->id())); | 1039 DCHECK(LayerById(layer->id())); |
| 1027 layer_tree_host_impl_->animation_host()->UnregisterLayer( | 1040 layer_tree_host_impl_->animation_host()->UnregisterLayer( |
| 1028 layer->id(), | 1041 layer->id(), |
| 1029 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); | 1042 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
| 1043 if (layer == root_layer_) | |
| 1044 root_layer_ = nullptr; | |
|
ajuma
2016/03/18 22:09:21
When does the root layer need to get cleared this
Ian Vollick
2016/03/19 03:05:22
Turns out never. Removed.
| |
| 1030 layer_id_map_.erase(layer->id()); | 1045 layer_id_map_.erase(layer->id()); |
| 1031 } | 1046 } |
| 1032 | 1047 |
| 1048 // These manage ownership of the LayerImpl. | |
| 1049 void LayerTreeImpl::AddLayer(scoped_ptr<LayerImpl> layer) { | |
| 1050 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); | |
| 1051 layers_->push_back(std::move(layer)); | |
| 1052 set_needs_update_draw_properties(); | |
| 1053 } | |
| 1054 | |
| 1055 scoped_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { | |
| 1056 for (auto it = layers_->begin(); it != layers_->end(); ++it) { | |
| 1057 if ((*it) && (*it)->id() != id) | |
| 1058 continue; | |
| 1059 scoped_ptr<LayerImpl> ret = std::move(*it); | |
| 1060 set_needs_update_draw_properties(); | |
| 1061 layers_->erase(it); | |
| 1062 return ret; | |
| 1063 } | |
| 1064 return nullptr; | |
| 1065 } | |
| 1066 | |
| 1033 size_t LayerTreeImpl::NumLayers() { | 1067 size_t LayerTreeImpl::NumLayers() { |
| 1034 return layer_id_map_.size(); | 1068 return layer_id_map_.size(); |
| 1035 } | 1069 } |
| 1036 | 1070 |
| 1037 void LayerTreeImpl::DidBecomeActive() { | 1071 void LayerTreeImpl::DidBecomeActive() { |
| 1038 if (next_activation_forces_redraw_) { | 1072 if (next_activation_forces_redraw_) { |
| 1039 layer_tree_host_impl_->SetFullRootLayerDamage(); | 1073 layer_tree_host_impl_->SetFullRootLayerDamage(); |
| 1040 next_activation_forces_redraw_ = false; | 1074 next_activation_forces_redraw_ = false; |
| 1041 } | 1075 } |
| 1042 | 1076 |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2062 } | 2096 } |
| 2063 | 2097 |
| 2064 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2098 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
| 2065 layers_that_should_push_properties_.clear(); | 2099 layers_that_should_push_properties_.clear(); |
| 2066 for (auto* layer : *this) | 2100 for (auto* layer : *this) |
| 2067 layer->ResetChangeTracking(); | 2101 layer->ResetChangeTracking(); |
| 2068 property_trees_.ResetAllChangeTracking(flag); | 2102 property_trees_.ResetAllChangeTracking(flag); |
| 2069 } | 2103 } |
| 2070 | 2104 |
| 2071 } // namespace cc | 2105 } // namespace cc |
| OLD | NEW |