OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef InterpolationEffect_h | 5 #ifndef InterpolationEffect_h |
6 #define InterpolationEffect_h | 6 #define InterpolationEffect_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/animation/Interpolation.h" | 9 #include "core/animation/Interpolation.h" |
10 #include "core/animation/Keyframe.h" | 10 #include "core/animation/Keyframe.h" |
11 #include "platform/RuntimeEnabledFeatures.h" | 11 #include "platform/RuntimeEnabledFeatures.h" |
12 #include "platform/animation/TimingFunction.h" | 12 #include "platform/animation/TimingFunction.h" |
13 #include "wtf/PassOwnPtr.h" | 13 #include "wtf/PassOwnPtr.h" |
14 #include "wtf/RefCounted.h" | |
15 | 14 |
16 namespace blink { | 15 namespace blink { |
17 | 16 |
18 class CORE_EXPORT InterpolationEffect : public RefCountedWillBeGarbageCollected<
InterpolationEffect> { | 17 class CORE_EXPORT InterpolationEffect : public GarbageCollected<InterpolationEff
ect> { |
19 public: | 18 public: |
20 static PassRefPtrWillBeRawPtr<InterpolationEffect> create() | 19 static InterpolationEffect* create() |
21 { | 20 { |
22 return adoptRefWillBeNoop(new InterpolationEffect()); | 21 return new InterpolationEffect(); |
23 } | 22 } |
24 | 23 |
25 void getActiveInterpolations(double fraction, double iterationDuration, OwnP
trWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const; | 24 void getActiveInterpolations(double fraction, double iterationDuration, OwnP
trWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const; |
26 | 25 |
27 void addInterpolation(PassRefPtrWillBeRawPtr<Interpolation> interpolation, P
assRefPtr<TimingFunction> easing, double start, double end, double applyFrom, do
uble applyTo) | 26 void addInterpolation(PassRefPtrWillBeRawPtr<Interpolation> interpolation, P
assRefPtr<TimingFunction> easing, double start, double end, double applyFrom, do
uble applyTo) |
28 { | 27 { |
29 m_interpolations.append(InterpolationRecord::create(interpolation, easin
g, start, end, applyFrom, applyTo)); | 28 m_interpolations.append(InterpolationRecord::create(interpolation, easin
g, start, end, applyFrom, applyTo)); |
30 } | 29 } |
31 | 30 |
32 void addInterpolationsFromKeyframes(PropertyHandle, Element*, const Computed
Style* baseStyle, Keyframe::PropertySpecificKeyframe& keyframeA, Keyframe::Prope
rtySpecificKeyframe& keyframeB, double applyFrom, double applyTo); | 31 void addInterpolationsFromKeyframes(PropertyHandle, Element*, const Computed
Style* baseStyle, Keyframe::PropertySpecificKeyframe& keyframeA, Keyframe::Prope
rtySpecificKeyframe& keyframeB, double applyFrom, double applyTo); |
33 | 32 |
34 template<typename T> | 33 template<typename T> |
35 inline void forEachInterpolation(const T& callback) | 34 inline void forEachInterpolation(const T& callback) |
36 { | 35 { |
37 for (auto& record : m_interpolations) | 36 for (auto& record : m_interpolations) |
38 callback(*record->m_interpolation); | 37 callback(*record->m_interpolation); |
39 } | 38 } |
40 | 39 |
41 DECLARE_TRACE(); | 40 DECLARE_TRACE(); |
42 | 41 |
43 private: | 42 private: |
44 InterpolationEffect() | 43 InterpolationEffect() |
45 { | 44 { |
46 } | 45 } |
47 | 46 |
48 class InterpolationRecord : public NoBaseWillBeGarbageCollectedFinalized<Int
erpolationRecord> { | 47 class InterpolationRecord : public GarbageCollectedFinalized<InterpolationRe
cord> { |
49 public: | 48 public: |
50 RefPtrWillBeMember<Interpolation> m_interpolation; | 49 RefPtrWillBeMember<Interpolation> m_interpolation; |
51 RefPtr<TimingFunction> m_easing; | 50 RefPtr<TimingFunction> m_easing; |
52 double m_start; | 51 double m_start; |
53 double m_end; | 52 double m_end; |
54 double m_applyFrom; | 53 double m_applyFrom; |
55 double m_applyTo; | 54 double m_applyTo; |
56 | 55 |
57 static PassOwnPtrWillBeRawPtr<InterpolationRecord> create(PassRefPtrWill
BeRawPtr<Interpolation> interpolation, PassRefPtr<TimingFunction> easing, double
start, double end, double applyFrom, double applyTo) | 56 static InterpolationRecord* create(PassRefPtrWillBeRawPtr<Interpolation>
interpolation, PassRefPtr<TimingFunction> easing, double start, double end, dou
ble applyFrom, double applyTo) |
58 { | 57 { |
59 return adoptPtrWillBeNoop(new InterpolationRecord(interpolation, eas
ing, start, end, applyFrom, applyTo)); | 58 return new InterpolationRecord(interpolation, easing, start, end, ap
plyFrom, applyTo); |
60 } | 59 } |
61 | 60 |
62 DECLARE_TRACE(); | 61 DECLARE_TRACE(); |
63 | 62 |
64 private: | 63 private: |
65 InterpolationRecord(PassRefPtrWillBeRawPtr<Interpolation> interpolation,
PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom,
double applyTo) | 64 InterpolationRecord(PassRefPtrWillBeRawPtr<Interpolation> interpolation,
PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom,
double applyTo) |
66 : m_interpolation(interpolation) | 65 : m_interpolation(interpolation) |
67 , m_easing(easing) | 66 , m_easing(easing) |
68 , m_start(start) | 67 , m_start(start) |
69 , m_end(end) | 68 , m_end(end) |
70 , m_applyFrom(applyFrom) | 69 , m_applyFrom(applyFrom) |
71 , m_applyTo(applyTo) | 70 , m_applyTo(applyTo) |
72 { | 71 { |
73 } | 72 } |
74 }; | 73 }; |
75 | 74 |
76 WillBeHeapVector<OwnPtrWillBeMember<InterpolationRecord>> m_interpolations; | 75 HeapVector<Member<InterpolationRecord>> m_interpolations; |
77 }; | 76 }; |
78 | 77 |
79 } // namespace blink | 78 } // namespace blink |
80 | 79 |
81 #endif // InterpolationEffect_h | 80 #endif // InterpolationEffect_h |
OLD | NEW |