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

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

Issue 2751783002: cc: Replace LayerIterator with iterator that walks layer list and effect tree (Closed)
Patch Set: Rebase Created 3 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
« no previous file with comments | « cc/trees/layer_tree_host_unittest_copyrequest.cc ('k') | cc/trees/occlusion_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 #include <iterator> 11 #include <iterator>
12 #include <limits> 12 #include <limits>
13 #include <set> 13 #include <set>
14 14
15 #include "base/containers/adapters.h" 15 #include "base/containers/adapters.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/timer/elapsed_timer.h" 17 #include "base/timer/elapsed_timer.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "base/trace_event/trace_event_argument.h" 19 #include "base/trace_event/trace_event_argument.h"
20 #include "cc/base/devtools_instrumentation.h" 20 #include "cc/base/devtools_instrumentation.h"
21 #include "cc/base/histograms.h" 21 #include "cc/base/histograms.h"
22 #include "cc/base/math_util.h" 22 #include "cc/base/math_util.h"
23 #include "cc/base/synced_property.h" 23 #include "cc/base/synced_property.h"
24 #include "cc/debug/traced_value.h" 24 #include "cc/debug/traced_value.h"
25 #include "cc/input/page_scale_animation.h" 25 #include "cc/input/page_scale_animation.h"
26 #include "cc/input/scrollbar_animation_controller.h" 26 #include "cc/input/scrollbar_animation_controller.h"
27 #include "cc/layers/effect_tree_layer_list_iterator.h"
27 #include "cc/layers/heads_up_display_layer_impl.h" 28 #include "cc/layers/heads_up_display_layer_impl.h"
28 #include "cc/layers/layer.h" 29 #include "cc/layers/layer.h"
29 #include "cc/layers/layer_iterator.h"
30 #include "cc/layers/layer_list_iterator.h" 30 #include "cc/layers/layer_list_iterator.h"
31 #include "cc/layers/render_surface_impl.h" 31 #include "cc/layers/render_surface_impl.h"
32 #include "cc/layers/scrollbar_layer_impl_base.h" 32 #include "cc/layers/scrollbar_layer_impl_base.h"
33 #include "cc/output/compositor_frame_sink.h" 33 #include "cc/output/compositor_frame_sink.h"
34 #include "cc/resources/ui_resource_request.h" 34 #include "cc/resources/ui_resource_request.h"
35 #include "cc/trees/clip_node.h" 35 #include "cc/trees/clip_node.h"
36 #include "cc/trees/draw_property_utils.h" 36 #include "cc/trees/draw_property_utils.h"
37 #include "cc/trees/effect_node.h" 37 #include "cc/trees/effect_node.h"
38 #include "cc/trees/layer_tree_host_common.h" 38 #include "cc/trees/layer_tree_host_common.h"
39 #include "cc/trees/layer_tree_host_impl.h" 39 #include "cc/trees/layer_tree_host_impl.h"
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1120
1121 { 1121 {
1122 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", 1122 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion",
1123 "IsActive", IsActiveTree(), "SourceFrameNumber", 1123 "IsActive", IsActiveTree(), "SourceFrameNumber",
1124 source_frame_number_); 1124 source_frame_number_);
1125 OcclusionTracker occlusion_tracker( 1125 OcclusionTracker occlusion_tracker(
1126 layer_list_[0]->GetRenderSurface()->content_rect()); 1126 layer_list_[0]->GetRenderSurface()->content_rect());
1127 occlusion_tracker.set_minimum_tracking_size( 1127 occlusion_tracker.set_minimum_tracking_size(
1128 settings().minimum_occlusion_tracking_size); 1128 settings().minimum_occlusion_tracking_size);
1129 1129
1130 // LayerIterator is used here instead of CallFunctionForEveryLayer to only 1130 for (EffectTreeLayerListIterator it(this);
1131 // UpdateTilePriorities on layers that will be visible (and thus have valid 1131 it.state() != EffectTreeLayerListIterator::State::END; ++it) {
1132 // draw properties) and not because any ordering is required.
1133 LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
1134 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
1135 it != end; ++it) {
1136 occlusion_tracker.EnterLayer(it); 1132 occlusion_tracker.EnterLayer(it);
1137 1133
1138 if (it.represents_itself()) { 1134 if (it.state() == EffectTreeLayerListIterator::State::LAYER) {
1139 it->draw_properties().occlusion_in_content_space = 1135 LayerImpl* layer = it.current_layer();
1140 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform()); 1136 layer->draw_properties().occlusion_in_content_space =
1137 occlusion_tracker.GetCurrentOcclusionForLayer(
1138 layer->DrawTransform());
1141 } 1139 }
1142 1140
1143 if (it.represents_contributing_render_surface()) { 1141 if (it.state() ==
1142 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
1144 const RenderSurfaceImpl* occlusion_surface = 1143 const RenderSurfaceImpl* occlusion_surface =
1145 occlusion_tracker.OcclusionSurfaceForContributingSurface(); 1144 occlusion_tracker.OcclusionSurfaceForContributingSurface();
1146 gfx::Transform draw_transform; 1145 gfx::Transform draw_transform;
1147 RenderSurfaceImpl* render_surface = it->GetRenderSurface(); 1146 RenderSurfaceImpl* render_surface = it.current_render_surface();
1148 if (occlusion_surface) { 1147 if (occlusion_surface) {
1149 // We are calculating transform between two render surfaces. So, we 1148 // We are calculating transform between two render surfaces. So, we
1150 // need to apply the surface contents scale at target and remove the 1149 // need to apply the surface contents scale at target and remove the
1151 // surface contents scale at source. 1150 // surface contents scale at source.
1152 property_trees()->GetToTarget(render_surface->TransformTreeIndex(), 1151 property_trees()->GetToTarget(render_surface->TransformTreeIndex(),
1153 occlusion_surface->EffectTreeIndex(), 1152 occlusion_surface->EffectTreeIndex(),
1154 &draw_transform); 1153 &draw_transform);
1155 const EffectNode* effect_node = property_trees()->effect_tree.Node( 1154 const EffectNode* effect_node = property_trees()->effect_tree.Node(
1156 render_surface->EffectTreeIndex()); 1155 render_surface->EffectTreeIndex());
1157 draw_property_utils::ConcatInverseSurfaceContentsScale( 1156 draw_property_utils::ConcatInverseSurfaceContentsScale(
1158 effect_node, &draw_transform); 1157 effect_node, &draw_transform);
1159 } 1158 }
1160 1159
1161 Occlusion occlusion = 1160 Occlusion occlusion =
1162 occlusion_tracker.GetCurrentOcclusionForContributingSurface( 1161 occlusion_tracker.GetCurrentOcclusionForContributingSurface(
1163 draw_transform); 1162 draw_transform);
1164 render_surface->set_occlusion_in_content_space(occlusion); 1163 render_surface->set_occlusion_in_content_space(occlusion);
1165 // Masks are used to draw the contributing surface, so should have 1164 // Masks are used to draw the contributing surface, so should have
1166 // the same occlusion as the surface (nothing inside the surface 1165 // the same occlusion as the surface (nothing inside the surface
1167 // occludes them). 1166 // occludes them).
1168 if (LayerImpl* mask = render_surface->MaskLayer()) { 1167 if (LayerImpl* mask = render_surface->MaskLayer()) {
1169 mask->draw_properties().occlusion_in_content_space = 1168 mask->draw_properties().occlusion_in_content_space =
1170 occlusion_tracker.GetCurrentOcclusionForContributingSurface( 1169 occlusion_tracker.GetCurrentOcclusionForContributingSurface(
1171 draw_transform * it->DrawTransform()); 1170 draw_transform * render_surface->SurfaceScale());
1172 } 1171 }
1173 } 1172 }
1174 1173
1175 occlusion_tracker.LeaveLayer(it); 1174 occlusion_tracker.LeaveLayer(it);
1176 } 1175 }
1177 1176
1178 unoccluded_screen_space_region_ = 1177 unoccluded_screen_space_region_ =
1179 occlusion_tracker.ComputeVisibleRegionInScreen(this); 1178 occlusion_tracker.ComputeVisibleRegionInScreen(this);
1180 } 1179 }
1181 1180
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 bool LayerTreeImpl::create_low_res_tiling() const { 1520 bool LayerTreeImpl::create_low_res_tiling() const {
1522 return layer_tree_host_impl_->create_low_res_tiling(); 1521 return layer_tree_host_impl_->create_low_res_tiling();
1523 } 1522 }
1524 1523
1525 void LayerTreeImpl::SetNeedsRedraw() { 1524 void LayerTreeImpl::SetNeedsRedraw() {
1526 layer_tree_host_impl_->SetNeedsRedraw(); 1525 layer_tree_host_impl_->SetNeedsRedraw();
1527 } 1526 }
1528 1527
1529 void LayerTreeImpl::GetAllPrioritizedTilesForTracing( 1528 void LayerTreeImpl::GetAllPrioritizedTilesForTracing(
1530 std::vector<PrioritizedTile>* prioritized_tiles) const { 1529 std::vector<PrioritizedTile>* prioritized_tiles) const {
1531 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); 1530 for (auto it = layer_list_.rbegin(); it != layer_list_.rend(); ++it) {
1532 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); 1531 LayerImpl* layer_impl = *it;
1533 it != end; ++it) { 1532 if (!layer_impl->is_drawn_render_surface_layer_list_member())
1534 if (!it.represents_itself())
1535 continue; 1533 continue;
1536 LayerImpl* layer_impl = *it;
1537 layer_impl->GetAllPrioritizedTilesForTracing(prioritized_tiles); 1534 layer_impl->GetAllPrioritizedTilesForTracing(prioritized_tiles);
1538 } 1535 }
1539 } 1536 }
1540 1537
1541 void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const { 1538 void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const {
1542 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); 1539 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this);
1543 state->SetInteger("source_frame_number", source_frame_number_); 1540 state->SetInteger("source_frame_number", source_frame_number_);
1544 1541
1545 state->BeginArray("render_surface_layer_list"); 1542 state->BeginArray("render_surface_layer_list");
1546 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); 1543 for (auto it = layer_list_.rbegin(); it != layer_list_.rend(); ++it) {
1547 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); 1544 if (!(*it)->is_drawn_render_surface_layer_list_member())
1548 it != end; ++it) {
1549 if (!it.represents_itself())
1550 continue; 1545 continue;
1551 TracedValue::AppendIDRef(*it, state); 1546 TracedValue::AppendIDRef(*it, state);
1552 } 1547 }
1553 state->EndArray(); 1548 state->EndArray();
1554 1549
1555 state->BeginArray("swap_promise_trace_ids"); 1550 state->BeginArray("swap_promise_trace_ids");
1556 for (const auto& swap_promise : swap_promise_list_) 1551 for (const auto& swap_promise : swap_promise_list_)
1557 state->AppendDouble(swap_promise->TraceId()); 1552 state->AppendDouble(swap_promise->TraceId());
1558 state->EndArray(); 1553 state->EndArray();
1559 1554
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 2189
2195 void LayerTreeImpl::ResetAllChangeTracking() { 2190 void LayerTreeImpl::ResetAllChangeTracking() {
2196 layers_that_should_push_properties_.clear(); 2191 layers_that_should_push_properties_.clear();
2197 // Iterate over all layers, including masks. 2192 // Iterate over all layers, including masks.
2198 for (auto& layer : *layers_) 2193 for (auto& layer : *layers_)
2199 layer->ResetChangeTracking(); 2194 layer->ResetChangeTracking();
2200 property_trees_.ResetAllChangeTracking(); 2195 property_trees_.ResetAllChangeTracking();
2201 } 2196 }
2202 2197
2203 } // namespace cc 2198 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_copyrequest.cc ('k') | cc/trees/occlusion_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698