| 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 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class CORE_EXPORT InterpolationEffect : public GarbageCollected<InterpolationEff
ect> { | 17 class CORE_EXPORT InterpolationEffect : public RefCounted<InterpolationEffect> { |
| 18 public: | 18 public: |
| 19 static InterpolationEffect* create() | 19 static PassRefPtr<InterpolationEffect> create() |
| 20 { | 20 { |
| 21 return new InterpolationEffect(); | 21 return adoptRef(new InterpolationEffect()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void getActiveInterpolations(double fraction, double iterationDuration, OwnP
trWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const; | 24 void getActiveInterpolations(double fraction, double iterationDuration, OwnP
tr<Vector<RefPtr<Interpolation>>>&) const; |
| 25 | 25 |
| 26 void addInterpolation(PassRefPtrWillBeRawPtr<Interpolation> interpolation, P
assRefPtr<TimingFunction> easing, double start, double end, double applyFrom, do
uble applyTo) | 26 void addInterpolation(PassRefPtr<Interpolation> interpolation, PassRefPtr<Ti
mingFunction> easing, double start, double end, double applyFrom, double applyTo
) |
| 27 { | 27 { |
| 28 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)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 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); |
| 32 | 32 |
| 33 template<typename T> | 33 template<typename T> |
| 34 inline void forEachInterpolation(const T& callback) | 34 inline void forEachInterpolation(const T& callback) |
| 35 { | 35 { |
| 36 for (auto& record : m_interpolations) | 36 for (auto& record : m_interpolations) |
| 37 callback(*record->m_interpolation); | 37 callback(*record->m_interpolation); |
| 38 } | 38 } |
| 39 | 39 |
| 40 DECLARE_TRACE(); | |
| 41 | |
| 42 private: | 40 private: |
| 43 InterpolationEffect() | 41 InterpolationEffect() |
| 44 { | 42 { |
| 45 } | 43 } |
| 46 | 44 |
| 47 class InterpolationRecord : public GarbageCollectedFinalized<InterpolationRe
cord> { | 45 class InterpolationRecord : public RefCounted<InterpolationRecord> { |
| 48 public: | 46 public: |
| 49 RefPtrWillBeMember<Interpolation> m_interpolation; | 47 RefPtr<Interpolation> m_interpolation; |
| 50 RefPtr<TimingFunction> m_easing; | 48 RefPtr<TimingFunction> m_easing; |
| 51 double m_start; | 49 double m_start; |
| 52 double m_end; | 50 double m_end; |
| 53 double m_applyFrom; | 51 double m_applyFrom; |
| 54 double m_applyTo; | 52 double m_applyTo; |
| 55 | 53 |
| 56 static InterpolationRecord* create(PassRefPtrWillBeRawPtr<Interpolation>
interpolation, PassRefPtr<TimingFunction> easing, double start, double end, dou
ble applyFrom, double applyTo) | 54 static PassRefPtr<InterpolationRecord> create(PassRefPtr<Interpolation>
interpolation, PassRefPtr<TimingFunction> easing, double start, double end, doub
le applyFrom, double applyTo) |
| 57 { | 55 { |
| 58 return new InterpolationRecord(interpolation, easing, start, end, ap
plyFrom, applyTo); | 56 return adoptRef(new InterpolationRecord(interpolation, easing, start
, end, applyFrom, applyTo)); |
| 59 } | 57 } |
| 60 | 58 |
| 61 DECLARE_TRACE(); | |
| 62 | |
| 63 private: | 59 private: |
| 64 InterpolationRecord(PassRefPtrWillBeRawPtr<Interpolation> interpolation,
PassRefPtr<TimingFunction> easing, double start, double end, double applyFrom,
double applyTo) | 60 InterpolationRecord(PassRefPtr<Interpolation> interpolation, PassRefPtr<
TimingFunction> easing, double start, double end, double applyFrom, double apply
To) |
| 65 : m_interpolation(interpolation) | 61 : m_interpolation(interpolation) |
| 66 , m_easing(easing) | 62 , m_easing(easing) |
| 67 , m_start(start) | 63 , m_start(start) |
| 68 , m_end(end) | 64 , m_end(end) |
| 69 , m_applyFrom(applyFrom) | 65 , m_applyFrom(applyFrom) |
| 70 , m_applyTo(applyTo) | 66 , m_applyTo(applyTo) |
| 71 { | 67 { |
| 72 } | 68 } |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 HeapVector<Member<InterpolationRecord>> m_interpolations; | 71 Vector<RefPtr<InterpolationRecord>> m_interpolations; |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 } // namespace blink | 74 } // namespace blink |
| 79 | 75 |
| 80 #endif // InterpolationEffect_h | 76 #endif // InterpolationEffect_h |
| OLD | NEW |