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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 rendering_stats_instrumentation)); | 152 rendering_stats_instrumentation)); |
153 } | 153 } |
154 | 154 |
155 LayerTreeHostImpl::LayerTreeHostImpl( | 155 LayerTreeHostImpl::LayerTreeHostImpl( |
156 const LayerTreeSettings& settings, | 156 const LayerTreeSettings& settings, |
157 LayerTreeHostImplClient* client, | 157 LayerTreeHostImplClient* client, |
158 Proxy* proxy, | 158 Proxy* proxy, |
159 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 159 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
160 : client_(client), | 160 : client_(client), |
161 proxy_(proxy), | 161 proxy_(proxy), |
| 162 input_handler_client_(NULL), |
162 did_lock_scrolling_layer_(false), | 163 did_lock_scrolling_layer_(false), |
163 should_bubble_scrolls_(false), | 164 should_bubble_scrolls_(false), |
164 wheel_scrolling_(false), | 165 wheel_scrolling_(false), |
165 root_layer_scroll_offset_delegate_(NULL), | 166 root_layer_scroll_offset_delegate_(NULL), |
166 settings_(settings), | 167 settings_(settings), |
167 overdraw_bottom_height_(0.f), | 168 overdraw_bottom_height_(0.f), |
168 device_scale_factor_(1.f), | 169 device_scale_factor_(1.f), |
169 visible_(true), | 170 visible_(true), |
170 managed_memory_policy_( | 171 managed_memory_policy_( |
171 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 172 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
(...skipping 29 matching lines...) Expand all Loading... |
201 // LTHI always has an active tree. | 202 // LTHI always has an active tree. |
202 active_tree_ = LayerTreeImpl::create(this); | 203 active_tree_ = LayerTreeImpl::create(this); |
203 TRACE_EVENT_OBJECT_CREATED_WITH_ID("cc.debug", "cc::LayerTreeHostImpl", this); | 204 TRACE_EVENT_OBJECT_CREATED_WITH_ID("cc.debug", "cc::LayerTreeHostImpl", this); |
204 } | 205 } |
205 | 206 |
206 LayerTreeHostImpl::~LayerTreeHostImpl() { | 207 LayerTreeHostImpl::~LayerTreeHostImpl() { |
207 DCHECK(proxy_->IsImplThread()); | 208 DCHECK(proxy_->IsImplThread()); |
208 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 209 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
209 TRACE_EVENT_OBJECT_DELETED_WITH_ID("cc.debug", "cc::LayerTreeHostImpl", this); | 210 TRACE_EVENT_OBJECT_DELETED_WITH_ID("cc.debug", "cc::LayerTreeHostImpl", this); |
210 | 211 |
| 212 if (input_handler_client_) { |
| 213 input_handler_client_->WillShutdown(); |
| 214 input_handler_client_ = NULL; |
| 215 } |
| 216 |
211 if (active_tree_->root_layer()) { | 217 if (active_tree_->root_layer()) { |
212 ClearRenderSurfaces(); | 218 ClearRenderSurfaces(); |
213 // The layer trees must be destroyed before the layer tree host. We've | 219 // The layer trees must be destroyed before the layer tree host. We've |
214 // made a contract with our animation controllers that the registrar | 220 // made a contract with our animation controllers that the registrar |
215 // will outlive them, and we must make good. | 221 // will outlive them, and we must make good. |
216 recycle_tree_.reset(); | 222 recycle_tree_.reset(); |
217 pending_tree_.reset(); | 223 pending_tree_.reset(); |
218 active_tree_.reset(); | 224 active_tree_.reset(); |
219 } | 225 } |
220 } | 226 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 TRACE_EVENT_INSTANT0( | 274 TRACE_EVENT_INSTANT0( |
269 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", | 275 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", |
270 TRACE_EVENT_SCOPE_THREAD); | 276 TRACE_EVENT_SCOPE_THREAD); |
271 return false; | 277 return false; |
272 } | 278 } |
273 return true; | 279 return true; |
274 } | 280 } |
275 | 281 |
276 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 282 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
277 base::Time wall_clock_time) { | 283 base::Time wall_clock_time) { |
| 284 if (input_handler_client_) |
| 285 input_handler_client_->Animate(monotonic_time); |
278 AnimatePageScale(monotonic_time); | 286 AnimatePageScale(monotonic_time); |
279 AnimateLayers(monotonic_time, wall_clock_time); | 287 AnimateLayers(monotonic_time, wall_clock_time); |
280 AnimateScrollbars(monotonic_time); | 288 AnimateScrollbars(monotonic_time); |
281 AnimateTopControls(monotonic_time); | 289 AnimateTopControls(monotonic_time); |
282 } | 290 } |
283 | 291 |
284 void LayerTreeHostImpl::ManageTiles() { | 292 void LayerTreeHostImpl::ManageTiles() { |
285 DCHECK(tile_manager_); | 293 DCHECK(tile_manager_); |
286 tile_manager_->ManageTiles(); | 294 tile_manager_->ManageTiles(); |
287 | 295 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 if (!output_surface_->ForcedDrawToSoftwareDevice()) | 722 if (!output_surface_->ForcedDrawToSoftwareDevice()) |
715 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); | 723 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); |
716 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()), | 724 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()), |
717 frame); | 725 frame); |
718 | 726 |
719 // If we're making a frame to draw, it better have at least one render pass. | 727 // If we're making a frame to draw, it better have at least one render pass. |
720 DCHECK(!frame->render_passes.empty()); | 728 DCHECK(!frame->render_passes.empty()); |
721 return draw_frame; | 729 return draw_frame; |
722 } | 730 } |
723 | 731 |
| 732 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 733 if (input_handler_client_) |
| 734 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 735 } |
| 736 |
724 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 737 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
725 bool should_background_tick) { | 738 bool should_background_tick) { |
726 bool enabled = should_background_tick && | 739 bool enabled = should_background_tick && |
727 !animation_registrar_->active_animation_controllers().empty(); | 740 !animation_registrar_->active_animation_controllers().empty(); |
728 | 741 |
729 // Lazily create the time_source adapter so that we can vary the interval for | 742 // Lazily create the time_source adapter so that we can vary the interval for |
730 // testing. | 743 // testing. |
731 if (!time_source_client_adapter_) { | 744 if (!time_source_client_adapter_) { |
732 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( | 745 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( |
733 this, | 746 this, |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 client_->SetNeedsRedrawOnImplThread(); | 1481 client_->SetNeedsRedrawOnImplThread(); |
1469 active_tree_->set_needs_update_draw_properties(); | 1482 active_tree_->set_needs_update_draw_properties(); |
1470 SetFullRootLayerDamage(); | 1483 SetFullRootLayerDamage(); |
1471 } | 1484 } |
1472 | 1485 |
1473 bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { | 1486 bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { |
1474 active_tree_->UpdateDrawProperties(); | 1487 active_tree_->UpdateDrawProperties(); |
1475 return !active_tree_->RenderSurfaceLayerList().empty(); | 1488 return !active_tree_->RenderSurfaceLayerList().empty(); |
1476 } | 1489 } |
1477 | 1490 |
| 1491 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 1492 DCHECK(input_handler_client_ == NULL); |
| 1493 input_handler_client_ = client; |
| 1494 } |
| 1495 |
1478 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 1496 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
1479 gfx::Point viewport_point, InputHandler::ScrollInputType type) { | 1497 gfx::Point viewport_point, InputHandler::ScrollInputType type) { |
1480 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 1498 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
1481 | 1499 |
1482 if (top_controls_manager_) | 1500 if (top_controls_manager_) |
1483 top_controls_manager_->ScrollBegin(); | 1501 top_controls_manager_->ScrollBegin(); |
1484 | 1502 |
1485 DCHECK(!CurrentlyScrollingLayer()); | 1503 DCHECK(!CurrentlyScrollingLayer()); |
1486 ClearCurrentlyScrollingLayer(); | 1504 ClearCurrentlyScrollingLayer(); |
1487 | 1505 |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 } | 2179 } |
2162 | 2180 |
2163 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2181 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
2164 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2182 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
2165 paint_time_counter_->ClearHistory(); | 2183 paint_time_counter_->ClearHistory(); |
2166 | 2184 |
2167 debug_state_ = debug_state; | 2185 debug_state_ = debug_state; |
2168 } | 2186 } |
2169 | 2187 |
2170 } // namespace cc | 2188 } // namespace cc |
OLD | NEW |