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

Unified Diff: cc/animation/animation_host.h

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add comments. 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
Index: cc/animation/animation_host.h
diff --git a/cc/animation/animation_host.h b/cc/animation/animation_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..e33560d156473e5df0344911f14b26be8a75367f
--- /dev/null
+++ b/cc/animation/animation_host.h
@@ -0,0 +1,97 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_ANIMATION_ANIMATION_HOST_H_
+#define CC_ANIMATION_ANIMATION_HOST_H_
+
+#include <vector>
+
+#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+class AnimationPlayer;
+class AnimationRegistrar;
+class AnimationTimeline;
+class LayerTreeHost;
+class LayerTreeMutatorsClient;
+
+typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList;
+
+// An AnimationHost contains all the state required to play animations.
+// Specifically, it owns all the AnimationTimelines objects.
+// There is just one AnimationHost for LayerTreeHost on main renderer thread
+// and just one AnimationHost for LayerTreeHostImpl on impl thread.
+// We synchronize them during the commit process in a one-way data flow process
+// (PushPropertiesTo).
+// An AnimationHost talks to it's correspondent LayerTreeHost via
+// LayerTreeMutatorsClient interface.
+// AnimationHost has it's own instance of AnimationRegistrar (to be merged).
ajuma 2015/04/30 13:17:54 Nit: s/it's/its (also above and elsewhere)
loyso (OOO) 2015/05/01 00:46:55 Acknowledged.
Ian Vollick 2015/05/05 03:52:06 To be clear, you mean that the AnimationRegistrar
loyso (OOO) 2015/05/05 06:51:18 Yes, correct.
loyso (OOO) 2015/06/22 07:48:51 Done.
loyso (OOO) 2015/06/22 07:48:51 Done.
+class CC_EXPORT AnimationHost {
+ public:
+ static scoped_ptr<AnimationHost> Create(bool is_impl_instance);
+ virtual ~AnimationHost();
+
+ void AddAnimationTimeline(AnimationTimeline* timeline);
Ian Vollick 2015/05/05 03:52:06 If it's going to hold a reference to the animation
loyso (OOO) 2015/05/05 06:51:18 It would require a complete definition for Animati
Ian Vollick 2015/05/07 13:58:42 I don't think this is true; this appears to compil
loyso (OOO) 2015/05/08 01:04:34 That's true for AnimationTimeline::AttachPlayer(An
loyso (OOO) 2015/06/22 07:48:51 Done.
+ void RemoveAnimationTimeline(AnimationTimeline* timeline);
+ AnimationTimeline* GetTimelineById(int timeline_id) const;
+
+ void ClearTimelines();
+
+ void RegisterLayer(int layer_id, bool is_active_tree);
Ian Vollick 2015/05/05 03:52:06 Please use an enum rather than a boolean. It makes
loyso (OOO) 2015/05/05 06:51:18 I wanted to go the LAC way with bools and no extra
Ian Vollick 2015/05/07 13:58:42 Using bools was probably a mistake with LAC. I wou
loyso (OOO) 2015/05/08 01:04:34 Acknowledged.
loyso (OOO) 2015/06/22 07:48:51 Done.
+ void UnregisterLayer(int layer_id, bool is_active_tree);
+
+ void RegisterPlayerForLayer(int layer_id, AnimationPlayer* player);
+ void UnregisterPlayerForLayer(int layer_id, AnimationPlayer* player);
+ AnimationPlayer* GetPlayerForLayerId(int layer_id) const;
+
+ // Parent LayerTreeHost or LayerTreeHostImpl.
+ LayerTreeMutatorsClient* layer_tree_mutators_client() {
+ return layer_tree_mutators_client_;
+ }
+ const LayerTreeMutatorsClient* layer_tree_mutators_client() const {
+ return layer_tree_mutators_client_;
+ }
+ void SetLayerTreeMutatorsClient(LayerTreeMutatorsClient* client);
+
+ void SetNeedsCommit();
+
+ void PushPropertiesTo(AnimationHost* host_impl);
+
+ AnimationRegistrar* animation_registrar() const {
Ian Vollick 2015/05/05 03:52:06 This looks like it could be a reference given that
loyso (OOO) 2015/05/05 06:51:18 I preserved the accessor signature from LayerTreeH
Ian Vollick 2015/05/07 13:58:42 I would prefer the reference, but if this accessor
loyso (OOO) 2015/06/22 07:48:51 Let it be a reference (to be deleted)
+ return animation_registrar_.get();
+ }
+
+ private:
+ // TODO(loyso): Temporary 1:1 mapping. AnimationPlayers share
+ // LayerAnimationController for a given layer at the moment.
+ // Introduce LayersAnimations for the many AnimationPlayers to many Layers
+ // mapping (a CC counterpart for blink::ElementAnimations).
+ typedef base::hash_map<int, AnimationPlayer*> LayerToPlayerMap;
+ LayerToPlayerMap layer_to_player_map_;
+
+ explicit AnimationHost(bool is_impl_instance);
+
+ void PushTimelinesToImplThread(AnimationHost* host_impl) const;
+ void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const;
+ void PushPropertiesToImplThread(AnimationHost* host_impl);
+
+ void EraseTimelines(AnimationTimelineList::iterator begin,
+ AnimationTimelineList::iterator end);
+
+ AnimationTimelineList timelines_;
+ scoped_ptr<AnimationRegistrar> animation_registrar_;
+ LayerTreeMutatorsClient* layer_tree_mutators_client_;
+
+ const bool is_impl_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(AnimationHost);
+};
+
+} // namespace cc
+
+#endif // CC_ANIMATION_ANIMATION_HOST_H_
« no previous file with comments | « cc/BUILD.gn ('k') | cc/animation/animation_host.cc » ('j') | cc/animation/animation_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698