| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 void LayerTreeImpl::Shutdown() { | 100 void LayerTreeImpl::Shutdown() { |
| 101 if (root_layer_) | 101 if (root_layer_) |
| 102 RemoveLayer(root_layer_->id()); | 102 RemoveLayer(root_layer_->id()); |
| 103 root_layer_ = nullptr; | 103 root_layer_ = nullptr; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void LayerTreeImpl::ReleaseResources() { | 106 void LayerTreeImpl::ReleaseResources() { |
| 107 if (root_layer_) { | 107 if (root_layer_) { |
| 108 LayerTreeHostCommon::CallFunctionForEveryLayer( | 108 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 109 this, [](LayerImpl* layer) { layer->ReleaseResources(); }); | 109 this, [](LayerImpl* layer) { layer->ReleaseResources(); }, |
| 110 CallFunctionLayerType::ALL_LAYERS); |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 | 113 |
| 113 void LayerTreeImpl::RecreateResources() { | 114 void LayerTreeImpl::RecreateResources() { |
| 114 if (root_layer_) { | 115 if (root_layer_) { |
| 115 LayerTreeHostCommon::CallFunctionForEveryLayer( | 116 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 116 this, [](LayerImpl* layer) { layer->RecreateResources(); }); | 117 this, [](LayerImpl* layer) { layer->RecreateResources(); }, |
| 118 CallFunctionLayerType::ALL_LAYERS); |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 | 121 |
| 120 void LayerTreeImpl::GatherFrameTimingRequestIds( | 122 void LayerTreeImpl::GatherFrameTimingRequestIds( |
| 121 std::vector<int64_t>* request_ids) { | 123 std::vector<int64_t>* request_ids) { |
| 122 if (!root_layer_) | 124 if (!root_layer_) |
| 123 return; | 125 return; |
| 124 | 126 |
| 125 // TODO(vmpstr): Early out if there are no requests on any of the layers. For | 127 // TODO(vmpstr): Early out if there are no requests on any of the layers. For |
| 126 // that, we need to inform LayerTreeImpl whenever there are requests when we | 128 // that, we need to inform LayerTreeImpl whenever there are requests when we |
| 127 // get them. | 129 // get them. |
| 128 LayerTreeHostCommon::CallFunctionForEveryLayer( | 130 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 129 this, [request_ids](LayerImpl* layer) { | 131 this, |
| 132 [request_ids](LayerImpl* layer) { |
| 130 layer->GatherFrameTimingRequestIds(request_ids); | 133 layer->GatherFrameTimingRequestIds(request_ids); |
| 131 }); | 134 }, |
| 135 CallFunctionLayerType::ALL_LAYERS); |
| 132 } | 136 } |
| 133 | 137 |
| 134 bool LayerTreeImpl::IsViewportLayerId(int id) const { | 138 bool LayerTreeImpl::IsViewportLayerId(int id) const { |
| 135 if (id == inner_viewport_scroll_layer_id_ || | 139 if (id == inner_viewport_scroll_layer_id_ || |
| 136 id == outer_viewport_scroll_layer_id_) | 140 id == outer_viewport_scroll_layer_id_) |
| 137 return true; | 141 return true; |
| 138 if (InnerViewportContainerLayer() && | 142 if (InnerViewportContainerLayer() && |
| 139 id == InnerViewportContainerLayer()->id()) | 143 id == InnerViewportContainerLayer()->id()) |
| 140 return true; | 144 return true; |
| 141 if (OuterViewportContainerLayer() && | 145 if (OuterViewportContainerLayer() && |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 | 561 |
| 558 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { | 562 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { |
| 559 // TODO(enne): This should get replaced by pulling out scrolling and | 563 // TODO(enne): This should get replaced by pulling out scrolling and |
| 560 // animations into their own trees. Then scrolls and animations would have | 564 // animations into their own trees. Then scrolls and animations would have |
| 561 // their own ways of synchronizing across commits. This occurs to push | 565 // their own ways of synchronizing across commits. This occurs to push |
| 562 // updates from scrolling deltas on the compositor thread that have occurred | 566 // updates from scrolling deltas on the compositor thread that have occurred |
| 563 // after begin frame and updates from animations that have ticked since begin | 567 // after begin frame and updates from animations that have ticked since begin |
| 564 // frame to a newly-committed property tree. | 568 // frame to a newly-committed property tree. |
| 565 if (!root_layer()) | 569 if (!root_layer()) |
| 566 return; | 570 return; |
| 567 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { | 571 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 568 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 572 this, |
| 569 }); | 573 [](LayerImpl* layer) { |
| 574 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
| 575 }, |
| 576 CallFunctionLayerType::ALL_LAYERS); |
| 570 } | 577 } |
| 571 | 578 |
| 572 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 579 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
| 573 DCHECK(IsActiveTree()); | 580 DCHECK(IsActiveTree()); |
| 574 if (page_scale_factor()->SetCurrent( | 581 if (page_scale_factor()->SetCurrent( |
| 575 ClampPageScaleFactorToLimits(active_page_scale))) { | 582 ClampPageScaleFactorToLimits(active_page_scale))) { |
| 576 DidUpdatePageScale(); | 583 DidUpdatePageScale(); |
| 577 if (PageScaleLayer()) { | 584 if (PageScaleLayer()) { |
| 578 draw_property_utils::UpdatePageScaleFactor( | 585 draw_property_utils::UpdatePageScaleFactor( |
| 579 property_trees(), PageScaleLayer(), current_page_scale_factor(), | 586 property_trees(), PageScaleLayer(), current_page_scale_factor(), |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 layer_tree_host_impl_->SetFullRootLayerDamage(); | 1076 layer_tree_host_impl_->SetFullRootLayerDamage(); |
| 1070 next_activation_forces_redraw_ = false; | 1077 next_activation_forces_redraw_ = false; |
| 1071 } | 1078 } |
| 1072 | 1079 |
| 1073 // Always reset this flag on activation, as we would only have activated | 1080 // Always reset this flag on activation, as we would only have activated |
| 1074 // if we were in a good state. | 1081 // if we were in a good state. |
| 1075 layer_tree_host_impl_->ResetRequiresHighResToDraw(); | 1082 layer_tree_host_impl_->ResetRequiresHighResToDraw(); |
| 1076 | 1083 |
| 1077 if (root_layer()) { | 1084 if (root_layer()) { |
| 1078 LayerTreeHostCommon::CallFunctionForEveryLayer( | 1085 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 1079 this, [](LayerImpl* layer) { layer->DidBecomeActive(); }); | 1086 this, [](LayerImpl* layer) { layer->DidBecomeActive(); }, |
| 1087 CallFunctionLayerType::ALL_LAYERS); |
| 1080 } | 1088 } |
| 1081 | 1089 |
| 1082 for (const auto& swap_promise : swap_promise_list_) | 1090 for (const auto& swap_promise : swap_promise_list_) |
| 1083 swap_promise->DidActivate(); | 1091 swap_promise->DidActivate(); |
| 1084 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), | 1092 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), |
| 1085 source_frame_number_); | 1093 source_frame_number_); |
| 1086 } | 1094 } |
| 1087 | 1095 |
| 1088 bool LayerTreeImpl::RequiresHighResToDraw() const { | 1096 bool LayerTreeImpl::RequiresHighResToDraw() const { |
| 1089 return layer_tree_host_impl_->RequiresHighResToDraw(); | 1097 return layer_tree_host_impl_->RequiresHighResToDraw(); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 } | 2101 } |
| 2094 | 2102 |
| 2095 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2103 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
| 2096 layers_that_should_push_properties_.clear(); | 2104 layers_that_should_push_properties_.clear(); |
| 2097 for (auto* layer : *this) | 2105 for (auto* layer : *this) |
| 2098 layer->ResetChangeTracking(); | 2106 layer->ResetChangeTracking(); |
| 2099 property_trees_.ResetAllChangeTracking(flag); | 2107 property_trees_.ResetAllChangeTracking(flag); |
| 2100 } | 2108 } |
| 2101 | 2109 |
| 2102 } // namespace cc | 2110 } // namespace cc |
| OLD | NEW |