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

Side by Side Diff: sky/engine/core/animation/AnimationTimeline.h

Issue 1229273004: Remove Animations and Transitions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef SKY_ENGINE_CORE_ANIMATION_ANIMATIONTIMELINE_H_
32 #define SKY_ENGINE_CORE_ANIMATION_ANIMATIONTIMELINE_H_
33
34 #include "sky/engine/tonic/dart_wrappable.h"
35 #include "sky/engine/core/animation/AnimationEffect.h"
36 #include "sky/engine/core/animation/AnimationPlayer.h"
37 #include "sky/engine/core/dom/Element.h"
38 #include "sky/engine/platform/Timer.h"
39 #include "sky/engine/platform/heap/Handle.h"
40 #include "sky/engine/wtf/RefCounted.h"
41 #include "sky/engine/wtf/RefPtr.h"
42 #include "sky/engine/wtf/Vector.h"
43
44 namespace blink {
45
46 class Document;
47 class AnimationNode;
48
49 // AnimationTimeline is constructed and owned by Document, and tied to its lifec ycle.
50 class AnimationTimeline : public RefCounted<AnimationTimeline>, public DartWrapp able {
51 DEFINE_WRAPPERTYPEINFO();
52 public:
53 class PlatformTiming {
54
55 public:
56 // Calls AnimationTimeline's wake() method after duration seconds.
57 virtual void wakeAfter(double duration) = 0;
58 virtual void cancelWake() = 0;
59 virtual void serviceOnNextFrame() = 0;
60 virtual ~PlatformTiming() { }
61 };
62
63 static PassRefPtr<AnimationTimeline> create(Document*, PassOwnPtr<PlatformTi ming> = nullptr);
64 ~AnimationTimeline();
65
66 void serviceAnimations(TimingUpdateReason);
67
68 // Creates a player attached to this timeline, but without a start time.
69 AnimationPlayer* createAnimationPlayer(AnimationNode*);
70 AnimationPlayer* play(AnimationNode*);
71 Vector<RefPtr<AnimationPlayer> > getAnimationPlayers();
72
73 #if !ENABLE(OILPAN)
74 void playerDestroyed(AnimationPlayer* player)
75 {
76 ASSERT(m_players.contains(player));
77 m_players.remove(player);
78 }
79 #endif
80
81 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); }
82 double zeroTime() const { return 0; }
83 double currentTime(bool& isNull);
84 double currentTime();
85 double currentTimeInternal(bool& isNull);
86 double currentTimeInternal();
87 double effectiveTime();
88
89 void setOutdatedAnimationPlayer(AnimationPlayer*);
90 bool hasOutdatedAnimationPlayer() const;
91
92 Document* document() { return m_document.get(); }
93 #if !ENABLE(OILPAN)
94 void detachFromDocument();
95 #endif
96 void wake();
97
98 protected:
99 AnimationTimeline(Document*, PassOwnPtr<PlatformTiming>);
100
101 private:
102 RawPtr<Document> m_document;
103 // AnimationPlayers which will be updated on the next frame
104 // i.e. current, in effect, or had timing changed
105 HashSet<RefPtr<AnimationPlayer> > m_playersNeedingUpdate;
106 HashSet<RawPtr<AnimationPlayer> > m_players;
107
108 friend class SMILTimeContainer;
109 static const double s_minimumDelay;
110
111 OwnPtr<PlatformTiming> m_timing;
112
113 class AnimationTimelineTiming final : public PlatformTiming {
114 public:
115 AnimationTimelineTiming(AnimationTimeline* timeline)
116 : m_timeline(timeline)
117 , m_timer(this, &AnimationTimelineTiming::timerFired)
118 {
119 ASSERT(m_timeline);
120 }
121
122 virtual void wakeAfter(double duration) override;
123 virtual void cancelWake() override;
124 virtual void serviceOnNextFrame() override;
125
126 void timerFired(Timer<AnimationTimelineTiming>*) { m_timeline->wake(); }
127
128 private:
129 RawPtr<AnimationTimeline> m_timeline;
130 Timer<AnimationTimelineTiming> m_timer;
131 };
132
133 friend class AnimationAnimationTimelineTest;
134 };
135
136 } // namespace blink
137
138 #endif // SKY_ENGINE_CORE_ANIMATION_ANIMATIONTIMELINE_H_
OLDNEW
« no previous file with comments | « sky/engine/core/animation/AnimationStackTest.cpp ('k') | sky/engine/core/animation/AnimationTimeline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698