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

Side by Side Diff: Source/core/animation/AnimationTimeline.h

Issue 946323002: Animations: Introduce compositor AnimationPlayer and AnimationTimeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix the order. Created 5 years, 9 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
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #ifndef AnimationTimeline_h 31 #ifndef AnimationTimeline_h
32 #define AnimationTimeline_h 32 #define AnimationTimeline_h
33 33
34 #include "bindings/core/v8/ScriptWrappable.h" 34 #include "bindings/core/v8/ScriptWrappable.h"
35 #include "core/animation/AnimationEffect.h" 35 #include "core/animation/AnimationEffect.h"
36 #include "core/animation/AnimationPlayer.h" 36 #include "core/animation/AnimationPlayer.h"
37 #include "core/dom/Element.h" 37 #include "core/dom/Element.h"
38 #include "platform/Timer.h" 38 #include "platform/Timer.h"
39 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
40 #include "public/platform/WebCompositorAnimationTimeline.h"
40 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
41 #include "wtf/RefPtr.h" 42 #include "wtf/RefPtr.h"
42 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class Document; 47 class Document;
47 class AnimationNode; 48 class AnimationNode;
48 49
49 // AnimationTimeline is constructed and owned by Document, and tied to its lifec ycle. 50 // AnimationTimeline is constructed and owned by Document, and tied to its lifec ycle.
(...skipping 19 matching lines...) Expand all
69 70
70 AnimationPlayer* play(AnimationNode*); 71 AnimationPlayer* play(AnimationNode*);
71 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers(); 72 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers();
72 73
73 void playerAttached(AnimationPlayer&); 74 void playerAttached(AnimationPlayer&);
74 #if !ENABLE(OILPAN) 75 #if !ENABLE(OILPAN)
75 void playerDestroyed(AnimationPlayer* player) 76 void playerDestroyed(AnimationPlayer* player)
76 { 77 {
77 ASSERT(m_players.contains(player)); 78 ASSERT(m_players.contains(player));
78 m_players.remove(player); 79 m_players.remove(player);
80
81 if (m_compositorTimeline)
82 m_compositorTimeline->playerDestroyed(*player);
79 } 83 }
80 #endif 84 #endif
81 85
82 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } 86 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); }
83 double zeroTime(); 87 double zeroTime();
84 double currentTime(bool& isNull); 88 double currentTime(bool& isNull);
85 double currentTime(); 89 double currentTime();
86 double currentTimeInternal(bool& isNull); 90 double currentTimeInternal(bool& isNull);
87 double currentTimeInternal(); 91 double currentTimeInternal();
88 void setCurrentTime(double); 92 void setCurrentTime(double);
89 void setCurrentTimeInternal(double); 93 void setCurrentTimeInternal(double);
90 double effectiveTime(); 94 double effectiveTime();
91 void pauseAnimationsForTesting(double); 95 void pauseAnimationsForTesting(double);
92 96
93 void setOutdatedAnimationPlayer(AnimationPlayer*); 97 void setOutdatedAnimationPlayer(AnimationPlayer*);
94 bool hasOutdatedAnimationPlayer() const; 98 bool hasOutdatedAnimationPlayer() const;
95 bool needsAnimationTimingUpdate(); 99 bool needsAnimationTimingUpdate();
96 100
97 void setPlaybackRate(double); 101 void setPlaybackRate(double);
98 double playbackRate() const; 102 double playbackRate() const;
99 103
104 WebCompositorAnimationTimeline* compositorTimeline() const { return m_compos itorTimeline.get(); }
105
100 Document* document() { return m_document.get(); } 106 Document* document() { return m_document.get(); }
101 #if !ENABLE(OILPAN) 107 #if !ENABLE(OILPAN)
102 void detachFromDocument(); 108 void detachFromDocument();
103 #endif 109 #endif
104 void wake(); 110 void wake();
105 111
106 DECLARE_TRACE(); 112 DECLARE_TRACE();
107 113
108 protected: 114 protected:
109 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); 115 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>);
110 116
111 private: 117 private:
112 RawPtrWillBeMember<Document> m_document; 118 RawPtrWillBeMember<Document> m_document;
113 double m_zeroTime; 119 double m_zeroTime;
114 bool m_zeroTimeInitialized; 120 bool m_zeroTimeInitialized;
115 // AnimationPlayers which will be updated on the next frame 121 // AnimationPlayers which will be updated on the next frame
116 // i.e. current, in effect, or had timing changed 122 // i.e. current, in effect, or had timing changed
117 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e; 123 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e;
118 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players; 124 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players;
119 125
120 double m_playbackRate; 126 double m_playbackRate;
121 127
122 friend class SMILTimeContainer; 128 friend class SMILTimeContainer;
123 static const double s_minimumDelay; 129 static const double s_minimumDelay;
124 130
125 OwnPtrWillBeMember<PlatformTiming> m_timing; 131 OwnPtrWillBeMember<PlatformTiming> m_timing;
126 double m_lastCurrentTimeInternal; 132 double m_lastCurrentTimeInternal;
127 133
134 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline;
135
128 class AnimationTimelineTiming final : public PlatformTiming { 136 class AnimationTimelineTiming final : public PlatformTiming {
129 public: 137 public:
130 AnimationTimelineTiming(AnimationTimeline* timeline) 138 AnimationTimelineTiming(AnimationTimeline* timeline)
131 : m_timeline(timeline) 139 : m_timeline(timeline)
132 , m_timer(this, &AnimationTimelineTiming::timerFired) 140 , m_timer(this, &AnimationTimelineTiming::timerFired)
133 { 141 {
134 ASSERT(m_timeline); 142 ASSERT(m_timeline);
135 } 143 }
136 144
137 virtual void wakeAfter(double duration) override; 145 virtual void wakeAfter(double duration) override;
138 virtual void cancelWake() override; 146 virtual void cancelWake() override;
139 virtual void serviceOnNextFrame() override; 147 virtual void serviceOnNextFrame() override;
140 148
141 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); } 149 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); }
142 150
143 DECLARE_VIRTUAL_TRACE(); 151 DECLARE_VIRTUAL_TRACE();
144 152
145 private: 153 private:
146 RawPtrWillBeMember<AnimationTimeline> m_timeline; 154 RawPtrWillBeMember<AnimationTimeline> m_timeline;
147 Timer<AnimationTimelineTiming> m_timer; 155 Timer<AnimationTimelineTiming> m_timer;
148 }; 156 };
149 157
150 friend class AnimationAnimationTimelineTest; 158 friend class AnimationAnimationTimelineTest;
151 }; 159 };
152 160
153 } // namespace blink 161 } // namespace blink
154 162
155 #endif 163 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698