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

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: Fix MSVC warning. Created 5 years, 5 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
« no previous file with comments | « cc/BUILD.gn ('k') | cc/animation/animation_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scoped_ptr_hash_map.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/trees/mutator_host_client.h"
15
16 namespace cc {
17
18 class AnimationPlayer;
19 class AnimationRegistrar;
20 class AnimationTimeline;
21 class ElementAnimations;
22 class LayerAnimationController;
23 class LayerTreeHost;
24
25 enum class ThreadInstance { MAIN, IMPL };
26
27 typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList;
28
29 // An AnimationHost contains all the state required to play animations.
30 // Specifically, it owns all the AnimationTimelines objects.
31 // There is just one AnimationHost for LayerTreeHost on main renderer thread
32 // and just one AnimationHost for LayerTreeHostImpl on impl thread.
33 // We synchronize them during the commit process in a one-way data flow process
34 // (PushPropertiesTo).
35 // An AnimationHost talks to its correspondent LayerTreeHost via
36 // LayerTreeMutatorsClient interface.
37 // AnimationHost has it's own instance of AnimationRegistrar,
38 // we want to merge AnimationRegistrar into AnimationHost.
39 class CC_EXPORT AnimationHost {
40 public:
41 static scoped_ptr<AnimationHost> Create(ThreadInstance thread_instance);
42 virtual ~AnimationHost();
43
44 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
45 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
46 AnimationTimeline* GetTimelineById(int timeline_id) const;
47
48 void ClearTimelines();
49
50 void RegisterLayer(int layer_id, LayerTreeType tree_type);
51 void UnregisterLayer(int layer_id, LayerTreeType tree_type);
52
53 void RegisterPlayerForLayer(int layer_id, AnimationPlayer* player);
54 void UnregisterPlayerForLayer(int layer_id, AnimationPlayer* player);
55
56 ElementAnimations* GetElementAnimationsForLayerId(int layer_id) const;
57
58 // TODO(loyso): Get rid of LayerAnimationController.
59 LayerAnimationController* GetControllerForLayerId(int layer_id) const;
60
61 // Parent LayerTreeHost or LayerTreeHostImpl.
62 MutatorHostClient* mutator_host_client() { return mutator_host_client_; }
63 const MutatorHostClient* mutator_host_client() const {
64 return mutator_host_client_;
65 }
66 void SetMutatorHostClient(MutatorHostClient* client);
67
68 void SetNeedsCommit();
69
70 void PushPropertiesTo(AnimationHost* host_impl);
71
72 AnimationRegistrar* animation_registrar() const {
73 return animation_registrar_.get();
74 }
75
76 private:
77 explicit AnimationHost(ThreadInstance thread_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 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object
87 // if they are attached to the same element(layer). Note that Element can
88 // contain many Layers.
89 typedef base::ScopedPtrHashMap<int, scoped_ptr<ElementAnimations>>
90 LayerToElementAnimationsMap;
91 LayerToElementAnimationsMap layer_to_element_animations_map_;
92
93 AnimationTimelineList timelines_;
94 scoped_ptr<AnimationRegistrar> animation_registrar_;
95 MutatorHostClient* mutator_host_client_;
96
97 const ThreadInstance thread_instance_;
98
99 DISALLOW_COPY_AND_ASSIGN(AnimationHost);
100 };
101
102 } // namespace cc
103
104 #endif // CC_ANIMATION_ANIMATION_HOST_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/animation/animation_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698