OLD | NEW |
(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 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; |
| 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(scoped_refptr<AnimationPlayer> player); |
| 43 void DetachPlayer(scoped_refptr<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_ |
OLD | NEW |