| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef KeyframeEffectModel_h | 31 #ifndef KeyframeEffectModel_h |
| 32 #define KeyframeEffectModel_h | 32 #define KeyframeEffectModel_h |
| 33 | 33 |
| 34 #include <memory> |
| 34 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 35 #include "core/animation/AnimationEffectReadOnly.h" | 36 #include "core/animation/AnimationEffectReadOnly.h" |
| 36 #include "core/animation/EffectModel.h" | 37 #include "core/animation/EffectModel.h" |
| 37 #include "core/animation/InterpolationEffect.h" | 38 #include "core/animation/InterpolationEffect.h" |
| 38 #include "core/animation/PropertyHandle.h" | 39 #include "core/animation/PropertyHandle.h" |
| 39 #include "core/animation/StringKeyframe.h" | 40 #include "core/animation/StringKeyframe.h" |
| 41 #include "core/animation/TransitionKeyframe.h" |
| 40 #include "core/animation/animatable/AnimatableValueKeyframe.h" | 42 #include "core/animation/animatable/AnimatableValueKeyframe.h" |
| 41 #include "platform/animation/TimingFunction.h" | 43 #include "platform/animation/TimingFunction.h" |
| 42 #include "platform/heap/Handle.h" | 44 #include "platform/heap/Handle.h" |
| 43 #include "wtf/HashMap.h" | 45 #include "wtf/HashMap.h" |
| 44 #include "wtf/HashSet.h" | 46 #include "wtf/HashSet.h" |
| 45 #include "wtf/PassRefPtr.h" | 47 #include "wtf/PassRefPtr.h" |
| 46 #include "wtf/Vector.h" | 48 #include "wtf/Vector.h" |
| 47 #include <memory> | |
| 48 | 49 |
| 49 namespace blink { | 50 namespace blink { |
| 50 | 51 |
| 51 class Element; | 52 class Element; |
| 52 class KeyframeEffectModelTest; | 53 class KeyframeEffectModelTest; |
| 53 | 54 |
| 54 class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { | 55 class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { |
| 55 public: | 56 public: |
| 56 // FIXME: Implement accumulation. | 57 // FIXME: Implement accumulation. |
| 57 | 58 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // EffectModel implementation. | 99 // EffectModel implementation. |
| 99 bool sample(int iteration, | 100 bool sample(int iteration, |
| 100 double fraction, | 101 double fraction, |
| 101 double iterationDuration, | 102 double iterationDuration, |
| 102 Vector<RefPtr<Interpolation>>&) const override; | 103 Vector<RefPtr<Interpolation>>&) const override; |
| 103 | 104 |
| 104 bool isKeyframeEffectModel() const override { return true; } | 105 bool isKeyframeEffectModel() const override { return true; } |
| 105 | 106 |
| 106 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } | 107 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } |
| 107 virtual bool isStringKeyframeEffectModel() const { return false; } | 108 virtual bool isStringKeyframeEffectModel() const { return false; } |
| 109 virtual bool isTransitionKeyframeEffectModel() const { return false; } |
| 108 | 110 |
| 109 bool hasSyntheticKeyframes() const { | 111 bool hasSyntheticKeyframes() const { |
| 110 ensureKeyframeGroups(); | 112 ensureKeyframeGroups(); |
| 111 return m_hasSyntheticKeyframes; | 113 return m_hasSyntheticKeyframes; |
| 112 } | 114 } |
| 113 | 115 |
| 114 bool needsCompositorKeyframesSnapshot() const { | 116 bool needsCompositorKeyframesSnapshot() const { |
| 115 return m_needsCompositorKeyframesSnapshot; | 117 return m_needsCompositorKeyframesSnapshot; |
| 116 } | 118 } |
| 117 bool snapshotNeutralCompositorKeyframes( | 119 bool snapshotNeutralCompositorKeyframes( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 182 |
| 181 private: | 183 private: |
| 182 KeyframeEffectModel(const KeyframeVector& keyframes, | 184 KeyframeEffectModel(const KeyframeVector& keyframes, |
| 183 PassRefPtr<TimingFunction> defaultKeyframeEasing) | 185 PassRefPtr<TimingFunction> defaultKeyframeEasing) |
| 184 : KeyframeEffectModelBase(std::move(defaultKeyframeEasing)) { | 186 : KeyframeEffectModelBase(std::move(defaultKeyframeEasing)) { |
| 185 m_keyframes.appendVector(keyframes); | 187 m_keyframes.appendVector(keyframes); |
| 186 } | 188 } |
| 187 | 189 |
| 188 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } | 190 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } |
| 189 virtual bool isStringKeyframeEffectModel() const { return false; } | 191 virtual bool isStringKeyframeEffectModel() const { return false; } |
| 192 virtual bool isTransitionKeyframeEffectModel() const { return false; } |
| 190 }; | 193 }; |
| 191 | 194 |
| 192 using KeyframeVector = KeyframeEffectModelBase::KeyframeVector; | 195 using KeyframeVector = KeyframeEffectModelBase::KeyframeVector; |
| 193 using PropertySpecificKeyframeVector = | 196 using PropertySpecificKeyframeVector = |
| 194 KeyframeEffectModelBase::PropertySpecificKeyframeVector; | 197 KeyframeEffectModelBase::PropertySpecificKeyframeVector; |
| 195 | 198 |
| 196 using AnimatableValueKeyframeEffectModel = | 199 using AnimatableValueKeyframeEffectModel = |
| 197 KeyframeEffectModel<AnimatableValueKeyframe>; | 200 KeyframeEffectModel<AnimatableValueKeyframe>; |
| 198 using AnimatableValueKeyframeVector = | 201 using AnimatableValueKeyframeVector = |
| 199 AnimatableValueKeyframeEffectModel::KeyframeVector; | 202 AnimatableValueKeyframeEffectModel::KeyframeVector; |
| 200 using AnimatableValuePropertySpecificKeyframeVector = | 203 using AnimatableValuePropertySpecificKeyframeVector = |
| 201 AnimatableValueKeyframeEffectModel::PropertySpecificKeyframeVector; | 204 AnimatableValueKeyframeEffectModel::PropertySpecificKeyframeVector; |
| 202 | 205 |
| 203 using StringKeyframeEffectModel = KeyframeEffectModel<StringKeyframe>; | 206 using StringKeyframeEffectModel = KeyframeEffectModel<StringKeyframe>; |
| 204 using StringKeyframeVector = StringKeyframeEffectModel::KeyframeVector; | 207 using StringKeyframeVector = StringKeyframeEffectModel::KeyframeVector; |
| 205 using StringPropertySpecificKeyframeVector = | 208 using StringPropertySpecificKeyframeVector = |
| 206 StringKeyframeEffectModel::PropertySpecificKeyframeVector; | 209 StringKeyframeEffectModel::PropertySpecificKeyframeVector; |
| 207 | 210 |
| 211 using TransitionKeyframeEffectModel = KeyframeEffectModel<TransitionKeyframe>; |
| 212 using TransitionKeyframeVector = TransitionKeyframeEffectModel::KeyframeVector; |
| 213 using TransitionPropertySpecificKeyframeVector = |
| 214 TransitionKeyframeEffectModel::PropertySpecificKeyframeVector; |
| 215 |
| 208 DEFINE_TYPE_CASTS(KeyframeEffectModelBase, | 216 DEFINE_TYPE_CASTS(KeyframeEffectModelBase, |
| 209 EffectModel, | 217 EffectModel, |
| 210 value, | 218 value, |
| 211 value->isKeyframeEffectModel(), | 219 value->isKeyframeEffectModel(), |
| 212 value.isKeyframeEffectModel()); | 220 value.isKeyframeEffectModel()); |
| 213 DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, | 221 DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, |
| 214 KeyframeEffectModelBase, | 222 KeyframeEffectModelBase, |
| 215 value, | 223 value, |
| 216 value->isAnimatableValueKeyframeEffectModel(), | 224 value->isAnimatableValueKeyframeEffectModel(), |
| 217 value.isAnimatableValueKeyframeEffectModel()); | 225 value.isAnimatableValueKeyframeEffectModel()); |
| 218 DEFINE_TYPE_CASTS(StringKeyframeEffectModel, | 226 DEFINE_TYPE_CASTS(StringKeyframeEffectModel, |
| 219 KeyframeEffectModelBase, | 227 KeyframeEffectModelBase, |
| 220 value, | 228 value, |
| 221 value->isStringKeyframeEffectModel(), | 229 value->isStringKeyframeEffectModel(), |
| 222 value.isStringKeyframeEffectModel()); | 230 value.isStringKeyframeEffectModel()); |
| 231 DEFINE_TYPE_CASTS(TransitionKeyframeEffectModel, |
| 232 KeyframeEffectModelBase, |
| 233 value, |
| 234 value->isTransitionKeyframeEffectModel(), |
| 235 value.isTransitionKeyframeEffectModel()); |
| 223 | 236 |
| 224 inline const AnimatableValueKeyframeEffectModel* | 237 inline const AnimatableValueKeyframeEffectModel* |
| 225 toAnimatableValueKeyframeEffectModel(const EffectModel* base) { | 238 toAnimatableValueKeyframeEffectModel(const EffectModel* base) { |
| 226 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)); | 239 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)); |
| 227 } | 240 } |
| 228 | 241 |
| 229 inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel( | 242 inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel( |
| 230 EffectModel* base) { | 243 EffectModel* base) { |
| 231 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)); | 244 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)); |
| 232 } | 245 } |
| 233 | 246 |
| 234 inline const StringKeyframeEffectModel* toStringKeyframeEffectModel( | 247 inline const StringKeyframeEffectModel* toStringKeyframeEffectModel( |
| 235 const EffectModel* base) { | 248 const EffectModel* base) { |
| 236 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base)); | 249 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base)); |
| 237 } | 250 } |
| 238 | 251 |
| 239 inline StringKeyframeEffectModel* toStringKeyframeEffectModel( | 252 inline StringKeyframeEffectModel* toStringKeyframeEffectModel( |
| 240 EffectModel* base) { | 253 EffectModel* base) { |
| 241 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base)); | 254 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base)); |
| 242 } | 255 } |
| 243 | 256 |
| 257 inline TransitionKeyframeEffectModel* toTransitionKeyframeEffectModel( |
| 258 EffectModel* base) { |
| 259 return toTransitionKeyframeEffectModel(toKeyframeEffectModelBase(base)); |
| 260 } |
| 261 |
| 244 template <> | 262 template <> |
| 245 inline bool KeyframeEffectModel< | 263 inline bool KeyframeEffectModel< |
| 246 AnimatableValueKeyframe>::isAnimatableValueKeyframeEffectModel() const { | 264 AnimatableValueKeyframe>::isAnimatableValueKeyframeEffectModel() const { |
| 247 return true; | 265 return true; |
| 248 } | 266 } |
| 249 | 267 |
| 250 template <> | 268 template <> |
| 251 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() | 269 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() |
| 252 const { | 270 const { |
| 253 return true; | 271 return true; |
| 254 } | 272 } |
| 255 | 273 |
| 274 template <> |
| 275 inline bool KeyframeEffectModel< |
| 276 TransitionKeyframe>::isTransitionKeyframeEffectModel() const { |
| 277 return true; |
| 278 } |
| 279 |
| 256 } // namespace blink | 280 } // namespace blink |
| 257 | 281 |
| 258 #endif // KeyframeEffectModel_h | 282 #endif // KeyframeEffectModel_h |
| OLD | NEW |