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> |
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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 | 1070 |
1071 { | 1071 { |
1072 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", | 1072 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", |
1073 "IsActive", IsActiveTree(), "SourceFrameNumber", | 1073 "IsActive", IsActiveTree(), "SourceFrameNumber", |
1074 source_frame_number_); | 1074 source_frame_number_); |
1075 OcclusionTracker occlusion_tracker( | 1075 OcclusionTracker occlusion_tracker( |
1076 layer_list_[0]->GetRenderSurface()->content_rect()); | 1076 layer_list_[0]->GetRenderSurface()->content_rect()); |
1077 occlusion_tracker.set_minimum_tracking_size( | 1077 occlusion_tracker.set_minimum_tracking_size( |
1078 settings().minimum_occlusion_tracking_size); | 1078 settings().minimum_occlusion_tracking_size); |
1079 | 1079 |
1080 // LayerIterator is used here instead of CallFunctionForEveryLayer to only | 1080 for (EffectTreeLayerListIterator it(this); |
1081 // UpdateTilePriorities on layers that will be visible (and thus have valid | 1081 it.state() != EffectTreeLayerListIterator::State::END; ++it) { |
1082 // draw properties) and not because any ordering is required. | |
1083 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | |
1084 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | |
1085 it != end; ++it) { | |
1086 occlusion_tracker.EnterLayer(it); | 1082 occlusion_tracker.EnterLayer(it); |
1087 | 1083 |
1088 if (it.represents_itself()) { | 1084 if (it.state() == EffectTreeLayerListIterator::State::LAYER) { |
1089 it->draw_properties().occlusion_in_content_space = | 1085 LayerImpl* layer = it.current_layer(); |
1090 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform()); | 1086 layer->draw_properties().occlusion_in_content_space = |
| 1087 occlusion_tracker.GetCurrentOcclusionForLayer( |
| 1088 layer->DrawTransform()); |
1091 } | 1089 } |
1092 | 1090 |
1093 if (it.represents_contributing_render_surface()) { | 1091 if (it.state() == |
| 1092 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) { |
1094 const RenderSurfaceImpl* occlusion_surface = | 1093 const RenderSurfaceImpl* occlusion_surface = |
1095 occlusion_tracker.OcclusionSurfaceForContributingSurface(); | 1094 occlusion_tracker.OcclusionSurfaceForContributingSurface(); |
1096 gfx::Transform draw_transform; | 1095 gfx::Transform draw_transform; |
1097 RenderSurfaceImpl* render_surface = it->GetRenderSurface(); | 1096 RenderSurfaceImpl* render_surface = it.current_render_surface(); |
1098 if (occlusion_surface) { | 1097 if (occlusion_surface) { |
1099 // We are calculating transform between two render surfaces. So, we | 1098 // We are calculating transform between two render surfaces. So, we |
1100 // need to apply the surface contents scale at target and remove the | 1099 // need to apply the surface contents scale at target and remove the |
1101 // surface contents scale at source. | 1100 // surface contents scale at source. |
1102 property_trees()->GetToTarget(render_surface->TransformTreeIndex(), | 1101 property_trees()->GetToTarget(render_surface->TransformTreeIndex(), |
1103 occlusion_surface->EffectTreeIndex(), | 1102 occlusion_surface->EffectTreeIndex(), |
1104 &draw_transform); | 1103 &draw_transform); |
1105 const EffectNode* effect_node = property_trees()->effect_tree.Node( | 1104 const EffectNode* effect_node = property_trees()->effect_tree.Node( |
1106 render_surface->EffectTreeIndex()); | 1105 render_surface->EffectTreeIndex()); |
1107 draw_property_utils::ConcatInverseSurfaceContentsScale( | 1106 draw_property_utils::ConcatInverseSurfaceContentsScale( |
1108 effect_node, &draw_transform); | 1107 effect_node, &draw_transform); |
1109 } | 1108 } |
1110 | 1109 |
1111 Occlusion occlusion = | 1110 Occlusion occlusion = |
1112 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | 1111 occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
1113 draw_transform); | 1112 draw_transform); |
1114 render_surface->set_occlusion_in_content_space(occlusion); | 1113 render_surface->set_occlusion_in_content_space(occlusion); |
1115 // Masks are used to draw the contributing surface, so should have | 1114 // Masks are used to draw the contributing surface, so should have |
1116 // the same occlusion as the surface (nothing inside the surface | 1115 // the same occlusion as the surface (nothing inside the surface |
1117 // occludes them). | 1116 // occludes them). |
1118 if (LayerImpl* mask = render_surface->MaskLayer()) { | 1117 if (LayerImpl* mask = render_surface->MaskLayer()) { |
1119 mask->draw_properties().occlusion_in_content_space = | 1118 mask->draw_properties().occlusion_in_content_space = |
1120 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | 1119 occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
1121 draw_transform * it->DrawTransform()); | 1120 draw_transform * render_surface->SurfaceScale()); |
1122 } | 1121 } |
1123 } | 1122 } |
1124 | 1123 |
1125 occlusion_tracker.LeaveLayer(it); | 1124 occlusion_tracker.LeaveLayer(it); |
1126 } | 1125 } |
1127 | 1126 |
1128 unoccluded_screen_space_region_ = | 1127 unoccluded_screen_space_region_ = |
1129 occlusion_tracker.ComputeVisibleRegionInScreen(this); | 1128 occlusion_tracker.ComputeVisibleRegionInScreen(this); |
1130 } | 1129 } |
1131 | 1130 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 bool LayerTreeImpl::create_low_res_tiling() const { | 1468 bool LayerTreeImpl::create_low_res_tiling() const { |
1470 return layer_tree_host_impl_->create_low_res_tiling(); | 1469 return layer_tree_host_impl_->create_low_res_tiling(); |
1471 } | 1470 } |
1472 | 1471 |
1473 void LayerTreeImpl::SetNeedsRedraw() { | 1472 void LayerTreeImpl::SetNeedsRedraw() { |
1474 layer_tree_host_impl_->SetNeedsRedraw(); | 1473 layer_tree_host_impl_->SetNeedsRedraw(); |
1475 } | 1474 } |
1476 | 1475 |
1477 void LayerTreeImpl::GetAllPrioritizedTilesForTracing( | 1476 void LayerTreeImpl::GetAllPrioritizedTilesForTracing( |
1478 std::vector<PrioritizedTile>* prioritized_tiles) const { | 1477 std::vector<PrioritizedTile>* prioritized_tiles) const { |
1479 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | 1478 for (auto it = layer_list_.rbegin(); it != layer_list_.rend(); ++it) { |
1480 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | 1479 LayerImpl* layer_impl = *it; |
1481 it != end; ++it) { | 1480 if (!layer_impl->is_drawn_render_surface_layer_list_member()) |
1482 if (!it.represents_itself()) | |
1483 continue; | 1481 continue; |
1484 LayerImpl* layer_impl = *it; | |
1485 layer_impl->GetAllPrioritizedTilesForTracing(prioritized_tiles); | 1482 layer_impl->GetAllPrioritizedTilesForTracing(prioritized_tiles); |
1486 } | 1483 } |
1487 } | 1484 } |
1488 | 1485 |
1489 void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const { | 1486 void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const { |
1490 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); | 1487 TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); |
1491 state->SetInteger("source_frame_number", source_frame_number_); | 1488 state->SetInteger("source_frame_number", source_frame_number_); |
1492 | 1489 |
1493 state->BeginArray("render_surface_layer_list"); | 1490 state->BeginArray("render_surface_layer_list"); |
1494 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | 1491 for (auto it = layer_list_.rbegin(); it != layer_list_.rend(); ++it) { |
1495 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | 1492 if (!(*it)->is_drawn_render_surface_layer_list_member()) |
1496 it != end; ++it) { | |
1497 if (!it.represents_itself()) | |
1498 continue; | 1493 continue; |
1499 TracedValue::AppendIDRef(*it, state); | 1494 TracedValue::AppendIDRef(*it, state); |
1500 } | 1495 } |
1501 state->EndArray(); | 1496 state->EndArray(); |
1502 | 1497 |
1503 state->BeginArray("swap_promise_trace_ids"); | 1498 state->BeginArray("swap_promise_trace_ids"); |
1504 for (const auto& swap_promise : swap_promise_list_) | 1499 for (const auto& swap_promise : swap_promise_list_) |
1505 state->AppendDouble(swap_promise->TraceId()); | 1500 state->AppendDouble(swap_promise->TraceId()); |
1506 state->EndArray(); | 1501 state->EndArray(); |
1507 | 1502 |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 | 2139 |
2145 void LayerTreeImpl::ResetAllChangeTracking() { | 2140 void LayerTreeImpl::ResetAllChangeTracking() { |
2146 layers_that_should_push_properties_.clear(); | 2141 layers_that_should_push_properties_.clear(); |
2147 // Iterate over all layers, including masks. | 2142 // Iterate over all layers, including masks. |
2148 for (auto& layer : *layers_) | 2143 for (auto& layer : *layers_) |
2149 layer->ResetChangeTracking(); | 2144 layer->ResetChangeTracking(); |
2150 property_trees_.ResetAllChangeTracking(); | 2145 property_trees_.ResetAllChangeTracking(); |
2151 } | 2146 } |
2152 | 2147 |
2153 } // namespace cc | 2148 } // namespace cc |
OLD | NEW |