OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef SMILTimeContainer_h | 26 #ifndef SMILTimeContainer_h |
27 #define SMILTimeContainer_h | 27 #define SMILTimeContainer_h |
28 | 28 |
29 #include "core/dom/QualifiedName.h" | 29 #include "core/dom/QualifiedName.h" |
30 #include "core/svg/animation/SMILTime.h" | 30 #include "core/svg/animation/SMILTime.h" |
31 #include "platform/Timer.h" | 31 #include "platform/Timer.h" |
32 #include "platform/graphics/ImageAnimationPolicy.h" | |
32 #include "platform/heap/Handle.h" | 33 #include "platform/heap/Handle.h" |
33 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
34 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
35 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
36 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
37 #include "wtf/text/StringHash.h" | 38 #include "wtf/text/StringHash.h" |
38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 class Document; | 43 class Document; |
43 class SVGElement; | 44 class SVGElement; |
44 class SVGSMILElement; | 45 class SVGSMILElement; |
45 class SVGSVGElement; | 46 class SVGSVGElement; |
46 | 47 |
47 class SMILTimeContainer : public RefCountedWillBeGarbageCollectedFinalized<SMILT imeContainer> { | 48 class SMILTimeContainer : public RefCountedWillBeGarbageCollectedFinalized<SMILT imeContainer> { |
48 public: | 49 public: |
49 static PassRefPtrWillBeRawPtr<SMILTimeContainer> create(SVGSVGElement& owner ) { return adoptRefWillBeNoop(new SMILTimeContainer(owner)); } | 50 static PassRefPtrWillBeRawPtr<SMILTimeContainer> create(SVGSVGElement& owner ) { return adoptRefWillBeNoop(new SMILTimeContainer(owner)); } |
50 ~SMILTimeContainer(); | 51 ~SMILTimeContainer(); |
51 | 52 |
52 void schedule(SVGSMILElement*, SVGElement*, const QualifiedName&); | 53 void schedule(SVGSMILElement*, SVGElement*, const QualifiedName&); |
53 void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&); | 54 void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&); |
54 void notifyIntervalsChanged(); | 55 void notifyIntervalsChanged(); |
55 | 56 |
56 SMILTime elapsed() const; | 57 SMILTime elapsed() const; |
57 | 58 |
58 bool isPaused() const; | 59 bool isPaused() const; |
59 bool isStarted() const; | 60 bool isStarted() const; |
61 bool isFrozen() const; | |
60 | 62 |
61 void begin(); | 63 void begin(); |
62 void pause(); | 64 void pause(bool freeze = false); |
63 void resume(); | 65 void resume(); |
64 void setElapsed(SMILTime); | 66 void setElapsed(SMILTime); |
65 | 67 |
66 void serviceAnimations(double monotonicAnimationStartTime); | 68 void serviceAnimations(double monotonicAnimationStartTime); |
67 bool hasAnimations() const; | 69 bool hasAnimations() const; |
68 | 70 |
69 void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; } | 71 void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; } |
70 | 72 |
71 void trace(Visitor*); | 73 void trace(Visitor*); |
72 | 74 |
73 private: | 75 private: |
74 explicit SMILTimeContainer(SVGSVGElement& owner); | 76 explicit SMILTimeContainer(SVGSVGElement& owner); |
75 | 77 |
76 enum FrameSchedulingState { | 78 enum FrameSchedulingState { |
77 // No frame scheduled. | 79 // No frame scheduled. |
78 Idle, | 80 Idle, |
79 // Scheduled a wakeup to update the animation values. | 81 // Scheduled a wakeup to update the animation values. |
80 SynchronizeAnimations, | 82 SynchronizeAnimations, |
81 // Scheduled a wakeup to trigger an animation frame. | 83 // Scheduled a wakeup to trigger an animation frame. |
82 FutureAnimationFrame, | 84 FutureAnimationFrame, |
83 // Scheduled a animation frame for continuous update. | 85 // Scheduled a animation frame for continuous update. |
84 AnimationFrame | 86 AnimationFrame |
85 }; | 87 }; |
88 enum AnimatedState { | |
fs
2014/12/22 16:23:15
I'd prefer to enumerate all the discrete states ra
je_julie(Not used)
2014/12/24 03:50:51
I removed it with improved concept.
| |
89 // initial state. | |
90 NormalState = 0, | |
91 // Paused animations. | |
92 PausedState = 1 << 0, | |
93 // Frozen animations. | |
94 FrozenState = 1 << 1 | |
95 }; | |
86 | 96 |
97 ImageAnimationPolicy getAnimationPolicy() const; | |
fs
2014/12/22 16:23:15
animationPolicy
je_julie(Not used)
2014/12/24 03:50:51
done.
| |
98 void freezeTimeline(); | |
87 bool isTimelineRunning() const; | 99 bool isTimelineRunning() const; |
88 void scheduleAnimationFrame(SMILTime fireTime); | 100 void scheduleAnimationFrame(SMILTime fireTime); |
89 void cancelAnimationFrame(); | 101 void cancelAnimationFrame(); |
90 void wakeupTimerFired(Timer<SMILTimeContainer>*); | 102 void wakeupTimerFired(Timer<SMILTimeContainer>*); |
103 void cancelAnimationPolicyTimer(); | |
104 void startAnimationPolicyTimer(); | |
105 void animationPolicyOnceTimerFired(Timer<SMILTimeContainer>*); | |
91 void updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToT ime = false); | 106 void updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToT ime = false); |
92 SMILTime updateAnimations(SMILTime elapsed, bool seekToTime = false); | 107 SMILTime updateAnimations(SMILTime elapsed, bool seekToTime = false); |
93 void serviceOnNextFrame(); | 108 void serviceOnNextFrame(); |
94 void scheduleWakeUp(double delayTime, FrameSchedulingState); | 109 void scheduleWakeUp(double delayTime, FrameSchedulingState); |
95 bool hasPendingSynchronization() const; | 110 bool hasPendingSynchronization() const; |
96 | 111 |
97 void updateDocumentOrderIndexes(); | 112 void updateDocumentOrderIndexes(); |
98 double lastResumeTime() const { return m_resumeTime ? m_resumeTime : m_begin Time; } | 113 double lastResumeTime() const { return m_resumeTime ? m_resumeTime : m_begin Time; } |
99 | 114 |
100 Document& document() const; | 115 Document& document() const; |
101 double currentTime() const; | 116 double currentTime() const; |
102 | 117 |
103 double m_beginTime; | 118 double m_beginTime; |
104 double m_pauseTime; | 119 double m_pauseTime; |
105 double m_resumeTime; | 120 double m_resumeTime; |
106 double m_accumulatedActiveTime; | 121 double m_accumulatedActiveTime; |
107 double m_presetStartTime; | 122 double m_presetStartTime; |
108 | 123 |
109 FrameSchedulingState m_frameSchedulingState; | 124 FrameSchedulingState m_frameSchedulingState; |
110 bool m_documentOrderIndexesDirty; | 125 bool m_documentOrderIndexesDirty; |
126 int m_animationState; | |
fs
2014/12/22 16:23:15
With the discrete states this would then be the en
je_julie(Not used)
2014/12/24 03:50:51
I removed it with improved concept.
| |
111 | 127 |
112 Timer<SMILTimeContainer> m_wakeupTimer; | 128 Timer<SMILTimeContainer> m_wakeupTimer; |
129 Timer<SMILTimeContainer> m_animationPolicyOnceTimer; | |
113 | 130 |
114 using ElementAttributePair = pair<RawPtrWillBeWeakMember<SVGElement>, Qualif iedName>; | 131 using ElementAttributePair = pair<RawPtrWillBeWeakMember<SVGElement>, Qualif iedName>; |
115 using AnimationsLinkedHashSet = WillBeHeapLinkedHashSet<RawPtrWillBeWeakMemb er<SVGSMILElement>>; | 132 using AnimationsLinkedHashSet = WillBeHeapLinkedHashSet<RawPtrWillBeWeakMemb er<SVGSMILElement>>; |
116 using GroupedAnimationsMap = WillBeHeapHashMap<ElementAttributePair, OwnPtrW illBeMember<AnimationsLinkedHashSet>>; | 133 using GroupedAnimationsMap = WillBeHeapHashMap<ElementAttributePair, OwnPtrW illBeMember<AnimationsLinkedHashSet>>; |
117 GroupedAnimationsMap m_scheduledAnimations; | 134 GroupedAnimationsMap m_scheduledAnimations; |
118 | 135 |
119 SVGSVGElement& m_ownerSVGElement; | 136 SVGSVGElement& m_ownerSVGElement; |
120 | 137 |
121 #if ENABLE(ASSERT) | 138 #if ENABLE(ASSERT) |
122 bool m_preventScheduledAnimationsChanges; | 139 bool m_preventScheduledAnimationsChanges; |
123 #endif | 140 #endif |
124 }; | 141 }; |
125 } | 142 } |
126 | 143 |
127 #endif // SMILTimeContainer_h | 144 #endif // SMILTimeContainer_h |
OLD | NEW |