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

Side by Side Diff: cc/layer_tree_host.cc

Issue 11783037: Not for review: Enable accelerated animations for orphaned layers (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Wait for layout to complete before starting orphaned animations Created 7 years, 10 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
« no previous file with comments | « cc/layer_tree_host.h ('k') | cc/test/animation_test_common.h » ('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/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 , m_debugState(settings.initialDebugState) 83 , m_debugState(settings.initialDebugState)
84 , m_deviceScaleFactor(1) 84 , m_deviceScaleFactor(1)
85 , m_visible(true) 85 , m_visible(true)
86 , m_pageScaleFactor(1) 86 , m_pageScaleFactor(1)
87 , m_minPageScaleFactor(1) 87 , m_minPageScaleFactor(1)
88 , m_maxPageScaleFactor(1) 88 , m_maxPageScaleFactor(1)
89 , m_triggerIdleUpdates(true) 89 , m_triggerIdleUpdates(true)
90 , m_backgroundColor(SK_ColorWHITE) 90 , m_backgroundColor(SK_ColorWHITE)
91 , m_hasTransparentBackground(false) 91 , m_hasTransparentBackground(false)
92 , m_partialTextureUpdateRequests(0) 92 , m_partialTextureUpdateRequests(0)
93 , m_animationRegistrar(AnimationRegistrar::create())
94 { 93 {
94 if (m_settings.acceleratedAnimationEnabled)
95 m_animationRegistrar = AnimationRegistrar::create();
95 numLayerTreeInstances++; 96 numLayerTreeInstances++;
96 } 97 }
97 98
98 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) 99 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread)
99 { 100 {
100 if (implThread) 101 if (implThread)
101 return initializeProxy(ThreadProxy::create(this, implThread.Pass())); 102 return initializeProxy(ThreadProxy::create(this, implThread.Pass()));
102 else 103 else
103 return initializeProxy(SingleThreadProxy::create(this)); 104 return initializeProxy(SingleThreadProxy::create(this));
104 } 105 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 { 213 {
213 DCHECK(m_proxy->isMainThread()); 214 DCHECK(m_proxy->isMainThread());
214 m_proxy->acquireLayerTextures(); 215 m_proxy->acquireLayerTextures();
215 } 216 }
216 217
217 void LayerTreeHost::didBeginFrame() 218 void LayerTreeHost::didBeginFrame()
218 { 219 {
219 m_client->didBeginFrame(); 220 m_client->didBeginFrame();
220 } 221 }
221 222
222 void LayerTreeHost::updateAnimations(base::TimeTicks frameBeginTime) 223 void LayerTreeHost::updateAnimations(base::TimeTicks monotonicFrameBeginTime, ba se::Time wallClockFrameBeginTime)
223 { 224 {
224 m_animating = true; 225 m_animating = true;
225 m_client->animate((frameBeginTime - base::TimeTicks()).InSecondsF()); 226 m_client->animate((monotonicFrameBeginTime - base::TimeTicks()).InSecondsF() );
226 animateLayers(frameBeginTime); 227 animateLayers(monotonicFrameBeginTime, wallClockFrameBeginTime);
227 m_animating = false; 228 m_animating = false;
228 229
229 m_renderingStats.numAnimationFrames++; 230 m_renderingStats.numAnimationFrames++;
230 } 231 }
231 232
232 void LayerTreeHost::didStopFlinging() 233 void LayerTreeHost::didStopFlinging()
233 { 234 {
234 m_proxy->mainThreadHasStoppedFlinging(); 235 m_proxy->mainThreadHasStoppedFlinging();
235 } 236 }
236 237
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 setNeedsCommit(); 829 setNeedsCommit();
829 } 830 }
830 831
831 bool LayerTreeHost::blocksPendingCommit() const 832 bool LayerTreeHost::blocksPendingCommit() const
832 { 833 {
833 if (!m_rootLayer) 834 if (!m_rootLayer)
834 return false; 835 return false;
835 return m_rootLayer->blocksPendingCommitRecursive(); 836 return m_rootLayer->blocksPendingCommitRecursive();
836 } 837 }
837 838
838 void LayerTreeHost::animateLayers(base::TimeTicks time) 839 void LayerTreeHost::didUpdateLayout()
840 {
841 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti ve_animation_controllers();
842 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin( ); iter != copy.end(); ++iter) {
843 if ((*iter).second->orphanWaitStatus() == LayerAnimationController::Wait ingForLayout)
844 (*iter).second->setOrphanWaitStatus(LayerAnimationController::Waited ForLayout);
845 }
846 }
847
848 void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wall ClockTime)
839 { 849 {
840 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_ animation_controllers().empty()) 850 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_ animation_controllers().empty())
841 return; 851 return;
842 852
843 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); 853 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers");
844 854
845 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 855 double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecond sF();
846 856
857 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents Vector));
847 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti ve_animation_controllers(); 858 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti ve_animation_controllers();
848 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin( ); iter != copy.end(); ++iter) 859 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin( ); iter != copy.end(); ++iter) {
849 (*iter).second->animate(monotonicTime, 0); 860 if ((*iter).second->hasNonOrphanedObserver())
861 (*iter).second->animate(monotonicTimeInSeconds, 0);
862 else if ((*iter).second->orphanWaitStatus() == LayerAnimationController: :WaitedForLayout)
863 (*iter).second->animate(monotonicTimeInSeconds, events.get());
864 }
865
866 if (!events->empty())
867 setAnimationEvents(events.Pass(), wallClockTime);
850 } 868 }
851 869
852 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve nts, Layer* layer, base::Time wallClockTime) 870 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve nts, Layer* layer, base::Time wallClockTime)
853 { 871 {
854 if (!layer) 872 if (!layer)
855 return; 873 return;
856 874
857 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { 875 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) {
858 if (layer->id() == events[eventIndex].layerId) { 876 if (layer->id() == events[eventIndex].layerId) {
859 if (events[eventIndex].type == AnimationEvent::Started) 877 if (events[eventIndex].type == AnimationEvent::Started)
860 layer->notifyAnimationStarted(events[eventIndex], wallClockTime. ToDoubleT()); 878 layer->notifyAnimationStarted(events[eventIndex], wallClockTime. ToDoubleT());
861 else 879 else
862 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); 880 layer->notifyAnimationFinished(wallClockTime.ToDoubleT());
863 } 881 }
864 } 882 }
865 883
866 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex) 884 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn dex)
867 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime); 885 setAnimationEventsRecursive(events, layer->children()[childIndex].get(), wallClockTime);
868 } 886 }
869 887
870 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() 888 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture()
871 { 889 {
872 return m_proxy->capturePicture(); 890 return m_proxy->capturePicture();
873 } 891 }
874 892
875 } // namespace cc 893 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host.h ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698