Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: Source/core/animation/KeyframeEffectModel.h

Issue 194673002: Web Animations: Refactor KeyframeEffectModel to work via an InterpolationEffect. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@interpolationWrap
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
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 "core/animation/AnimatableValue.h" 34 #include "core/animation/AnimatableValue.h"
35 #include "core/animation/AnimationEffect.h" 35 #include "core/animation/AnimationEffect.h"
36 #include "core/animation/InterpolationEffect.h"
36 #include "heap/Handle.h" 37 #include "heap/Handle.h"
37 #include "platform/animation/TimingFunction.h" 38 #include "platform/animation/TimingFunction.h"
38 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
39 #include "wtf/HashSet.h" 40 #include "wtf/HashSet.h"
40 #include "wtf/PassOwnPtr.h" 41 #include "wtf/PassOwnPtr.h"
41 #include "wtf/PassRefPtr.h" 42 #include "wtf/PassRefPtr.h"
42 #include "wtf/RefCounted.h" 43 #include "wtf/RefCounted.h"
43 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes)); 95 return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes));
95 } 96 }
96 97
97 virtual bool affects(CSSPropertyID property) OVERRIDE 98 virtual bool affects(CSSPropertyID property) OVERRIDE
98 { 99 {
99 ensureKeyframeGroups(); 100 ensureKeyframeGroups();
100 return m_keyframeGroups->contains(property); 101 return m_keyframeGroups->contains(property);
101 } 102 }
102 103
103 // AnimationEffect implementation. 104 // AnimationEffect implementation.
104 virtual PassOwnPtr<CompositableValueList> sample(int iteration, double fract ion) const OVERRIDE; 105 virtual PassOwnPtr<Vector<RefPtr<Interpolation> > > sample(int iteration, do uble fraction) const OVERRIDE;
105 106
106 // FIXME: Implement setFrames() 107 // FIXME: Implement setFrames()
107 const KeyframeVector& getFrames() const { return m_keyframes; } 108 const KeyframeVector& getFrames() const { return m_keyframes; }
108 109
109 virtual bool isKeyframeEffectModel() const OVERRIDE { return true; } 110 virtual bool isKeyframeEffectModel() const OVERRIDE { return true; }
110 111
111 PropertySet properties() const; 112 PropertySet properties() const;
112 113
113 class PropertySpecificKeyframe { 114 class PropertySpecificKeyframe {
114 public: 115 public:
115 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const AnimatableValue*, CompositeOperation); 116 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const AnimatableValue*, CompositeOperation);
116 double offset() const { return m_offset; } 117 double offset() const { return m_offset; }
117 const TimingFunction* easing() const { return m_easing.get(); } 118 TimingFunction* easing() const { return m_easing.get(); }
118 const CompositableValue* value() const { return m_value.get(); } 119 const AnimatableValue* value() const { return m_value.get(); }
119 PassOwnPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) cons t; 120 PassOwnPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) cons t;
120 private: 121 private:
121 // Used by cloneWithOffset(). 122 // Used by cloneWithOffset().
122 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, PassRefPtr<CompositableValue>); 123 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, PassRefPtr<AnimatableValue>);
123 double m_offset; 124 double m_offset;
124 RefPtr<TimingFunction> m_easing; 125 RefPtr<TimingFunction> m_easing;
125 RefPtr<CompositableValue> m_value; 126 RefPtr<AnimatableValue> m_value;
126 }; 127 };
127 128
128 class PropertySpecificKeyframeGroup { 129 class PropertySpecificKeyframeGroup {
129 public: 130 public:
130 void appendKeyframe(PassOwnPtr<PropertySpecificKeyframe>); 131 void appendKeyframe(PassOwnPtr<PropertySpecificKeyframe>);
131 PassRefPtr<CompositableValue> sample(int iteration, double offset) const ;
132 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; } 132 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; }
133 private: 133 private:
134 PropertySpecificKeyframeVector m_keyframes; 134 PropertySpecificKeyframeVector m_keyframes;
135 void removeRedundantKeyframes(); 135 void removeRedundantKeyframes();
136 void addSyntheticKeyframeIfRequired(); 136 void addSyntheticKeyframeIfRequired();
137 137
138 friend class KeyframeEffectModel; 138 friend class KeyframeEffectModel;
139 }; 139 };
140 140
141 const PropertySpecificKeyframeVector& getPropertySpecificKeyframes(CSSProper tyID id) const 141 const PropertySpecificKeyframeVector& getPropertySpecificKeyframes(CSSProper tyID id) const
142 { 142 {
143 ensureKeyframeGroups(); 143 ensureKeyframeGroups();
144 return m_keyframeGroups->get(id)->keyframes(); 144 return m_keyframeGroups->get(id)->keyframes();
145 } 145 }
146 146
147 virtual void trace(Visitor*) OVERRIDE; 147 virtual void trace(Visitor*) OVERRIDE;
148 148
149 private: 149 private:
150 KeyframeEffectModel(const KeyframeVector& keyframes); 150 KeyframeEffectModel(const KeyframeVector& keyframes);
151 151
152 static KeyframeVector normalizedKeyframes(const KeyframeVector& keyframes); 152 static KeyframeVector normalizedKeyframes(const KeyframeVector& keyframes);
153 153
154 // Lazily computes the groups of property-specific keyframes. 154 // Lazily computes the groups of property-specific keyframes.
155 void ensureKeyframeGroups() const; 155 void ensureKeyframeGroups() const;
156 void ensureInterpolationEffect() const;
156 157
157 KeyframeVector m_keyframes; 158 KeyframeVector m_keyframes;
158 // The spec describes filtering the normalized keyframes at sampling time 159 // The spec describes filtering the normalized keyframes at sampling time
159 // to get the 'property-specific keyframes'. For efficiency, we cache the 160 // to get the 'property-specific keyframes'. For efficiency, we cache the
160 // property-specific lists. 161 // property-specific lists.
161 typedef HashMap<CSSPropertyID, OwnPtr<PropertySpecificKeyframeGroup> > Keyfr ameGroupMap; 162 typedef HashMap<CSSPropertyID, OwnPtr<PropertySpecificKeyframeGroup> > Keyfr ameGroupMap;
162 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups; 163 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups;
163 164
165 mutable RefPtr<InterpolationEffect> m_interpolationEffect;
166
164 friend class KeyframeEffectModelTest; 167 friend class KeyframeEffectModelTest;
165 }; 168 };
166 169
167 DEFINE_TYPE_CASTS(KeyframeEffectModel, AnimationEffect, value, value->isKeyframe EffectModel(), value.isKeyframeEffectModel()); 170 DEFINE_TYPE_CASTS(KeyframeEffectModel, AnimationEffect, value, value->isKeyframe EffectModel(), value.isKeyframeEffectModel());
168 171
169 } // namespace WebCore 172 } // namespace WebCore
170 173
171 #endif // KeyframeEffectModel_h 174 #endif // KeyframeEffectModel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698