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

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: Set up impl-only timelines for ScrollOffset animations Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 890d304093193bfd10af96d234cb6c9f81299176..e735c2a28bce9433d97cdc8c774f4add87174019 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -17,6 +17,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
+#include "cc/animation/animation_host.h"
#include "cc/animation/animation_registrar.h"
#include "cc/animation/layer_animation_controller.h"
#include "cc/base/math_util.h"
@@ -133,6 +134,11 @@ LayerTreeHost::LayerTreeHost(
animation_registrar_ = AnimationRegistrar::Create();
rendering_stats_instrumentation_->set_record_rendering_stats(
debug_state_.RecordRenderingStats());
+
+ if (settings_.use_compositor_animation_timelines) {
+ animation_host_ = AnimationHost::Create(false);
+ animation_host_->SetLayerTreeMutatorsClient(this);
+ }
}
void LayerTreeHost::InitializeThreaded(
@@ -174,6 +180,9 @@ void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
LayerTreeHost::~LayerTreeHost() {
TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
+ if (animation_host_)
+ animation_host_->SetLayerTreeMutatorsClient(nullptr);
+
if (root_layer_.get())
root_layer_->SetLayerTreeHost(NULL);
@@ -367,6 +376,11 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
{
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
+
+ if (animation_host_) {
+ DCHECK(host_impl->animation_host());
+ animation_host_->PushPropertiesTo(host_impl->animation_host());
+ }
}
micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
@@ -1278,4 +1292,64 @@ void LayerTreeHost::SetAuthoritativeVSyncInterval(
proxy_->SetAuthoritativeVSyncInterval(interval);
}
+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());
+}
+
+bool LayerTreeHost::IsLayerInActiveTree(int layer_id) const {
+ return true;
+}
+
+bool LayerTreeHost::IsLayerInPendingTree(int layer_id) const {
+ return false;
+}
+
+void LayerTreeHost::SetMutatorsNeedCommit() {
+ SetNeedsCommit();
+}
+
+void LayerTreeHost::SetLayerFilterMutated(int layer_id,
+ bool active_tree,
+ const FilterOperations& filters) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnFilterAnimated(filters);
+}
+
+void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
+ bool active_tree,
+ float opacity) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnOpacityAnimated(opacity);
+}
+
+void LayerTreeHost::SetLayerTransformMutated(int layer_id,
+ bool active_tree,
+ const gfx::Transform& transform) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnTransformAnimated(transform);
+}
+
+void LayerTreeHost::SetLayerScrollOffsetMutated(
+ int layer_id,
+ bool active_tree,
+ const gfx::ScrollOffset& scroll_offset) {
+ LayerAnimationValueObserver* layer = LayerById(layer_id);
+ DCHECK(layer);
+ layer->OnScrollOffsetAnimated(scroll_offset);
+}
+
} // namespace cc
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698