| 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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 client_->SetNeedsRedrawOnImplThread(); | 1483 client_->SetNeedsRedrawOnImplThread(); |
| 1471 active_tree_->set_needs_update_draw_properties(); | 1484 active_tree_->set_needs_update_draw_properties(); |
| 1472 SetFullRootLayerDamage(); | 1485 SetFullRootLayerDamage(); |
| 1473 } | 1486 } |
| 1474 | 1487 |
| 1475 bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { | 1488 bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { |
| 1476 active_tree_->UpdateDrawProperties(); | 1489 active_tree_->UpdateDrawProperties(); |
| 1477 return !active_tree_->RenderSurfaceLayerList().empty(); | 1490 return !active_tree_->RenderSurfaceLayerList().empty(); |
| 1478 } | 1491 } |
| 1479 | 1492 |
| 1493 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 1494 DCHECK(input_handler_client_ == NULL); |
| 1495 input_handler_client_ = client; |
| 1496 } |
| 1497 |
| 1480 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 1498 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
| 1481 gfx::Point viewport_point, InputHandler::ScrollInputType type) { | 1499 gfx::Point viewport_point, InputHandler::ScrollInputType type) { |
| 1482 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 1500 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
| 1483 | 1501 |
| 1484 if (top_controls_manager_) | 1502 if (top_controls_manager_) |
| 1485 top_controls_manager_->ScrollBegin(); | 1503 top_controls_manager_->ScrollBegin(); |
| 1486 | 1504 |
| 1487 DCHECK(!CurrentlyScrollingLayer()); | 1505 DCHECK(!CurrentlyScrollingLayer()); |
| 1488 ClearCurrentlyScrollingLayer(); | 1506 ClearCurrentlyScrollingLayer(); |
| 1489 | 1507 |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 } | 2181 } |
| 2164 | 2182 |
| 2165 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { | 2183 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { |
| 2166 if (debug_state_.continuous_painting != debug_state.continuous_painting) | 2184 if (debug_state_.continuous_painting != debug_state.continuous_painting) |
| 2167 paint_time_counter_->ClearHistory(); | 2185 paint_time_counter_->ClearHistory(); |
| 2168 | 2186 |
| 2169 debug_state_ = debug_state; | 2187 debug_state_ = debug_state; |
| 2170 } | 2188 } |
| 2171 | 2189 |
| 2172 } // namespace cc | 2190 } // namespace cc |
| OLD | NEW |