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

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: Implement layer attach/detach. Fix code review issues. 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 void updateCompositorPlayerToElementAttachments();
106
100 Document* document() { return m_document.get(); } 107 Document* document() { return m_document.get(); }
101 #if !ENABLE(OILPAN) 108 #if !ENABLE(OILPAN)
102 void detachFromDocument(); 109 void detachFromDocument();
103 #endif 110 #endif
104 void wake(); 111 void wake();
105 112
106 DECLARE_TRACE(); 113 DECLARE_TRACE();
107 114
108 protected: 115 protected:
109 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); 116 AnimationTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>);
110 117
111 private: 118 private:
112 RawPtrWillBeMember<Document> m_document; 119 RawPtrWillBeMember<Document> m_document;
113 double m_zeroTime; 120 double m_zeroTime;
114 bool m_zeroTimeInitialized; 121 bool m_zeroTimeInitialized;
115 // AnimationPlayers which will be updated on the next frame 122 // AnimationPlayers which will be updated on the next frame
116 // i.e. current, in effect, or had timing changed 123 // i.e. current, in effect, or had timing changed
117 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e; 124 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdat e;
118 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players; 125 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players;
119 126
120 double m_playbackRate; 127 double m_playbackRate;
121 128
122 friend class SMILTimeContainer; 129 friend class SMILTimeContainer;
123 static const double s_minimumDelay; 130 static const double s_minimumDelay;
124 131
125 OwnPtrWillBeMember<PlatformTiming> m_timing; 132 OwnPtrWillBeMember<PlatformTiming> m_timing;
126 double m_lastCurrentTimeInternal; 133 double m_lastCurrentTimeInternal;
127 134
135 OwnPtr<WebCompositorAnimationTimeline> m_compositorTimeline;
136
128 class AnimationTimelineTiming final : public PlatformTiming { 137 class AnimationTimelineTiming final : public PlatformTiming {
129 public: 138 public:
130 AnimationTimelineTiming(AnimationTimeline* timeline) 139 AnimationTimelineTiming(AnimationTimeline* timeline)
131 : m_timeline(timeline) 140 : m_timeline(timeline)
132 , m_timer(this, &AnimationTimelineTiming::timerFired) 141 , m_timer(this, &AnimationTimelineTiming::timerFired)
133 { 142 {
134 ASSERT(m_timeline); 143 ASSERT(m_timeline);
135 } 144 }
136 145
137 virtual void wakeAfter(double duration) override; 146 virtual void wakeAfter(double duration) override;
138 virtual void cancelWake() override; 147 virtual void cancelWake() override;
139 virtual void serviceOnNextFrame() override; 148 virtual void serviceOnNextFrame() override;
140 149
141 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); } 150 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); }
142 151
143 DECLARE_VIRTUAL_TRACE(); 152 DECLARE_VIRTUAL_TRACE();
144 153
145 private: 154 private:
146 RawPtrWillBeMember<AnimationTimeline> m_timeline; 155 RawPtrWillBeMember<AnimationTimeline> m_timeline;
147 Timer<AnimationTimelineTiming> m_timer; 156 Timer<AnimationTimelineTiming> m_timer;
148 }; 157 };
149 158
150 friend class AnimationAnimationTimelineTest; 159 friend class AnimationAnimationTimelineTest;
151 }; 160 };
152 161
153 } // namespace blink 162 } // namespace blink
154 163
155 #endif 164 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698