Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 23593003: cc: Avoid updating animations in the background without an active tree (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add DCHECKs, fix SingleThreadProxy Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 {
132 return time_source_->Active();
133 }
134
131 private: 135 private:
132 LayerTreeHostImplTimeSourceAdapter( 136 LayerTreeHostImplTimeSourceAdapter(
133 LayerTreeHostImpl* layer_tree_host_impl, 137 LayerTreeHostImpl* layer_tree_host_impl,
134 scoped_refptr<DelayBasedTimeSource> time_source) 138 scoped_refptr<DelayBasedTimeSource> time_source)
135 : layer_tree_host_impl_(layer_tree_host_impl), 139 : layer_tree_host_impl_(layer_tree_host_impl),
136 time_source_(time_source) { 140 time_source_(time_source) {
137 time_source_->SetClient(this); 141 time_source_->SetClient(this);
138 } 142 }
139 143
140 LayerTreeHostImpl* layer_tree_host_impl_; 144 LayerTreeHostImpl* layer_tree_host_impl_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 pending_tree()->ApplyScrollDeltasSinceBeginFrame(); 253 pending_tree()->ApplyScrollDeltasSinceBeginFrame();
250 pending_tree_->set_needs_update_draw_properties(); 254 pending_tree_->set_needs_update_draw_properties();
251 pending_tree_->UpdateDrawProperties(); 255 pending_tree_->UpdateDrawProperties();
252 // Start working on newly created tiles immediately if needed. 256 // Start working on newly created tiles immediately if needed.
253 if (!tile_manager_ || !manage_tiles_needed_) 257 if (!tile_manager_ || !manage_tiles_needed_)
254 NotifyReadyToActivate(); 258 NotifyReadyToActivate();
255 else 259 else
256 ManageTiles(); 260 ManageTiles();
257 } else { 261 } else {
258 active_tree_->set_needs_update_draw_properties(); 262 active_tree_->set_needs_update_draw_properties();
263 if (time_source_client_adapter_ && time_source_client_adapter_->Active())
264 DCHECK(active_tree_->root_layer());
259 } 265 }
260 266
261 client_->SendManagedMemoryStats(); 267 client_->SendManagedMemoryStats();
262 } 268 }
263 269
264 bool LayerTreeHostImpl::CanDraw() const { 270 bool LayerTreeHostImpl::CanDraw() const {
265 // Note: If you are changing this function or any other function that might 271 // Note: If you are changing this function or any other function that might
266 // affect the result of CanDraw, make sure to call 272 // affect the result of CanDraw, make sure to call
267 // client_->OnCanDrawStateChanged in the proper places and update the 273 // client_->OnCanDrawStateChanged in the proper places and update the
268 // NotifyIfCanDrawChanged test. 274 // NotifyIfCanDrawChanged test.
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 824 }
819 825
820 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { 826 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
821 if (input_handler_client_) 827 if (input_handler_client_)
822 input_handler_client_->MainThreadHasStoppedFlinging(); 828 input_handler_client_->MainThreadHasStoppedFlinging();
823 } 829 }
824 830
825 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( 831 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking(
826 bool should_background_tick) { 832 bool should_background_tick) {
827 DCHECK(proxy_->IsImplThread()); 833 DCHECK(proxy_->IsImplThread());
834 if (should_background_tick)
835 DCHECK(active_tree_->root_layer());
828 836
829 bool enabled = should_background_tick && 837 bool enabled = should_background_tick &&
830 !animation_registrar_->active_animation_controllers().empty(); 838 !animation_registrar_->active_animation_controllers().empty();
831 839
832 // Lazily create the time_source adapter so that we can vary the interval for 840 // Lazily create the time_source adapter so that we can vary the interval for
833 // testing. 841 // testing.
834 if (!time_source_client_adapter_) { 842 if (!time_source_client_adapter_) {
835 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( 843 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create(
836 this, 844 this,
837 DelayBasedTimeSource::Create( 845 DelayBasedTimeSource::Create(
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 const RenderingStats& stats = 1504 const RenderingStats& stats =
1497 rendering_stats_instrumentation_->GetRenderingStats(); 1505 rendering_stats_instrumentation_->GetRenderingStats();
1498 paint_time_counter_->SavePaintTime( 1506 paint_time_counter_->SavePaintTime(
1499 stats.main_stats.paint_time + stats.main_stats.record_time + 1507 stats.main_stats.paint_time + stats.main_stats.record_time +
1500 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree); 1508 stats.impl_stats.rasterize_time_for_now_bins_on_pending_tree);
1501 } 1509 }
1502 1510
1503 client_->DidActivatePendingTree(); 1511 client_->DidActivatePendingTree();
1504 if (!tree_activation_callback_.is_null()) 1512 if (!tree_activation_callback_.is_null())
1505 tree_activation_callback_.Run(); 1513 tree_activation_callback_.Run();
1514
1515 if (time_source_client_adapter_ && time_source_client_adapter_->Active())
1516 DCHECK(active_tree_->root_layer());
1506 } 1517 }
1507 1518
1508 void LayerTreeHostImpl::SetVisible(bool visible) { 1519 void LayerTreeHostImpl::SetVisible(bool visible) {
1509 DCHECK(proxy_->IsImplThread()); 1520 DCHECK(proxy_->IsImplThread());
1510 1521
1511 if (visible_ == visible) 1522 if (visible_ == visible)
1512 return; 1523 return;
1513 visible_ = visible; 1524 visible_ = visible;
1514 DidVisibilityChange(this, visible_); 1525 DidVisibilityChange(this, visible_);
1515 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1526 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 2579
2569 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2580 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2570 UIResourceId uid) const { 2581 UIResourceId uid) const {
2571 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2582 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2572 if (iter != ui_resource_map_.end()) 2583 if (iter != ui_resource_map_.end())
2573 return iter->second; 2584 return iter->second;
2574 return 0; 2585 return 0;
2575 } 2586 }
2576 2587
2577 } // namespace cc 2588 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | cc/trees/single_thread_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698