| 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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 861 |
| 861 void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wall
ClockTime) | 862 void LayerTreeHost::animateLayers(base::TimeTicks monotonicTime, base::Time wall
ClockTime) |
| 862 { | 863 { |
| 863 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_
animation_controllers().empty()) | 864 if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_
animation_controllers().empty()) |
| 864 return; | 865 return; |
| 865 | 866 |
| 866 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); | 867 TRACE_EVENT0("cc", "LayerTreeHostImpl::animateLayers"); |
| 867 | 868 |
| 868 double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecond
sF(); | 869 double monotonicTimeInSeconds = (monotonicTime - base::TimeTicks()).InSecond
sF(); |
| 869 | 870 |
| 871 scoped_ptr<AnimationEventsVector> events(make_scoped_ptr(new AnimationEvents
Vector)); |
| 870 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti
ve_animation_controllers(); | 872 AnimationRegistrar::AnimationControllerMap copy = m_animationRegistrar->acti
ve_animation_controllers(); |
| 871 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(
); iter != copy.end(); ++iter) | 873 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(
); iter != copy.end(); ++iter) |
| 872 (*iter).second->animate(monotonicTimeInSeconds, 0); | 874 if ((*iter).second->hasNonOrphanedObserver()) |
| 875 (*iter).second->animate(monotonicTimeInSeconds, 0); |
| 876 else |
| 877 (*iter).second->animate(monotonicTimeInSeconds, events.get()); |
| 878 |
| 879 if (!events->empty()) |
| 880 setAnimationEvents(events.Pass(), wallClockTime); |
| 873 } | 881 } |
| 874 | 882 |
| 875 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve
nts, Layer* layer, base::Time wallClockTime) | 883 void LayerTreeHost::setAnimationEventsRecursive(const AnimationEventsVector& eve
nts, Layer* layer, base::Time wallClockTime) |
| 876 { | 884 { |
| 877 if (!layer) | 885 if (!layer) |
| 878 return; | 886 return; |
| 879 | 887 |
| 880 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { | 888 for (size_t eventIndex = 0; eventIndex < events.size(); ++eventIndex) { |
| 881 if (layer->id() == events[eventIndex].layerId) { | 889 if (layer->id() == events[eventIndex].layerId) { |
| 882 if (events[eventIndex].type == AnimationEvent::Started) | 890 if (events[eventIndex].type == AnimationEvent::Started) |
| 883 layer->notifyAnimationStarted(events[eventIndex], wallClockTime.
ToDoubleT()); | 891 layer->notifyAnimationStarted(events[eventIndex], wallClockTime.
ToDoubleT()); |
| 884 else | 892 else |
| 885 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); | 893 layer->notifyAnimationFinished(wallClockTime.ToDoubleT()); |
| 886 } | 894 } |
| 887 } | 895 } |
| 888 | 896 |
| 889 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) | 897 for (size_t childIndex = 0; childIndex < layer->children().size(); ++childIn
dex) |
| 890 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); | 898 setAnimationEventsRecursive(events, layer->children()[childIndex].get(),
wallClockTime); |
| 891 } | 899 } |
| 892 | 900 |
| 893 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() | 901 skia::RefPtr<SkPicture> LayerTreeHost::capturePicture() |
| 894 { | 902 { |
| 895 return m_proxy->capturePicture(); | 903 return m_proxy->capturePicture(); |
| 896 } | 904 } |
| 897 | 905 |
| 898 } // namespace cc | 906 } // namespace cc |
| OLD | NEW |