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

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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bool start_ready_animations = true;
117 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
115 layer_tree_host_impl_->BeginNextFrame(); 118 layer_tree_host_impl_->BeginNextFrame();
116 } 119 }
117 120
118 void SetActive(bool active) { 121 void SetActive(bool active) {
119 if (active != time_source_->Active()) 122 if (active != time_source_->Active())
120 time_source_->SetActive(active); 123 time_source_->SetActive(active);
121 } 124 }
122 125
123 private: 126 private:
124 LayerTreeHostImplTimeSourceAdapter( 127 LayerTreeHostImplTimeSourceAdapter(
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); 671 occlusion_tracker.overdraw_metrics()->RecordMetrics(this);
669 672
670 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); 673 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame);
671 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); 674 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
672 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()), 675 RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()),
673 frame); 676 frame);
674 677
675 return draw_frame; 678 return draw_frame;
676 } 679 }
677 680
678 void LayerTreeHostImpl::SetBackgroundTickingEnabled(bool enabled) { 681 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking() {
682 bool able_to_draw = visible_ && CanDraw();
enne (OOO) 2013/04/05 16:01:12 These two lines of code bake in a bunch assumption
danakj 2013/04/05 16:38:58 Ok, PTAL.
683 bool enabled = !able_to_draw &&
684 !animation_registrar_->active_animation_controllers().empty();
685
679 // Lazily create the time_source adapter so that we can vary the interval for 686 // Lazily create the time_source adapter so that we can vary the interval for
680 // testing. 687 // testing.
681 if (!time_source_client_adapter_) { 688 if (!time_source_client_adapter_) {
682 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( 689 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create(
683 this, 690 this,
684 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(), 691 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(),
685 proxy_->CurrentThread())); 692 proxy_->CurrentThread()));
686 } 693 }
687 694
688 time_source_client_adapter_->SetActive(enabled); 695 time_source_client_adapter_->SetActive(enabled);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 DCHECK(frame->render_passes.empty()); 1042 DCHECK(frame->render_passes.empty());
1036 frame->render_passes_by_id.clear(); 1043 frame->render_passes_by_id.clear();
1037 1044
1038 // The next frame should start by assuming nothing has changed, and changes 1045 // The next frame should start by assuming nothing has changed, and changes
1039 // are noted as they occur. 1046 // are noted as they occur.
1040 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { 1047 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) {
1041 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()-> 1048 (*frame->render_surface_layer_list)[i]->render_surface()->damage_tracker()->
1042 DidDrawDamagedArea(); 1049 DidDrawDamagedArea();
1043 } 1050 }
1044 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); 1051 active_tree_->root_layer()->ResetAllChangeTrackingForSubtree();
1045 UpdateAnimationState();
1046 } 1052 }
1047 1053
1048 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { 1054 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) {
1049 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) 1055 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i)
1050 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); 1056 frame.will_draw_layers[i]->DidDraw(resource_provider_.get());
1051 1057
1052 // Once all layers have been drawn, pending texture uploads should no 1058 // Once all layers have been drawn, pending texture uploads should no
1053 // longer block future uploads. 1059 // longer block future uploads.
1054 resource_provider_->MarkPendingUploadsAsNonBlocking(); 1060 resource_provider_->MarkPendingUploadsAsNonBlocking();
1055 } 1061 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 if (visible_ == visible) 1246 if (visible_ == visible)
1241 return; 1247 return;
1242 visible_ = visible; 1248 visible_ = visible;
1243 DidVisibilityChange(this, visible_); 1249 DidVisibilityChange(this, visible_);
1244 EnforceManagedMemoryPolicy(managed_memory_policy_); 1250 EnforceManagedMemoryPolicy(managed_memory_policy_);
1245 1251
1246 if (!renderer_) 1252 if (!renderer_)
1247 return; 1253 return;
1248 1254
1249 renderer_->SetVisible(visible); 1255 renderer_->SetVisible(visible);
1250
1251 SetBackgroundTickingEnabled(
1252 !visible_ &&
1253 !animation_registrar_->active_animation_controllers().empty());
1254 } 1256 }
1255 1257
1256 bool LayerTreeHostImpl::InitializeRenderer( 1258 bool LayerTreeHostImpl::InitializeRenderer(
1257 scoped_ptr<OutputSurface> output_surface) { 1259 scoped_ptr<OutputSurface> output_surface) {
1258 // Since we will create a new resource provider, we cannot continue to use 1260 // Since we will create a new resource provider, we cannot continue to use
1259 // the old resources (i.e. render_surfaces and texture IDs). Clear them 1261 // the old resources (i.e. render_surfaces and texture IDs). Clear them
1260 // before we destroy the old resource provider. 1262 // before we destroy the old resource provider.
1261 if (active_tree_->root_layer()) 1263 if (active_tree_->root_layer())
1262 ClearRenderSurfaces(); 1264 ClearRenderSurfaces();
1263 if (active_tree_->root_layer()) 1265 if (active_tree_->root_layer())
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF(); 1817 double monotonic_seconds = (monotonic_time - base::TimeTicks()).InSecondsF();
1816 1818
1817 AnimationRegistrar::AnimationControllerMap copy = 1819 AnimationRegistrar::AnimationControllerMap copy =
1818 animation_registrar_->active_animation_controllers(); 1820 animation_registrar_->active_animation_controllers();
1819 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 1821 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
1820 iter != copy.end(); 1822 iter != copy.end();
1821 ++iter) 1823 ++iter)
1822 (*iter).second->Animate(monotonic_seconds); 1824 (*iter).second->Animate(monotonic_seconds);
1823 1825
1824 client_->SetNeedsRedrawOnImplThread(); 1826 client_->SetNeedsRedrawOnImplThread();
1825 SetBackgroundTickingEnabled(
1826 !visible_ &&
1827 !animation_registrar_->active_animation_controllers().empty());
1828 } 1827 }
1829 1828
1830 void LayerTreeHostImpl::UpdateAnimationState() { 1829 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
1831 if (!settings_.accelerated_animation_enabled || 1830 if (!settings_.accelerated_animation_enabled ||
1832 animation_registrar_->active_animation_controllers().empty() || 1831 animation_registrar_->active_animation_controllers().empty() ||
1833 !active_tree_->root_layer()) 1832 !active_tree_->root_layer())
1834 return; 1833 return;
1835 1834
1836 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState"); 1835 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
1837 scoped_ptr<AnimationEventsVector> events = 1836 scoped_ptr<AnimationEventsVector> events =
1838 make_scoped_ptr(new AnimationEventsVector); 1837 make_scoped_ptr(new AnimationEventsVector);
1839 AnimationRegistrar::AnimationControllerMap copy = 1838 AnimationRegistrar::AnimationControllerMap copy =
1840 animation_registrar_->active_animation_controllers(); 1839 animation_registrar_->active_animation_controllers();
1841 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 1840 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
1842 iter != copy.end(); 1841 iter != copy.end();
1843 ++iter) 1842 ++iter)
1844 (*iter).second->UpdateState(events.get()); 1843 (*iter).second->UpdateState(start_ready_animations, events.get());
1845 1844
1846 if (!events->empty()) { 1845 if (!events->empty()) {
1847 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(), 1846 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass(),
1848 last_animation_time_); 1847 last_animation_time_);
1849 } 1848 }
1850 } 1849 }
1851 1850
1852 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const { 1851 base::TimeDelta LayerTreeHostImpl::LowFrequencyAnimationInterval() const {
1853 return base::TimeDelta::FromSeconds(1); 1852 return base::TimeDelta::FromSeconds(1);
1854 } 1853 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 } 2054 }
2056 2055
2057 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2056 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2058 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2057 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2059 paint_time_counter_->ClearHistory(); 2058 paint_time_counter_->ClearHistory();
2060 2059
2061 debug_state_ = debug_state; 2060 debug_state_ = debug_state;
2062 } 2061 }
2063 2062
2064 } // namespace cc 2063 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698