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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_ANIMATION_ANIMATION_HOST_H_
6 #define CC_ANIMATION_ANIMATION_HOST_H_
7
8 #include <vector>
9
10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/base/cc_export.h"
14
15 namespace cc {
16
17 class AnimationPlayer;
18 class AnimationRegistrar;
19 class AnimationTimeline;
20 class LayerTreeHost;
21 class LayerTreeMutatorsClient;
22
23 typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList;
24
25 // An AnimationHost contains all the state required to play animations.
26 // Specifically, it owns all the AnimationTimelines objects.
27 // There is just one AnimationHost for LayerTreeHost on main renderer thread
28 // and just one AnimationHost for LayerTreeHostImpl on impl thread.
29 // We synchronize them during the commit process in a one-way data flow process
30 // (PushPropertiesTo).
31 // An AnimationHost talks to it's correspondent LayerTreeHost via
32 // LayerTreeMutatorsClient interface.
33 // 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.
34 class CC_EXPORT AnimationHost {
35 public:
36 static scoped_ptr<AnimationHost> Create(bool is_impl_instance);
37 virtual ~AnimationHost();
38
39 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.
40 void RemoveAnimationTimeline(AnimationTimeline* timeline);
41 AnimationTimeline* GetTimelineById(int timeline_id) const;
42
43 void ClearTimelines();
44
45 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.
46 void UnregisterLayer(int layer_id, bool is_active_tree);
47
48 void RegisterPlayerForLayer(int layer_id, AnimationPlayer* player);
49 void UnregisterPlayerForLayer(int layer_id, AnimationPlayer* player);
50 AnimationPlayer* GetPlayerForLayerId(int layer_id) const;
51
52 // Parent LayerTreeHost or LayerTreeHostImpl.
53 LayerTreeMutatorsClient* layer_tree_mutators_client() {
54 return layer_tree_mutators_client_;
55 }
56 const LayerTreeMutatorsClient* layer_tree_mutators_client() const {
57 return layer_tree_mutators_client_;
58 }
59 void SetLayerTreeMutatorsClient(LayerTreeMutatorsClient* client);
60
61 void SetNeedsCommit();
62
63 void PushPropertiesTo(AnimationHost* host_impl);
64
65 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)
66 return animation_registrar_.get();
67 }
68
69 private:
70 // TODO(loyso): Temporary 1:1 mapping. AnimationPlayers share
71 // LayerAnimationController for a given layer at the moment.
72 // Introduce LayersAnimations for the many AnimationPlayers to many Layers
73 // mapping (a CC counterpart for blink::ElementAnimations).
74 typedef base::hash_map<int, AnimationPlayer*> LayerToPlayerMap;
75 LayerToPlayerMap layer_to_player_map_;
76
77 explicit AnimationHost(bool is_impl_instance);
78
79 void PushTimelinesToImplThread(AnimationHost* host_impl) const;
80 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const;
81 void PushPropertiesToImplThread(AnimationHost* host_impl);
82
83 void EraseTimelines(AnimationTimelineList::iterator begin,
84 AnimationTimelineList::iterator end);
85
86 AnimationTimelineList timelines_;
87 scoped_ptr<AnimationRegistrar> animation_registrar_;
88 LayerTreeMutatorsClient* layer_tree_mutators_client_;
89
90 const bool is_impl_instance_;
91
92 DISALLOW_COPY_AND_ASSIGN(AnimationHost);
93 };
94
95 } // namespace cc
96
97 #endif // CC_ANIMATION_ANIMATION_HOST_H_
OLDNEW
« 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