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

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

Issue 142523005: Web Animations: Define easing for each keyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Rename s_accuracy to accuracyForKeyframeEasing Created 6 years, 10 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
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/KeyframeEffectModel.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/animation/TimingFunction.h"
36 #include "wtf/HashMap.h" 37 #include "wtf/HashMap.h"
37 #include "wtf/HashSet.h" 38 #include "wtf/HashSet.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
39 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
41 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 typedef HashSet<CSSPropertyID> PropertySet; 46 typedef HashSet<CSSPropertyID> PropertySet;
46 47
47 class KeyframeEffectModelTest; 48 class KeyframeEffectModelTest;
48 49
49 // Represents the keyframes set through the API. 50 // Represents the keyframes set through the API.
50 class Keyframe : public RefCounted<Keyframe> { 51 class Keyframe : public RefCounted<Keyframe> {
51 public: 52 public:
52 static PassRefPtr<Keyframe> create() 53 static PassRefPtr<Keyframe> create()
53 { 54 {
54 return adoptRef(new Keyframe); 55 return adoptRef(new Keyframe);
55 } 56 }
56 static bool compareOffsets(const RefPtr<Keyframe>& a, const RefPtr<Keyframe> & b) 57 static bool compareOffsets(const RefPtr<Keyframe>& a, const RefPtr<Keyframe> & b)
57 { 58 {
58 return a->offset() < b->offset(); 59 return a->offset() < b->offset();
59 } 60 }
60 void setOffset(double offset) { m_offset = offset; } 61 void setOffset(double offset) { m_offset = offset; }
61 double offset() const { return m_offset; } 62 double offset() const { return m_offset; }
62 void setComposite(AnimationEffect::CompositeOperation composite) { m_composi te = composite; } 63 void setComposite(AnimationEffect::CompositeOperation composite) { m_composi te = composite; }
63 AnimationEffect::CompositeOperation composite() const { return m_composite; } 64 AnimationEffect::CompositeOperation composite() const { return m_composite; }
65 void setEasing(PassRefPtr<TimingFunction> easing) { m_easing = easing; }
66 TimingFunction* easing() const { return m_easing.get(); }
64 void setPropertyValue(CSSPropertyID, const AnimatableValue*); 67 void setPropertyValue(CSSPropertyID, const AnimatableValue*);
65 void clearPropertyValue(CSSPropertyID); 68 void clearPropertyValue(CSSPropertyID);
66 const AnimatableValue* propertyValue(CSSPropertyID) const; 69 const AnimatableValue* propertyValue(CSSPropertyID) const;
67 PropertySet properties() const; 70 PropertySet properties() const;
68 PassRefPtr<Keyframe> clone() const { return adoptRef(new Keyframe(*this)); } 71 PassRefPtr<Keyframe> clone() const { return adoptRef(new Keyframe(*this)); }
69 PassRefPtr<Keyframe> cloneWithOffset(double offset) const; 72 PassRefPtr<Keyframe> cloneWithOffset(double offset) const;
70 private: 73 private:
71 Keyframe(); 74 Keyframe();
72 Keyframe(const Keyframe&); 75 Keyframe(const Keyframe&);
73 double m_offset; 76 double m_offset;
74 AnimationEffect::CompositeOperation m_composite; 77 AnimationEffect::CompositeOperation m_composite;
78 RefPtr<TimingFunction> m_easing;
75 typedef HashMap<CSSPropertyID, RefPtr<AnimatableValue> > PropertyValueMap; 79 typedef HashMap<CSSPropertyID, RefPtr<AnimatableValue> > PropertyValueMap;
76 PropertyValueMap m_propertyValues; 80 PropertyValueMap m_propertyValues;
77 }; 81 };
78 82
79 class KeyframeEffectModel FINAL : public AnimationEffect { 83 class KeyframeEffectModel FINAL : public AnimationEffect {
80 public: 84 public:
81 class PropertySpecificKeyframe; 85 class PropertySpecificKeyframe;
82 typedef Vector<RefPtr<Keyframe> > KeyframeVector; 86 typedef Vector<RefPtr<Keyframe> > KeyframeVector;
83 typedef Vector<OwnPtr<PropertySpecificKeyframe> > PropertySpecificKeyframeVe ctor; 87 typedef Vector<OwnPtr<PropertySpecificKeyframe> > PropertySpecificKeyframeVe ctor;
84 // FIXME: Implement accumulation. 88 // FIXME: Implement accumulation.
(...skipping 13 matching lines...) Expand all
98 102
99 // FIXME: Implement setFrames() 103 // FIXME: Implement setFrames()
100 const KeyframeVector& getFrames() const { return m_keyframes; } 104 const KeyframeVector& getFrames() const { return m_keyframes; }
101 105
102 virtual bool isKeyframeEffectModel() const OVERRIDE { return true; } 106 virtual bool isKeyframeEffectModel() const OVERRIDE { return true; }
103 107
104 PropertySet properties() const; 108 PropertySet properties() const;
105 109
106 class PropertySpecificKeyframe { 110 class PropertySpecificKeyframe {
107 public: 111 public:
108 PropertySpecificKeyframe(double offset, const AnimatableValue*, Composit eOperation); 112 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const AnimatableValue*, CompositeOperation);
109 double offset() const { return m_offset; } 113 double offset() const { return m_offset; }
114 const TimingFunction* easing() const { return m_easing.get(); }
110 const CompositableValue* value() const { return m_value.get(); } 115 const CompositableValue* value() const { return m_value.get(); }
111 PassOwnPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) cons t; 116 PassOwnPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) cons t;
112 private: 117 private:
113 // Used by cloneWithOffset(). 118 // Used by cloneWithOffset().
114 PropertySpecificKeyframe(double offset, PassRefPtr<CompositableValue>); 119 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, PassRefPtr<CompositableValue>);
115 double m_offset; 120 double m_offset;
121 RefPtr<TimingFunction> m_easing;
116 RefPtr<CompositableValue> m_value; 122 RefPtr<CompositableValue> m_value;
117 }; 123 };
118 124
119 class PropertySpecificKeyframeGroup { 125 class PropertySpecificKeyframeGroup {
120 public: 126 public:
121 void appendKeyframe(PassOwnPtr<PropertySpecificKeyframe>); 127 void appendKeyframe(PassOwnPtr<PropertySpecificKeyframe>);
122 PassRefPtr<CompositableValue> sample(int iteration, double offset) const ; 128 PassRefPtr<CompositableValue> sample(int iteration, double offset) const ;
123 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; } 129 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; }
124 private: 130 private:
125 PropertySpecificKeyframeVector m_keyframes; 131 PropertySpecificKeyframeVector m_keyframes;
(...skipping 25 matching lines...) Expand all
151 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups; 157 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups;
152 158
153 friend class KeyframeEffectModelTest; 159 friend class KeyframeEffectModelTest;
154 }; 160 };
155 161
156 DEFINE_TYPE_CASTS(KeyframeEffectModel, AnimationEffect, value, value->isKeyframe EffectModel(), value.isKeyframeEffectModel()); 162 DEFINE_TYPE_CASTS(KeyframeEffectModel, AnimationEffect, value, value->isKeyframe EffectModel(), value.isKeyframeEffectModel());
157 163
158 } // namespace WebCore 164 } // namespace WebCore
159 165
160 #endif // KeyframeEffectModel_h 166 #endif // KeyframeEffectModel_h
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/KeyframeEffectModel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698