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/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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 , m_debugState(settings.initialDebugState) | 82 , m_debugState(settings.initialDebugState) |
83 , m_deviceScaleFactor(1) | 83 , m_deviceScaleFactor(1) |
84 , m_visible(true) | 84 , m_visible(true) |
85 , m_pageScaleFactor(1) | 85 , m_pageScaleFactor(1) |
86 , m_minPageScaleFactor(1) | 86 , m_minPageScaleFactor(1) |
87 , m_maxPageScaleFactor(1) | 87 , m_maxPageScaleFactor(1) |
88 , m_triggerIdleUpdates(true) | 88 , m_triggerIdleUpdates(true) |
89 , m_backgroundColor(SK_ColorWHITE) | 89 , m_backgroundColor(SK_ColorWHITE) |
90 , m_hasTransparentBackground(false) | 90 , m_hasTransparentBackground(false) |
91 , m_partialTextureUpdateRequests(0) | 91 , m_partialTextureUpdateRequests(0) |
92 , m_animationRegistrar(AnimationRegistrar::create()) | |
93 { | 92 { |
| 93 if (m_settings.acceleratedAnimationEnabled) |
| 94 m_animationRegistrar = AnimationRegistrar::create(); |
94 numLayerTreeInstances++; | 95 numLayerTreeInstances++; |
95 } | 96 } |
96 | 97 |
97 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) | 98 bool LayerTreeHost::initialize(scoped_ptr<Thread> implThread) |
98 { | 99 { |
99 if (implThread) | 100 if (implThread) |
100 return initializeProxy(ThreadProxy::create(this, implThread.Pass())); | 101 return initializeProxy(ThreadProxy::create(this, implThread.Pass())); |
101 else | 102 else |
102 return initializeProxy(SingleThreadProxy::create(this)); | 103 return initializeProxy(SingleThreadProxy::create(this)); |
103 } | 104 } |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 824 |
824 void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wall
ClockTime) | 825 void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wall
ClockTime) |
825 { | 826 { |
826 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_
animation_controllers().empty()) | 827 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_
animation_controllers().empty()) |
827 return; | 828 return; |
828 | 829 |
829 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 830 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
830 | 831 |
831 double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecond
sF(); | 832 double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecond
sF(); |
832 | 833 |
| 834 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); |
833 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti
ve_animation_controllers(); | 835 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti
ve_animation_controllers(); |
834 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(
); iter != copy.end(); ++iter) | 836 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(
); iter != copy.end(); ++iter) |
835 (*iter).second->animate(monotonicTimeInSeconds, 0); | 837 if ((*iter).second->hasNonOrphanedObserver()) |
| 838 (*iter).second->animate(monotonicTimeInSeconds, 0); |
| 839 else |
| 840 (*iter).second->animate(monotonicTimeInSeconds, events.get()); |
| 841 |
| 842 if (!events->empty()) |
| 843 setAnimationEvents(events.Pass(), wallClockTime); |
836 } | 844 } |
837 | 845 |
838 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve
nts, Layer* layer, base::Time wallClockTime) | 846 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve
nts, Layer* layer, base::Time wallClockTime) |
839 { | 847 { |
840 if (!layer) | 848 if (!layer) |
841 return; | 849 return; |
842 | 850 |
843 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { | 851 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { |
844 if (layer->id() == events[eventIndex].layerId) { | 852 if (layer->id() == events[eventIndex].layerId) { |
845 if (events[eventIndex].type == AnimationEvent::Started) | 853 if (events[eventIndex].type == AnimationEvent::Started) |
846 layer->notifyAnimationStarted(events[eventIndex], wallClockTime.
ToDoubleT()); | 854 layer->notifyAnimationStarted(events[eventIndex], wallClockTime.
ToDoubleT()); |
847 else | 855 else |
848 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 856 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
849 } | 857 } |
850 } | 858 } |
851 | 859 |
852 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 860 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
853 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 861 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
854 } | 862 } |
855 | 863 |
856 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 864 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
857 { | 865 { |
858 return m_proxy->capturePicture(); | 866 return m_proxy->capturePicture(); |
859 } | 867 } |
860 | 868 |
861 } // namespace cc | 869 } // namespace cc |
OLD | NEW |