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 16 matching lines...) Expand all Loading... |
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 EffectModel_h | 31 #ifndef EffectModel_h |
32 #define EffectModel_h | 32 #define EffectModel_h |
33 | 33 |
34 #include "bindings/core/v8/ScriptWrappable.h" | 34 #include "bindings/core/v8/ScriptWrappable.h" |
35 #include "core/CSSPropertyNames.h" | 35 #include "core/CSSPropertyNames.h" |
36 #include "core/CoreExport.h" | 36 #include "core/CoreExport.h" |
| 37 #include "core/animation/AnimationEffect.h" |
37 #include "core/animation/PropertyHandle.h" | 38 #include "core/animation/PropertyHandle.h" |
38 #include "platform/heap/Handle.h" | 39 #include "platform/heap/Handle.h" |
39 #include "wtf/HashMap.h" | 40 #include "wtf/HashMap.h" |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class Interpolation; | 44 class Interpolation; |
44 | 45 |
45 // Time independent representation of an Animation's content. | 46 // Time independent representation of an Animation's content. |
46 // Can be sampled for the active pairs of Keyframes (represented by Interpolatio
ns) at a given time fraction. | 47 // Can be sampled for the active pairs of Keyframes (represented by Interpolatio
ns) at a given time fraction. |
47 class CORE_EXPORT EffectModel : public GarbageCollectedFinalized<EffectModel>, p
ublic ScriptWrappable { | 48 class CORE_EXPORT EffectModel : public GarbageCollectedFinalized<EffectModel>, p
ublic ScriptWrappable { |
48 DEFINE_WRAPPERTYPEINFO(); | 49 DEFINE_WRAPPERTYPEINFO(); |
49 public: | 50 public: |
50 enum CompositeOperation { | 51 enum CompositeOperation { |
51 CompositeReplace, | 52 CompositeReplace, |
52 CompositeAdd, | 53 CompositeAdd, |
53 }; | 54 }; |
54 | 55 |
55 EffectModel() { } | |
56 virtual ~EffectModel() { } | 56 virtual ~EffectModel() { } |
57 virtual bool sample(int iteration, double fraction, double iterationDuration
, Vector<RefPtr<Interpolation>>&) const = 0; | |
58 | 57 |
59 virtual bool affects(PropertyHandle) const { return false; } | 58 bool sample(int iteration, double fraction, double iterationDuration, Vector
<RefPtr<Interpolation>>& result) const |
60 virtual bool isTransformRelatedEffect() const { return false; } | 59 { |
| 60 DCHECK_GE(iteration, 0); |
| 61 DCHECK(!isNull(fraction)); |
| 62 bool changed = iteration != m_lastIteration || fraction != m_lastFractio
n || iterationDuration != m_lastIterationDuration; |
| 63 m_lastIteration = iteration; |
| 64 m_lastFraction = fraction; |
| 65 m_lastIterationDuration = iterationDuration; |
| 66 sampleImpl(iteration, fraction, iterationDuration, result); |
| 67 return changed; |
| 68 } |
| 69 |
| 70 virtual bool affects(PropertyHandle) const = 0; |
| 71 bool isTransformRelatedEffect() const |
| 72 { |
| 73 return affects(PropertyHandle(CSSPropertyTransform)) |
| 74 || affects(PropertyHandle(CSSPropertyRotate)) |
| 75 || affects(PropertyHandle(CSSPropertyScale)) |
| 76 || affects(PropertyHandle(CSSPropertyTranslate)); |
| 77 } |
| 78 |
61 virtual bool isKeyframeEffectModel() const { return false; } | 79 virtual bool isKeyframeEffectModel() const { return false; } |
| 80 virtual bool isTransitionEffectModel() const { return false; } |
62 | 81 |
63 DEFINE_INLINE_VIRTUAL_TRACE() { } | 82 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 83 |
| 84 protected: |
| 85 EffectModel() |
| 86 : m_lastIteration(0) |
| 87 , m_lastFraction(nullValue()) |
| 88 , m_lastIterationDuration(0) |
| 89 { } |
| 90 |
| 91 virtual void sampleImpl(int iteration, double fraction, double iterationDura
tion, Vector<RefPtr<Interpolation>>&) const = 0; |
| 92 |
| 93 void clearLastFraction() const { m_lastFraction = nullValue(); } |
| 94 |
| 95 private: |
| 96 mutable int m_lastIteration; |
| 97 mutable double m_lastFraction; |
| 98 mutable double m_lastIterationDuration; |
64 }; | 99 }; |
65 | 100 |
66 } // namespace blink | 101 } // namespace blink |
67 | 102 |
68 #endif // EffectModel_h | 103 #endif // EffectModel_h |
OLD | NEW |