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

Unified Diff: cc/trees/layer_tree_host.cc

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index f4780789394c447a1b3a56cfb5925ef325dec6a1..f4e4309d60f05003db55a05d0342498010c0081b 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -18,6 +18,7 @@
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "cc/animation/animation_registrar.h"
+#include "cc/animation/animation_timeline.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/base/math_util.h"
#include "cc/debug/devtools_instrumentation.h"
@@ -296,6 +297,9 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
sync_tree->set_source_frame_number(source_frame_number());
if (needs_full_tree_sync_) {
+ host_impl->SetAnimationTimeline(
+ animation_timeline_ ? AnimationTimeline::Create() : nullptr);
+
sync_tree->SetRootLayer(TreeSynchronizer::SynchronizeTrees(
root_layer(), sync_tree->DetachLayerTree(), sync_tree));
}
@@ -369,6 +373,11 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
{
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
+
+ if (animation_timeline_) {
+ DCHECK(host_impl->animation_timeline());
+ animation_timeline_->PushPropertiesTo(host_impl->animation_timeline());
+ }
}
micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
@@ -579,6 +588,18 @@ void LayerTreeHost::SetAnimationEvents(
}
}
+void LayerTreeHost::SetAnimationTimeline(
+ scoped_refptr<AnimationTimeline> timeline) {
+ if (animation_timeline_.get() == timeline.get())
+ return;
+
+ if (animation_timeline_.get())
+ animation_timeline_->SetLayerTreeMutatorsClient(nullptr);
+ animation_timeline_ = timeline;
+ if (animation_timeline_.get())
+ animation_timeline_->SetLayerTreeMutatorsClient(this);
+}
+
void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
if (root_layer_.get() == root_layer.get())
return;
@@ -1376,4 +1397,51 @@ void LayerTreeHost::SendBeginFramesToChildren(
client_->SendBeginFramesToChildren(args);
}
+Layer* LayerTreeHost::LayerById(int id) const {
+ LayerIdMap::const_iterator iter = layer_id_map_.find(id);
+ return iter != layer_id_map_.end() ? iter->second : NULL;
+}
+
+void LayerTreeHost::RegisterLayer(Layer* layer) {
+ DCHECK(!LayerById(layer->id()));
+ layer_id_map_[layer->id()] = layer;
+}
+
+void LayerTreeHost::UnregisterLayer(Layer* layer) {
+ DCHECK(LayerById(layer->id()));
+ layer_id_map_.erase(layer->id());
+}
+
+AnimationRegistrar* LayerTreeHost::GetAnimationRegistrar() const {
+ return animation_registrar_.get();
+}
+
+void LayerTreeHost::SetMutatorsNeedCommit() {
+ SetNeedsCommit();
+}
+
+void LayerTreeHost::SetLayerFilterMutated(int layer_id,
+ bool active_tree,
+ const FilterOperations& filters) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ if (layer)
ajuma 2015/02/23 16:36:44 In what situation would |layer| be null here? Shou
loyso (OOO) 2015/02/25 04:37:03 Active tree is a 'passive' view of pending tree. O
ajuma 2015/02/25 14:57:25 I'm not sure I follow. LayerTreeHost is the main-t
loyso (OOO) 2015/02/26 03:04:45 Oh, sorry. I was commenting with LayerTreeHostImpl
ajuma 2015/02/26 14:16:31 needs_synchronized_start_time means "use the compo
loyso (OOO) 2015/02/27 02:45:17 Thank you so much Ali for pointing out that import
+ layer->OnFilterAnimated(filters);
+}
+
+void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
+ bool active_tree,
+ float opacity) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ if (layer)
+ layer->OnOpacityAnimated(opacity);
+}
+
+void LayerTreeHost::SetLayerTransformMutated(int layer_id,
+ bool active_tree,
+ const gfx::Transform& transform) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ if (layer)
+ layer->OnTransformAnimated(transform);
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698