| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 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::CallFunctionForSubtree( | 108 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 109 root_layer_, [](LayerImpl* layer) { layer->ReleaseResources(); }); | 109 this, [](LayerImpl* layer) { layer->ReleaseResources(); }); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void LayerTreeImpl::RecreateResources() { | 113 void LayerTreeImpl::RecreateResources() { |
| 114 if (root_layer_) { | 114 if (root_layer_) { |
| 115 LayerTreeHostCommon::CallFunctionForSubtree( | 115 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 116 root_layer_, [](LayerImpl* layer) { layer->RecreateResources(); }); | 116 this, [](LayerImpl* layer) { layer->RecreateResources(); }); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void LayerTreeImpl::GatherFrameTimingRequestIds( | 120 void LayerTreeImpl::GatherFrameTimingRequestIds( |
| 121 std::vector<int64_t>* request_ids) { | 121 std::vector<int64_t>* request_ids) { |
| 122 if (!root_layer_) | 122 if (!root_layer_) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 // 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 |
| 126 // 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 |
| 127 // get them. | 127 // get them. |
| 128 LayerTreeHostCommon::CallFunctionForSubtree( | 128 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 129 root_layer_, [request_ids](LayerImpl* layer) { | 129 this, [request_ids](LayerImpl* layer) { |
| 130 layer->GatherFrameTimingRequestIds(request_ids); | 130 layer->GatherFrameTimingRequestIds(request_ids); |
| 131 }); | 131 }); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool LayerTreeImpl::IsViewportLayerId(int id) const { | 134 bool LayerTreeImpl::IsViewportLayerId(int id) const { |
| 135 if (id == inner_viewport_scroll_layer_id_ || | 135 if (id == inner_viewport_scroll_layer_id_ || |
| 136 id == outer_viewport_scroll_layer_id_) | 136 id == outer_viewport_scroll_layer_id_) |
| 137 return true; | 137 return true; |
| 138 if (InnerViewportContainerLayer() && | 138 if (InnerViewportContainerLayer() && |
| 139 id == InnerViewportContainerLayer()->id()) | 139 id == InnerViewportContainerLayer()->id()) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 | 557 |
| 558 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { | 558 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { |
| 559 // TODO(enne): This should get replaced by pulling out scrolling and | 559 // TODO(enne): This should get replaced by pulling out scrolling and |
| 560 // animations into their own trees. Then scrolls and animations would have | 560 // animations into their own trees. Then scrolls and animations would have |
| 561 // their own ways of synchronizing across commits. This occurs to push | 561 // their own ways of synchronizing across commits. This occurs to push |
| 562 // updates from scrolling deltas on the compositor thread that have occurred | 562 // updates from scrolling deltas on the compositor thread that have occurred |
| 563 // after begin frame and updates from animations that have ticked since begin | 563 // after begin frame and updates from animations that have ticked since begin |
| 564 // frame to a newly-committed property tree. | 564 // frame to a newly-committed property tree. |
| 565 if (!root_layer()) | 565 if (!root_layer()) |
| 566 return; | 566 return; |
| 567 LayerTreeHostCommon::CallFunctionForSubtree( | 567 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { |
| 568 root_layer(), [](LayerImpl* layer) { | 568 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
| 569 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 569 }); |
| 570 }); | |
| 571 } | 570 } |
| 572 | 571 |
| 573 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 572 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
| 574 DCHECK(IsActiveTree()); | 573 DCHECK(IsActiveTree()); |
| 575 if (page_scale_factor()->SetCurrent( | 574 if (page_scale_factor()->SetCurrent( |
| 576 ClampPageScaleFactorToLimits(active_page_scale))) { | 575 ClampPageScaleFactorToLimits(active_page_scale))) { |
| 577 DidUpdatePageScale(); | 576 DidUpdatePageScale(); |
| 578 if (PageScaleLayer()) { | 577 if (PageScaleLayer()) { |
| 579 draw_property_utils::UpdatePageScaleFactor( | 578 draw_property_utils::UpdatePageScaleFactor( |
| 580 property_trees(), PageScaleLayer(), current_page_scale_factor(), | 579 property_trees(), PageScaleLayer(), current_page_scale_factor(), |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 845 |
| 847 { | 846 { |
| 848 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", | 847 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", |
| 849 "IsActive", IsActiveTree(), "SourceFrameNumber", | 848 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 850 source_frame_number_); | 849 source_frame_number_); |
| 851 OcclusionTracker occlusion_tracker( | 850 OcclusionTracker occlusion_tracker( |
| 852 root_layer()->render_surface()->content_rect()); | 851 root_layer()->render_surface()->content_rect()); |
| 853 occlusion_tracker.set_minimum_tracking_size( | 852 occlusion_tracker.set_minimum_tracking_size( |
| 854 settings().minimum_occlusion_tracking_size); | 853 settings().minimum_occlusion_tracking_size); |
| 855 | 854 |
| 856 // LayerIterator is used here instead of CallFunctionForSubtree to only | 855 // LayerIterator is used here instead of CallFunctionForEveryLayer to only |
| 857 // UpdateTilePriorities on layers that will be visible (and thus have valid | 856 // UpdateTilePriorities on layers that will be visible (and thus have valid |
| 858 // draw properties) and not because any ordering is required. | 857 // draw properties) and not because any ordering is required. |
| 859 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | 858 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); |
| 860 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | 859 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); |
| 861 it != end; ++it) { | 860 it != end; ++it) { |
| 862 occlusion_tracker.EnterLayer(it); | 861 occlusion_tracker.EnterLayer(it); |
| 863 | 862 |
| 864 bool inside_replica = it->render_target()->InsideReplica(); | 863 bool inside_replica = it->render_target()->InsideReplica(); |
| 865 | 864 |
| 866 // Don't use occlusion if a layer will appear in a replica, since the | 865 // Don't use occlusion if a layer will appear in a replica, since the |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 if (next_activation_forces_redraw_) { | 1069 if (next_activation_forces_redraw_) { |
| 1071 layer_tree_host_impl_->SetFullRootLayerDamage(); | 1070 layer_tree_host_impl_->SetFullRootLayerDamage(); |
| 1072 next_activation_forces_redraw_ = false; | 1071 next_activation_forces_redraw_ = false; |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 // Always reset this flag on activation, as we would only have activated | 1074 // Always reset this flag on activation, as we would only have activated |
| 1076 // if we were in a good state. | 1075 // if we were in a good state. |
| 1077 layer_tree_host_impl_->ResetRequiresHighResToDraw(); | 1076 layer_tree_host_impl_->ResetRequiresHighResToDraw(); |
| 1078 | 1077 |
| 1079 if (root_layer()) { | 1078 if (root_layer()) { |
| 1080 LayerTreeHostCommon::CallFunctionForSubtree( | 1079 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 1081 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); | 1080 this, [](LayerImpl* layer) { layer->DidBecomeActive(); }); |
| 1082 } | 1081 } |
| 1083 | 1082 |
| 1084 for (const auto& swap_promise : swap_promise_list_) | 1083 for (const auto& swap_promise : swap_promise_list_) |
| 1085 swap_promise->DidActivate(); | 1084 swap_promise->DidActivate(); |
| 1086 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), | 1085 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), |
| 1087 source_frame_number_); | 1086 source_frame_number_); |
| 1088 } | 1087 } |
| 1089 | 1088 |
| 1090 bool LayerTreeImpl::RequiresHighResToDraw() const { | 1089 bool LayerTreeImpl::RequiresHighResToDraw() const { |
| 1091 return layer_tree_host_impl_->RequiresHighResToDraw(); | 1090 return layer_tree_host_impl_->RequiresHighResToDraw(); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 } | 2094 } |
| 2096 | 2095 |
| 2097 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2096 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
| 2098 layers_that_should_push_properties_.clear(); | 2097 layers_that_should_push_properties_.clear(); |
| 2099 for (auto* layer : *this) | 2098 for (auto* layer : *this) |
| 2100 layer->ResetChangeTracking(); | 2099 layer->ResetChangeTracking(); |
| 2101 property_trees_.ResetAllChangeTracking(flag); | 2100 property_trees_.ResetAllChangeTracking(flag); |
| 2102 } | 2101 } |
| 2103 | 2102 |
| 2104 } // namespace cc | 2103 } // namespace cc |
| OLD | NEW |