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

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

Issue 13613003: cc: Make animations tick regardless of drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // correct. In fact, setting fake thread id's interferes with the real 105 // correct. In fact, setting fake thread id's interferes with the real
106 // thread id's and causes breakage. 106 // thread id's and causes breakage.
107 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; 107 scoped_ptr<DebugScopedSetImplThread> set_impl_thread;
108 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { 108 if (!layer_tree_host_impl_->proxy()->HasImplThread()) {
109 set_impl_thread.reset( 109 set_impl_thread.reset(
110 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 110 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
111 } 111 }
112 112
113 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 113 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
114 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now()); 114 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
115 layer_tree_host_impl_->UpdateBackgroundAnimateTicking();
116 layer_tree_host_impl_->UpdateAnimationState();
115 layer_tree_host_impl_->BeginNextFrame(); 117 layer_tree_host_impl_->BeginNextFrame();
116 } 118 }
117 119
118 void SetActive(bool active) { 120 void SetActive(bool active) {
119 if (active != time_source_->Active()) 121 if (active != time_source_->Active())
120 time_source_->SetActive(active); 122 time_source_->SetActive(active);
121 } 123 }
122 124
123 private: 125 private:
124 LayerTreeHostImplTimeSourceAdapter( 126 LayerTreeHostImplTimeSourceAdapter(
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); 670 occlusion_tracker.overdraw_metrics()->RecordMetrics(this);
669 671
670 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); 672 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame);
671 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); 673 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
672 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()), 674 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()),
673 frame); 675 frame);
674 676
675 return draw_frame; 677 return draw_frame;
676 } 678 }
677 679
678 void LayerTreeHostImpl::SetBackgroundTickingEnabled(bool enabled) { 680 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking() {
681 bool able_to_draw = visible_ && CanDraw();
682 bool enabled = !able_to_draw &&
683 !animation_registrar_->active_animation_controllers().empty();
684
679 // Lazily create the time_source adapter so that we can vary the interval for 685 // Lazily create the time_source adapter so that we can vary the interval for
680 // testing. 686 // testing.
681 if (!time_source_client_adapter_) { 687 if (!time_source_client_adapter_) {
682 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( 688 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create(
683 this, 689 this,
684 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(), 690 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(),
685 proxy_->CurrentThread())); 691 proxy_->CurrentThread()));
686 } 692 }
687 693
688 time_source_client_adapter_->SetActive(enabled); 694 time_source_client_adapter_->SetActive(enabled);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 DCHECK(frame->render_passes.empty()); 1034 DCHECK(frame->render_passes.empty());
1029 frame->render_passes_by_id.clear(); 1035 frame->render_passes_by_id.clear();
1030 1036
1031 // The next frame should start by assuming nothing has changed, and changes 1037 // The next frame should start by assuming nothing has changed, and changes
1032 // are noted as they occur. 1038 // are noted as they occur.
1033 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { 1039 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) {
1034 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> 1040 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()->
1035 DidDrawDamagedArea(); 1041 DidDrawDamagedArea();
1036 } 1042 }
1037 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); 1043 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree();
1038 UpdateAnimationState();
1039 } 1044 }
1040 1045
1041 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { 1046 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) {
1042 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) 1047 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i)
1043 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); 1048 frame.will_draw_layers[i]->DidDraw(resource_provider_.get());
1044 1049
1045 // Once all layers have been drawn, pending texture uploads should no 1050 // Once all layers have been drawn, pending texture uploads should no
1046 // longer block future uploads. 1051 // longer block future uploads.
1047 resource_provider_->MarkPendingUploadsAsNonBlocking(); 1052 resource_provider_->MarkPendingUploadsAsNonBlocking();
1048 } 1053 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 if (visible_ == visible) 1238 if (visible_ == visible)
1234 return; 1239 return;
1235 visible_ = visible; 1240 visible_ = visible;
1236 DidVisibilityChange(this, visible_); 1241 DidVisibilityChange(this, visible_);
1237 EnforceManagedMemoryPolicy(managed_memory_policy_); 1242 EnforceManagedMemoryPolicy(managed_memory_policy_);
1238 1243
1239 if (!renderer_) 1244 if (!renderer_)
1240 return; 1245 return;
1241 1246
1242 renderer_->SetVisible(visible); 1247 renderer_->SetVisible(visible);
1243
1244 SetBackgroundTickingEnabled(
1245 !visible_ &&
1246 !animation_registrar_->active_animation_controllers().empty());
1247 } 1248 }
1248 1249
1249 bool LayerTreeHostImpl::InitializeRenderer( 1250 bool LayerTreeHostImpl::InitializeRenderer(
1250 scoped_ptr<OutputSurface> output_surface) { 1251 scoped_ptr<OutputSurface> output_surface) {
1251 // Since we will create a new resource provider, we cannot continue to use 1252 // Since we will create a new resource provider, we cannot continue to use
1252 // the old resources (i.e. render_surfaces and texture IDs). Clear them 1253 // the old resources (i.e. render_surfaces and texture IDs). Clear them
1253 // before we destroy the old resource provider. 1254 // before we destroy the old resource provider.
1254 if (active_tree_->root_layer()) 1255 if (active_tree_->root_layer())
1255 ClearRenderSurfaces(); 1256 ClearRenderSurfaces();
1256 if (active_tree_->root_layer()) 1257 if (active_tree_->root_layer())
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF(); 1809 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF();
1809 1810
1810 AnimationRegistrar::AnimationControllerMap copy = 1811 AnimationRegistrar::AnimationControllerMap copy =
1811 animation_registrar_->active_animation_controllers(); 1812 animation_registrar_->active_animation_controllers();
1812 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 1813 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
1813 iter != copy.end(); 1814 iter != copy.end();
1814 ++iter) 1815 ++iter)
1815 (*iter).second->Animate(monotonic_seconds); 1816 (*iter).second->Animate(monotonic_seconds);
1816 1817
1817 client_->SetNeedsRedrawOnImplThread(); 1818 client_->SetNeedsRedrawOnImplThread();
1818 SetBackgroundTickingEnabled(
1819 !visible_ &&
1820 !animation_registrar_->active_animation_controllers().empty());
1821 } 1819 }
1822 1820
1823 void LayerTreeHostImpl::UpdateAnimationState() { 1821 void LayerTreeHostImpl::UpdateAnimationState() {
1824 if (!settings_.accelerated_animation_enabled || 1822 if (!settings_.accelerated_animation_enabled ||
1825 animation_registrar_->active_animation_controllers().empty() || 1823 animation_registrar_->active_animation_controllers().empty() ||
1826 !active_tree_->root_layer()) 1824 !active_tree_->root_layer())
1827 return; 1825 return;
1828 1826
1829 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); 1827 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
1830 scoped_ptr<AnimationEventsVector> events = 1828 scoped_ptr<AnimationEventsVector> events =
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 } 2046 }
2049 2047
2050 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2048 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2051 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2049 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2052 paint_time_counter_->ClearHistory(); 2050 paint_time_counter_->ClearHistory();
2053 2051
2054 debug_state_ = debug_state; 2052 debug_state_ = debug_state;
2055 } 2053 }
2056 2054
2057 } // namespace cc 2055 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698