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

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 1846043002: cc : Make CallFunctionForSubtree on impl use layer iterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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
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 root_layer_, [](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 root_layer_, [](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 root_layer_, [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() &&
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
568 root_layer(), [](LayerImpl* layer) { 568 root_layer(), [](LayerImpl* layer) {
569 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); 569 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded();
570 }); 570 });
571 } 571 }
572 572
573 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { 573 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) {
574 DCHECK(IsActiveTree()); 574 DCHECK(IsActiveTree());
575 if (page_scale_factor()->SetCurrent( 575 if (page_scale_factor()->SetCurrent(
576 ClampPageScaleFactorToLimits(active_page_scale))) { 576 ClampPageScaleFactorToLimits(active_page_scale))) {
577 DidUpdatePageScale(); 577 DidUpdatePageScale();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 846
847 { 847 {
848 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", 848 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion",
849 "IsActive", IsActiveTree(), "SourceFrameNumber", 849 "IsActive", IsActiveTree(), "SourceFrameNumber",
850 source_frame_number_); 850 source_frame_number_);
851 OcclusionTracker occlusion_tracker( 851 OcclusionTracker occlusion_tracker(
852 root_layer()->render_surface()->content_rect()); 852 root_layer()->render_surface()->content_rect());
853 occlusion_tracker.set_minimum_tracking_size( 853 occlusion_tracker.set_minimum_tracking_size(
854 settings().minimum_occlusion_tracking_size); 854 settings().minimum_occlusion_tracking_size);
855 855
856 // LayerIterator is used here instead of CallFunctionForSubtree to only 856 // LayerIterator is used here instead of CallFunctionForEveryLayer to only
857 // UpdateTilePriorities on layers that will be visible (and thus have valid 857 // UpdateTilePriorities on layers that will be visible (and thus have valid
858 // draw properties) and not because any ordering is required. 858 // draw properties) and not because any ordering is required.
859 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); 859 LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
860 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); 860 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
861 it != end; ++it) { 861 it != end; ++it) {
862 occlusion_tracker.EnterLayer(it); 862 occlusion_tracker.EnterLayer(it);
863 863
864 bool inside_replica = it->render_target()->InsideReplica(); 864 bool inside_replica = it->render_target()->InsideReplica();
865 865
866 // Don't use occlusion if a layer will appear in a replica, since the 866 // 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
1070 if (next_activation_forces_redraw_) { 1070 if (next_activation_forces_redraw_) {
1071 layer_tree_host_impl_->SetFullRootLayerDamage(); 1071 layer_tree_host_impl_->SetFullRootLayerDamage();
1072 next_activation_forces_redraw_ = false; 1072 next_activation_forces_redraw_ = false;
1073 } 1073 }
1074 1074
1075 // Always reset this flag on activation, as we would only have activated 1075 // Always reset this flag on activation, as we would only have activated
1076 // if we were in a good state. 1076 // if we were in a good state.
1077 layer_tree_host_impl_->ResetRequiresHighResToDraw(); 1077 layer_tree_host_impl_->ResetRequiresHighResToDraw();
1078 1078
1079 if (root_layer()) { 1079 if (root_layer()) {
1080 LayerTreeHostCommon::CallFunctionForSubtree( 1080 LayerTreeHostCommon::CallFunctionForEveryLayer(
1081 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); 1081 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); });
1082 } 1082 }
1083 1083
1084 for (const auto& swap_promise : swap_promise_list_) 1084 for (const auto& swap_promise : swap_promise_list_)
1085 swap_promise->DidActivate(); 1085 swap_promise->DidActivate();
1086 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), 1086 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(),
1087 source_frame_number_); 1087 source_frame_number_);
1088 } 1088 }
1089 1089
1090 bool LayerTreeImpl::RequiresHighResToDraw() const { 1090 bool LayerTreeImpl::RequiresHighResToDraw() const {
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 } 2095 }
2096 2096
2097 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { 2097 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) {
2098 layers_that_should_push_properties_.clear(); 2098 layers_that_should_push_properties_.clear();
2099 for (auto* layer : *this) 2099 for (auto* layer : *this)
2100 layer->ResetChangeTracking(); 2100 layer->ResetChangeTracking();
2101 property_trees_.ResetAllChangeTracking(flag); 2101 property_trees_.ResetAllChangeTracking(flag);
2102 } 2102 }
2103 2103
2104 } // namespace cc 2104 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common.h ('K') | « cc/trees/layer_tree_host_unittest_serialization.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698