| 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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bool start_ready_animations = true; | 121 bool start_ready_animations = true; |
| 122 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 122 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 123 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 123 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void SetActive(bool active) { | 126 void SetActive(bool active) { |
| 127 if (active != time_source_->Active()) | 127 if (active != time_source_->Active()) |
| 128 time_source_->SetActive(active); | 128 time_source_->SetActive(active); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool Active() const { return time_source_->Active(); } |
| 132 |
| 131 private: | 133 private: |
| 132 LayerTreeHostImplTimeSourceAdapter( | 134 LayerTreeHostImplTimeSourceAdapter( |
| 133 LayerTreeHostImpl* layer_tree_host_impl, | 135 LayerTreeHostImpl* layer_tree_host_impl, |
| 134 scoped_refptr<DelayBasedTimeSource> time_source) | 136 scoped_refptr<DelayBasedTimeSource> time_source) |
| 135 : layer_tree_host_impl_(layer_tree_host_impl), | 137 : layer_tree_host_impl_(layer_tree_host_impl), |
| 136 time_source_(time_source) { | 138 time_source_(time_source) { |
| 137 time_source_->SetClient(this); | 139 time_source_->SetClient(this); |
| 138 } | 140 } |
| 139 | 141 |
| 140 LayerTreeHostImpl* layer_tree_host_impl_; | 142 LayerTreeHostImpl* layer_tree_host_impl_; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); | 251 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); |
| 250 pending_tree_->set_needs_update_draw_properties(); | 252 pending_tree_->set_needs_update_draw_properties(); |
| 251 pending_tree_->UpdateDrawProperties(); | 253 pending_tree_->UpdateDrawProperties(); |
| 252 // Start working on newly created tiles immediately if needed. | 254 // Start working on newly created tiles immediately if needed. |
| 253 if (!tile_manager_ || !manage_tiles_needed_) | 255 if (!tile_manager_ || !manage_tiles_needed_) |
| 254 NotifyReadyToActivate(); | 256 NotifyReadyToActivate(); |
| 255 else | 257 else |
| 256 ManageTiles(); | 258 ManageTiles(); |
| 257 } else { | 259 } else { |
| 258 active_tree_->set_needs_update_draw_properties(); | 260 active_tree_->set_needs_update_draw_properties(); |
| 261 if (time_source_client_adapter_ && time_source_client_adapter_->Active()) |
| 262 DCHECK(active_tree_->root_layer()); |
| 259 } | 263 } |
| 260 | 264 |
| 261 client_->SendManagedMemoryStats(); | 265 client_->SendManagedMemoryStats(); |
| 262 } | 266 } |
| 263 | 267 |
| 264 bool LayerTreeHostImpl::CanDraw() const { | 268 bool LayerTreeHostImpl::CanDraw() const { |
| 265 // Note: If you are changing this function or any other function that might | 269 // Note: If you are changing this function or any other function that might |
| 266 // affect the result of CanDraw, make sure to call | 270 // affect the result of CanDraw, make sure to call |
| 267 // client_->OnCanDrawStateChanged in the proper places and update the | 271 // client_->OnCanDrawStateChanged in the proper places and update the |
| 268 // NotifyIfCanDrawChanged test. | 272 // NotifyIfCanDrawChanged test. |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 822 } |
| 819 | 823 |
| 820 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 824 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 821 if (input_handler_client_) | 825 if (input_handler_client_) |
| 822 input_handler_client_->MainThreadHasStoppedFlinging(); | 826 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 823 } | 827 } |
| 824 | 828 |
| 825 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 829 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
| 826 bool should_background_tick) { | 830 bool should_background_tick) { |
| 827 DCHECK(proxy_->IsImplThread()); | 831 DCHECK(proxy_->IsImplThread()); |
| 832 if (should_background_tick) |
| 833 DCHECK(active_tree_->root_layer()); |
| 828 | 834 |
| 829 bool enabled = should_background_tick && | 835 bool enabled = should_background_tick && |
| 830 !animation_registrar_->active_animation_controllers().empty(); | 836 !animation_registrar_->active_animation_controllers().empty(); |
| 831 | 837 |
| 832 // Lazily create the time_source adapter so that we can vary the interval for | 838 // Lazily create the time_source adapter so that we can vary the interval for |
| 833 // testing. | 839 // testing. |
| 834 if (!time_source_client_adapter_) { | 840 if (!time_source_client_adapter_) { |
| 835 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( | 841 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( |
| 836 this, | 842 this, |
| 837 DelayBasedTimeSource::Create( | 843 DelayBasedTimeSource::Create( |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 const RenderingStats& stats = | 1502 const RenderingStats& stats = |
| 1497 rendering_stats_instrumentation_->GetRenderingStats(); | 1503 rendering_stats_instrumentation_->GetRenderingStats(); |
| 1498 paint_time_counter_->SavePaintTime( | 1504 paint_time_counter_->SavePaintTime( |
| 1499 stats.main_stats.paint_time + stats.main_stats.record_time + | 1505 stats.main_stats.paint_time + stats.main_stats.record_time + |
| 1500 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); | 1506 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); |
| 1501 } | 1507 } |
| 1502 | 1508 |
| 1503 client_->DidActivatePendingTree(); | 1509 client_->DidActivatePendingTree(); |
| 1504 if (!tree_activation_callback_.is_null()) | 1510 if (!tree_activation_callback_.is_null()) |
| 1505 tree_activation_callback_.Run(); | 1511 tree_activation_callback_.Run(); |
| 1512 |
| 1513 if (time_source_client_adapter_ && time_source_client_adapter_->Active()) |
| 1514 DCHECK(active_tree_->root_layer()); |
| 1506 } | 1515 } |
| 1507 | 1516 |
| 1508 void LayerTreeHostImpl::SetVisible(bool visible) { | 1517 void LayerTreeHostImpl::SetVisible(bool visible) { |
| 1509 DCHECK(proxy_->IsImplThread()); | 1518 DCHECK(proxy_->IsImplThread()); |
| 1510 | 1519 |
| 1511 if (visible_ == visible) | 1520 if (visible_ == visible) |
| 1512 return; | 1521 return; |
| 1513 visible_ = visible; | 1522 visible_ = visible; |
| 1514 DidVisibilityChange(this, visible_); | 1523 DidVisibilityChange(this, visible_); |
| 1515 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1524 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 | 2577 |
| 2569 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2578 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2570 UIResourceId uid) const { | 2579 UIResourceId uid) const { |
| 2571 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2580 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2572 if (iter != ui_resource_map_.end()) | 2581 if (iter != ui_resource_map_.end()) |
| 2573 return iter->second; | 2582 return iter->second; |
| 2574 return 0; | 2583 return 0; |
| 2575 } | 2584 } |
| 2576 | 2585 |
| 2577 } // namespace cc | 2586 } // namespace cc |
| OLD | NEW |