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_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 return metadata; | 1100 return metadata; |
1101 } | 1101 } |
1102 | 1102 |
1103 bool LayerTreeHostImpl::AllowPartialSwap() const { | 1103 bool LayerTreeHostImpl::AllowPartialSwap() const { |
1104 // We don't track damage on the HUD layer (it interacts with damage tracking | 1104 // We don't track damage on the HUD layer (it interacts with damage tracking |
1105 // visualizations), so disable partial swaps to make the HUD layer display | 1105 // visualizations), so disable partial swaps to make the HUD layer display |
1106 // properly. | 1106 // properly. |
1107 return !debug_state_.ShowHudRects(); | 1107 return !debug_state_.ShowHudRects(); |
1108 } | 1108 } |
1109 | 1109 |
1110 class DidBeginTracingFunctor { | 1110 void DidBeginTracing(LayerImpl* layer) { |
1111 public: | 1111 layer->DidBeginTracing(); |
1112 void operator()(LayerImpl* layer) { | 1112 } |
1113 layer->DidBeginTracing(); | |
1114 } | |
1115 }; | |
1116 | 1113 |
1117 void LayerTreeHostImpl::DrawLayers(FrameData* frame, | 1114 void LayerTreeHostImpl::DrawLayers(FrameData* frame, |
1118 base::TimeTicks frame_begin_time) { | 1115 base::TimeTicks frame_begin_time) { |
1119 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); | 1116 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); |
1120 DCHECK(CanDraw()); | 1117 DCHECK(CanDraw()); |
1121 | 1118 |
1122 if (frame->has_no_damage) | 1119 if (frame->has_no_damage) |
1123 return; | 1120 return; |
1124 | 1121 |
1125 DCHECK(!frame->render_passes.empty()); | 1122 DCHECK(!frame->render_passes.empty()); |
(...skipping 21 matching lines...) Expand all Loading... |
1147 | 1144 |
1148 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { | 1145 if (!settings_.impl_side_painting && debug_state_.continuous_painting) { |
1149 const RenderingStats& stats = | 1146 const RenderingStats& stats = |
1150 rendering_stats_instrumentation_->GetRenderingStats(); | 1147 rendering_stats_instrumentation_->GetRenderingStats(); |
1151 paint_time_counter_->SavePaintTime(stats.total_paint_time); | 1148 paint_time_counter_->SavePaintTime(stats.total_paint_time); |
1152 } | 1149 } |
1153 | 1150 |
1154 bool is_new_trace; | 1151 bool is_new_trace; |
1155 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 1152 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
1156 if (is_new_trace) { | 1153 if (is_new_trace) { |
1157 if (pending_tree_) | 1154 if (pending_tree_) { |
1158 LayerTreeHostCommon::CallFunctionForSubtree< | 1155 LayerTreeHostCommon::CallFunctionForSubtree(DidBeginTracing, |
1159 DidBeginTracingFunctor, LayerImpl>( | 1156 pending_tree_->root_layer()); |
1160 pending_tree_->root_layer()); | 1157 } |
1161 LayerTreeHostCommon::CallFunctionForSubtree< | 1158 LayerTreeHostCommon::CallFunctionForSubtree(DidBeginTracing, |
1162 DidBeginTracingFunctor, LayerImpl>( | 1159 active_tree_->root_layer()); |
1163 active_tree_->root_layer()); | |
1164 } | 1160 } |
1165 | 1161 |
1166 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1162 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
1167 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", this, | 1163 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", this, |
1168 TracedValue::FromValue(AsValue().release())); | 1164 TracedValue::FromValue(AsValue().release())); |
1169 | 1165 |
1170 // Because the contents of the HUD depend on everything else in the frame, the | 1166 // Because the contents of the HUD depend on everything else in the frame, the |
1171 // contents of its texture are updated as the last thing before the frame is | 1167 // contents of its texture are updated as the last thing before the frame is |
1172 // drawn. | 1168 // drawn. |
1173 if (active_tree_->hud_layer()) | 1169 if (active_tree_->hud_layer()) |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 return managed_memory_policy_; | 1420 return managed_memory_policy_; |
1425 | 1421 |
1426 ManagedMemoryPolicy actual = managed_memory_policy_; | 1422 ManagedMemoryPolicy actual = managed_memory_policy_; |
1427 actual.priority_cutoff_when_not_visible = | 1423 actual.priority_cutoff_when_not_visible = |
1428 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; | 1424 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; |
1429 actual.priority_cutoff_when_visible = | 1425 actual.priority_cutoff_when_visible = |
1430 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; | 1426 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; |
1431 return actual; | 1427 return actual; |
1432 } | 1428 } |
1433 | 1429 |
| 1430 static void LostOutputSurface(LayerImpl* layer) { |
| 1431 layer->DidLoseOutputSurface(); |
| 1432 } |
| 1433 |
1434 bool LayerTreeHostImpl::InitializeRenderer( | 1434 bool LayerTreeHostImpl::InitializeRenderer( |
1435 scoped_ptr<OutputSurface> output_surface) { | 1435 scoped_ptr<OutputSurface> output_surface) { |
1436 // Since we will create a new resource provider, we cannot continue to use | 1436 // Since we will create a new resource provider, we cannot continue to use |
1437 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 1437 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
1438 // before we destroy the old resource provider. | 1438 // before we destroy the old resource provider. |
1439 if (active_tree_->root_layer()) | 1439 if (active_tree_->root_layer()) |
1440 ClearRenderSurfaces(); | 1440 ClearRenderSurfaces(); |
1441 if (active_tree_->root_layer()) | 1441 if (active_tree_->root_layer()) { |
1442 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); | 1442 LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface, |
1443 if (pending_tree_ && pending_tree_->root_layer()) | 1443 active_tree_->root_layer()); |
1444 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); | 1444 } |
1445 if (recycle_tree_ && recycle_tree_->root_layer()) | 1445 if (pending_tree_ && pending_tree_->root_layer()) { |
1446 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); | 1446 LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface, |
| 1447 pending_tree_->root_layer()); |
| 1448 } |
| 1449 if (recycle_tree_ && recycle_tree_->root_layer()) { |
| 1450 LayerTreeHostCommon::CallFunctionForSubtree(LostOutputSurface, |
| 1451 recycle_tree_->root_layer()); |
| 1452 } |
1447 if (resource_provider_) | 1453 if (resource_provider_) |
1448 resource_provider_->DidLoseOutputSurface(); | 1454 resource_provider_->DidLoseOutputSurface(); |
1449 | 1455 |
1450 // Note: order is important here. | 1456 // Note: order is important here. |
1451 renderer_.reset(); | 1457 renderer_.reset(); |
1452 tile_manager_.reset(); | 1458 tile_manager_.reset(); |
1453 resource_provider_.reset(); | 1459 resource_provider_.reset(); |
1454 output_surface_.reset(); | 1460 output_surface_.reset(); |
1455 | 1461 |
1456 if (!output_surface->BindToClient(this)) | 1462 if (!output_surface->BindToClient(this)) |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 if (!events->empty()) { | 2061 if (!events->empty()) { |
2056 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(), | 2062 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(), |
2057 last_animation_time_); | 2063 last_animation_time_); |
2058 } | 2064 } |
2059 } | 2065 } |
2060 | 2066 |
2061 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { | 2067 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { |
2062 return base::TimeDelta::FromSeconds(1); | 2068 return base::TimeDelta::FromSeconds(1); |
2063 } | 2069 } |
2064 | 2070 |
2065 void LayerTreeHostImpl::SendDidLoseOutputSurfaceRecursive(LayerImpl* current) { | |
2066 DCHECK(current); | |
2067 current->DidLoseOutputSurface(); | |
2068 if (current->mask_layer()) | |
2069 SendDidLoseOutputSurfaceRecursive(current->mask_layer()); | |
2070 if (current->replica_layer()) | |
2071 SendDidLoseOutputSurfaceRecursive(current->replica_layer()); | |
2072 for (size_t i = 0; i < current->children().size(); ++i) | |
2073 SendDidLoseOutputSurfaceRecursive(current->children()[i]); | |
2074 } | |
2075 | |
2076 void LayerTreeHostImpl::ClearRenderSurfaces() { | 2071 void LayerTreeHostImpl::ClearRenderSurfaces() { |
2077 active_tree_->ClearRenderSurfaces(); | 2072 active_tree_->ClearRenderSurfaces(); |
2078 if (pending_tree_) | 2073 if (pending_tree_) |
2079 pending_tree_->ClearRenderSurfaces(); | 2074 pending_tree_->ClearRenderSurfaces(); |
2080 } | 2075 } |
2081 | 2076 |
2082 std::string LayerTreeHostImpl::LayerTreeAsText() const { | 2077 std::string LayerTreeHostImpl::LayerTreeAsText() const { |
2083 std::string str; | 2078 std::string str; |
2084 if (active_tree_->root_layer()) { | 2079 if (active_tree_->root_layer()) { |
2085 str = active_tree_->root_layer()->LayerTreeAsText(); | 2080 str = active_tree_->root_layer()->LayerTreeAsText(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 } | 2267 } |
2273 | 2268 |
2274 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2269 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2275 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2270 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2276 paint_time_counter_->ClearHistory(); | 2271 paint_time_counter_->ClearHistory(); |
2277 | 2272 |
2278 debug_state_ = debug_state; | 2273 debug_state_ = debug_state; |
2279 } | 2274 } |
2280 | 2275 |
2281 } // namespace cc | 2276 } // namespace cc |
OLD | NEW |