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

Side by Side Diff: cc/animation/animation_timeline.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_TIMELINE_H_
6 #define CC_ANIMATION_ANIMATION_TIMELINE_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 AnimationHost;
18 class AnimationPlayer;
19
20 typedef std::vector<scoped_refptr<AnimationPlayer>> AnimationPlayerList;
21
22 // An AnimationTimeline owns a group of AnimationPlayers.
23 // This is a cc counterpart for blink::AnimationTimeline (in 1:1 relationship).
24 // Each AnimationTimeline and it's AnimationPlayers have their copies on
25 // the impl thread. We synchronize main thread and impl thread instances
26 // using integer IDs.
27 class CC_EXPORT AnimationTimeline : public base::RefCounted<AnimationTimeline> {
Ian Vollick 2015/05/05 03:52:07 Why refptr?
loyso (OOO) 2015/05/05 06:51:18 Shared between cc::AnimationHost and blink::Animat
Ian Vollick 2015/05/07 13:58:43 IIUC, this means that both the cc::AnimationHost a
loyso (OOO) 2015/05/08 01:04:35 Yes, that's true. We can create WebCompositorAnima
28 public:
29 static scoped_refptr<AnimationTimeline> Create(int id);
30 scoped_refptr<AnimationTimeline> CreateImplInstance() const;
31
32 int id() const { return id_; }
33
34 // Parent AnimationHost.
35 AnimationHost* animation_host() { return animation_host_; }
36 const AnimationHost* animation_host() const { return animation_host_; }
37 void SetAnimationHost(AnimationHost* animation_host);
38
39 void set_is_impl_only(bool is_impl_only) { is_impl_only_ = is_impl_only; }
40 bool is_impl_only() const { return is_impl_only_; }
41
42 void AttachPlayer(AnimationPlayer* player);
43 void DetachPlayer(AnimationPlayer* player);
44
45 void ClearPlayers();
46
47 void PushPropertiesTo(AnimationTimeline* timeline_impl);
48
49 AnimationPlayer* GetPlayerById(int player_id) const;
50
51 private:
52 friend class base::RefCounted<AnimationTimeline>;
53
54 explicit AnimationTimeline(int id);
55 virtual ~AnimationTimeline();
56
57 void PushAttachedPlayersToImplThread(AnimationTimeline* timeline) const;
58 void RemoveDetachedPlayersFromImplThread(AnimationTimeline* timeline) const;
59 void PushPropertiesToImplThread(AnimationTimeline* timeline);
60
61 void ErasePlayers(AnimationPlayerList::iterator begin,
62 AnimationPlayerList::iterator end);
63
64 AnimationPlayerList players_;
65 int id_;
66 AnimationHost* animation_host_;
67
68 // Impl-only AnimationTimeline has no main thread instance and lives on
69 // it's own.
70 bool is_impl_only_;
71
72 DISALLOW_COPY_AND_ASSIGN(AnimationTimeline);
73 };
74
75 } // namespace cc
76
77 #endif // CC_ANIMATION_ANIMATION_TIMELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698