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" | 14 #include "wtf/RefCounted.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class CORE_EXPORT InterpolationEffect : public RefCountedWillBeGarbageCollected<
InterpolationEffect> { | 18 class CORE_EXPORT InterpolationEffect : public GarbageCollected<InterpolationEff
ect> { |
19 public: | 19 public: |
20 static PassRefPtrWillBeRawPtr<InterpolationEffect> create() | 20 static InterpolationEffect* create() |
21 { | 21 { |
22 return adoptRefWillBeNoop(new InterpolationEffect()); | 22 return new InterpolationEffect(); |
23 } | 23 } |
24 | 24 |
25 void getActiveInterpolations(double fraction, double iterationDuration, OwnP
trWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const; | 25 void getActiveInterpolations(double fraction, double iterationDuration, Heap
Vector<Member<Interpolation>>*&) const; |
26 | 26 |
27 void addInterpolation(PassRefPtrWillBeRawPtr<Interpolation> interpolation, P
assRefPtr<TimingFunction> easing, double start, double end, double applyFrom, do
uble applyTo) | 27 void addInterpolation(Interpolation* interpolation, PassRefPtr<TimingFunctio
n> easing, double start, double end, double applyFrom, double applyTo) |
28 { | 28 { |
29 m_interpolations.append(InterpolationRecord::create(interpolation, easin
g, start, end, applyFrom, applyTo)); | 29 m_interpolations.append(InterpolationRecord::create(interpolation, easin
g, start, end, applyFrom, applyTo)); |
30 } | 30 } |
31 | 31 |
32 void addInterpolationsFromKeyframes(PropertyHandle, Element*, const Computed
Style* baseStyle, Keyframe::PropertySpecificKeyframe& keyframeA, Keyframe::Prope
rtySpecificKeyframe& keyframeB, double applyFrom, double applyTo); | 32 void addInterpolationsFromKeyframes(PropertyHandle, Element*, const Computed
Style* baseStyle, Keyframe::PropertySpecificKeyframe& keyframeA, Keyframe::Prope
rtySpecificKeyframe& keyframeB, double applyFrom, double applyTo); |
33 | 33 |
34 template<typename T> | 34 template<typename T> |
35 inline void forEachInterpolation(const T& callback) | 35 inline void forEachInterpolation(const T& callback) |
36 { | 36 { |
37 for (auto& record : m_interpolations) | 37 for (auto& record : m_interpolations) |
38 callback(*record->m_interpolation); | 38 callback(*record->m_interpolation); |
39 } | 39 } |
40 | 40 |
41 DECLARE_TRACE(); | 41 DECLARE_TRACE(); |
42 | 42 |
43 private: | 43 private: |
44 InterpolationEffect() | 44 InterpolationEffect() |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 class InterpolationRecord : public NoBaseWillBeGarbageCollectedFinalized<Int
erpolationRecord> { | 48 class InterpolationRecord : public GarbageCollectedFinalized<InterpolationRe
cord> { |
49 public: | 49 public: |
50 RefPtrWillBeMember<Interpolation> m_interpolation; | 50 Member<Interpolation> m_interpolation; |
51 RefPtr<TimingFunction> m_easing; | 51 RefPtr<TimingFunction> m_easing; |
52 double m_start; | 52 double m_start; |
53 double m_end; | 53 double m_end; |
54 double m_applyFrom; | 54 double m_applyFrom; |
55 double m_applyTo; | 55 double m_applyTo; |
56 | 56 |
57 static PassOwnPtrWillBeRawPtr<InterpolationRecord> create(PassRefPtrWill
BeRawPtr<Interpolation> interpolation, PassRefPtr<TimingFunction> easing, double
start, double end, double applyFrom, double applyTo) | 57 static InterpolationRecord* create(Interpolation* interpolation, PassRef
Ptr<TimingFunction> easing, double start, double end, double applyFrom, double a
pplyTo) |
58 { | 58 { |
59 return adoptPtrWillBeNoop(new InterpolationRecord(interpolation, eas
ing, start, end, applyFrom, applyTo)); | 59 return new InterpolationRecord(interpolation, easing, start, end, ap
plyFrom, applyTo); |
60 } | 60 } |
61 | 61 |
62 DECLARE_TRACE(); | 62 DECLARE_TRACE(); |
63 | 63 |
64 private: | 64 private: |
65 InterpolationRecord(PassRefPtrWillBeRawPtr<Interpolation> interpolation,
PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom,
double applyTo) | 65 InterpolationRecord(Interpolation* interpolation, PassRefPtr<TimingFunct
ion> easing, double start, double end, double applyFrom, double applyTo) |
66 : m_interpolation(interpolation) | 66 : m_interpolation(interpolation) |
67 , m_easing(easing) | 67 , m_easing(easing) |
68 , m_start(start) | 68 , m_start(start) |
69 , m_end(end) | 69 , m_end(end) |
70 , m_applyFrom(applyFrom) | 70 , m_applyFrom(applyFrom) |
71 , m_applyTo(applyTo) | 71 , m_applyTo(applyTo) |
72 { | 72 { |
73 } | 73 } |
74 }; | 74 }; |
75 | 75 |
76 WillBeHeapVector<OwnPtrWillBeMember<InterpolationRecord>> m_interpolations; | 76 HeapVector<Member<InterpolationRecord>> m_interpolations; |
77 }; | 77 }; |
78 | 78 |
79 } // namespace blink | 79 } // namespace blink |
80 | 80 |
81 #endif // InterpolationEffect_h | 81 #endif // InterpolationEffect_h |
OLD | NEW |