All instances of addresses as void* are changed to uintptr_t in
[chromium-blink-merge.git] / cc / animation / animation_timeline.h
blob4cb31f5c07606c5188bd85033711bb9e9438dbb5
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.
5 #ifndef CC_ANIMATION_ANIMATION_TIMELINE_H_
6 #define CC_ANIMATION_ANIMATION_TIMELINE_H_
8 #include <vector>
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"
15 namespace cc {
17 class AnimationHost;
18 class AnimationPlayer;
20 typedef std::vector<scoped_refptr<AnimationPlayer>> AnimationPlayerList;
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 its 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> {
28 public:
29 static scoped_refptr<AnimationTimeline> Create(int id);
30 scoped_refptr<AnimationTimeline> CreateImplInstance() const;
32 int id() const { return id_; }
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);
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_; }
42 void AttachPlayer(scoped_refptr<AnimationPlayer> player);
43 void DetachPlayer(scoped_refptr<AnimationPlayer> player);
45 void ClearPlayers();
47 void PushPropertiesTo(AnimationTimeline* timeline_impl);
49 AnimationPlayer* GetPlayerById(int player_id) const;
51 private:
52 friend class base::RefCounted<AnimationTimeline>;
54 explicit AnimationTimeline(int id);
55 virtual ~AnimationTimeline();
57 void PushAttachedPlayersToImplThread(AnimationTimeline* timeline) const;
58 void RemoveDetachedPlayersFromImplThread(AnimationTimeline* timeline) const;
59 void PushPropertiesToImplThread(AnimationTimeline* timeline);
61 void ErasePlayers(AnimationPlayerList::iterator begin,
62 AnimationPlayerList::iterator end);
64 AnimationPlayerList players_;
65 int id_;
66 AnimationHost* animation_host_;
68 // Impl-only AnimationTimeline has no main thread instance and lives on
69 // it's own.
70 bool is_impl_only_;
72 DISALLOW_COPY_AND_ASSIGN(AnimationTimeline);
75 } // namespace cc
77 #endif // CC_ANIMATION_ANIMATION_TIMELINE_H_