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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 3 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 // 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 InterpolableValue_h 5 #ifndef InterpolableValue_h
6 #define InterpolableValue_h 6 #define InterpolableValue_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/animation/animatable/AnimatableValue.h" 9 #include "core/animation/animatable/AnimatableValue.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "wtf/OwnPtr.h" 11 #include "wtf/OwnPtr.h"
12 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class CORE_EXPORT InterpolableValue : public NoBaseWillBeGarbageCollected<Interp olableValue> { 17 class CORE_EXPORT InterpolableValue : public GarbageCollected<InterpolableValue> {
18 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
19 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InterpolableValue);
20 public: 18 public:
21 virtual bool isNumber() const { return false; } 19 virtual bool isNumber() const { return false; }
22 virtual bool isBool() const { return false; } 20 virtual bool isBool() const { return false; }
23 virtual bool isList() const { return false; } 21 virtual bool isList() const { return false; }
24 virtual bool isAnimatableValue() const { return false; } 22 virtual bool isAnimatableValue() const { return false; }
25 23
26 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; 24 virtual InterpolableValue* clone() const = 0;
27 25
28 DEFINE_INLINE_VIRTUAL_TRACE() { } 26 DEFINE_INLINE_VIRTUAL_TRACE() { }
29 27
30 private: 28 private:
31 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0; 29 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0;
32 virtual void scaleAndAdd(double scale, const InterpolableValue& other) = 0; 30 virtual void scaleAndAdd(double scale, const InterpolableValue& other) = 0;
33 31
34 friend class Interpolation; 32 friend class Interpolation;
35 friend class PairwisePrimitiveInterpolation; 33 friend class PairwisePrimitiveInterpolation;
36 friend class InvalidatableStyleInterpolation; 34 friend class InvalidatableStyleInterpolation;
37 35
38 // Keep interpolate private, but allow calls within the hierarchy without 36 // Keep interpolate private, but allow calls within the hierarchy without
39 // knowledge of type. 37 // knowledge of type.
40 friend class DeferredLegacyStyleInterpolation; 38 friend class DeferredLegacyStyleInterpolation;
41 friend class InterpolableNumber; 39 friend class InterpolableNumber;
42 friend class InterpolableBool; 40 friend class InterpolableBool;
43 friend class InterpolableList; 41 friend class InterpolableList;
44 42
45 friend class AnimationInterpolableValueTest; 43 friend class AnimationInterpolableValueTest;
46 }; 44 };
47 45
48 class CORE_EXPORT InterpolableNumber final : public InterpolableValue { 46 class CORE_EXPORT InterpolableNumber final : public InterpolableValue {
49 public: 47 public:
50 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) 48 static InterpolableNumber* create(double value)
51 { 49 {
52 return adoptPtrWillBeNoop(new InterpolableNumber(value)); 50 return new InterpolableNumber(value);
53 } 51 }
54 52
55 bool isNumber() const final { return true; } 53 bool isNumber() const final { return true; }
56 double value() const { return m_value; } 54 double value() const { return m_value; }
57 PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const final { return creat e(m_value); } 55 InterpolableValue* clone() const final { return create(m_value); }
58 56
59 private: 57 private:
60 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final; 58 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final;
61 void scaleAndAdd(double scale, const InterpolableValue& other) final; 59 void scaleAndAdd(double scale, const InterpolableValue& other) final;
62 double m_value; 60 double m_value;
63 61
64 explicit InterpolableNumber(double value) 62 explicit InterpolableNumber(double value)
65 : m_value(value) 63 : m_value(value)
66 { 64 {
67 } 65 }
68 66
69 }; 67 };
70 68
71 class CORE_EXPORT InterpolableBool final : public InterpolableValue { 69 class CORE_EXPORT InterpolableBool final : public InterpolableValue {
72 public: 70 public:
73 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) 71 static InterpolableBool* create(bool value)
74 { 72 {
75 return adoptPtrWillBeNoop(new InterpolableBool(value)); 73 return new InterpolableBool(value);
76 } 74 }
77 75
78 bool isBool() const final { return true; } 76 bool isBool() const final { return true; }
79 bool value() const { return m_value; } 77 bool value() const { return m_value; }
80 PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const final { return creat e(m_value); } 78 InterpolableValue* clone() const final { return create(m_value); }
81 79
82 private: 80 private:
83 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final; 81 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final;
84 void scaleAndAdd(double scale, const InterpolableValue& other) final { ASSER T_NOT_REACHED(); } 82 void scaleAndAdd(double scale, const InterpolableValue& other) final { ASSER T_NOT_REACHED(); }
85 bool m_value; 83 bool m_value;
86 84
87 explicit InterpolableBool(bool value) 85 explicit InterpolableBool(bool value)
88 : m_value(value) 86 : m_value(value)
89 { 87 {
90 } 88 }
91 89
92 }; 90 };
93 91
94 class CORE_EXPORT InterpolableList : public InterpolableValue { 92 class CORE_EXPORT InterpolableList : public InterpolableValue {
95 public: 93 public:
96 // Explicitly delete operator= because MSVC automatically generate 94 // Explicitly delete operator= because MSVC automatically generate
97 // copy constructors and operator= for dll-exported classes. 95 // copy constructors and operator= for dll-exported classes.
98 // Since InterpolableList is not copyable, automatically generated 96 // Since InterpolableList is not copyable, automatically generated
99 // operator= causes MSVC compiler error. 97 // operator= causes MSVC compiler error.
100 // However, we cannot use WTF_MAKE_NONCOPYABLE because InterpolableList 98 // However, we cannot use WTF_MAKE_NONCOPYABLE because InterpolableList
101 // has its own copy constructor. So just delete operator= here. 99 // has its own copy constructor. So just delete operator= here.
102 InterpolableList& operator=(const InterpolableList&) = delete; 100 InterpolableList& operator=(const InterpolableList&) = delete;
103 101
104 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other) 102 static InterpolableList* create(const InterpolableList &other)
105 { 103 {
106 return adoptPtrWillBeNoop(new InterpolableList(other)); 104 return new InterpolableList(other);
107 } 105 }
108 106
109 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size) 107 static InterpolableList* create(size_t size)
110 { 108 {
111 return adoptPtrWillBeNoop(new InterpolableList(size)); 109 return new InterpolableList(size);
112 } 110 }
113 111
114 bool isList() const final { return true; } 112 bool isList() const final { return true; }
115 void set(size_t position, PassOwnPtrWillBeRawPtr<InterpolableValue> value) 113 void set(size_t position, InterpolableValue* value)
116 { 114 {
117 ASSERT(position < m_size); 115 ASSERT(position < m_size);
118 m_values[position] = value; 116 m_values[position] = value;
119 } 117 }
120 const InterpolableValue* get(size_t position) const 118 const InterpolableValue* get(size_t position) const
121 { 119 {
122 ASSERT(position < m_size); 120 ASSERT(position < m_size);
123 return m_values[position].get(); 121 return m_values[position];
124 } 122 }
125 InterpolableValue* get(size_t position) 123 InterpolableValue* get(size_t position)
126 { 124 {
127 ASSERT(position < m_size); 125 ASSERT(position < m_size);
128 return m_values[position].get(); 126 return m_values[position].get();
129 } 127 }
130 size_t length() const { return m_size; } 128 size_t length() const { return m_size; }
131 PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const final { return creat e(*this); } 129 InterpolableValue* clone() const final { return create(*this); }
132 130
133 DECLARE_VIRTUAL_TRACE(); 131 DECLARE_VIRTUAL_TRACE();
134 132
135 private: 133 private:
136 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final; 134 void interpolate(const InterpolableValue& to, const double progress, Interpo lableValue& result) const final;
137 void scaleAndAdd(double scale, const InterpolableValue& other) final; 135 void scaleAndAdd(double scale, const InterpolableValue& other) final;
138 explicit InterpolableList(size_t size) 136 explicit InterpolableList(size_t size)
139 : m_size(size) 137 : m_size(size)
140 , m_values(m_size) 138 , m_values(m_size)
141 { 139 {
142 } 140 }
143 141
144 InterpolableList(const InterpolableList& other) 142 InterpolableList(const InterpolableList& other)
145 : m_size(other.m_size) 143 : m_size(other.m_size)
146 , m_values(m_size) 144 , m_values(m_size)
147 { 145 {
148 for (size_t i = 0; i < m_size; i++) 146 for (size_t i = 0; i < m_size; i++)
149 set(i, other.m_values[i]->clone()); 147 set(i, other.m_values[i]->clone());
150 } 148 }
151 149
152 size_t m_size; 150 size_t m_size;
153 WillBeHeapVector<OwnPtrWillBeMember<InterpolableValue>> m_values; 151 HeapVector<Member<InterpolableValue>> m_values;
154 }; 152 };
155 153
156 // FIXME: Remove this when we can. 154 // FIXME: Remove this when we can.
157 class InterpolableAnimatableValue : public InterpolableValue { 155 class InterpolableAnimatableValue : public InterpolableValue {
158 public: 156 public:
159 static PassOwnPtrWillBeRawPtr<InterpolableAnimatableValue> create(PassRefPtr WillBeRawPtr<AnimatableValue> value) 157 static InterpolableAnimatableValue* create(AnimatableValue* value)
160 { 158 {
161 return adoptPtrWillBeNoop(new InterpolableAnimatableValue(value)); 159 return new InterpolableAnimatableValue(value);
162 } 160 }
163 161
164 bool isAnimatableValue() const final { return true; } 162 bool isAnimatableValue() const final { return true; }
165 AnimatableValue* value() const { return m_value.get(); } 163 AnimatableValue* value() const { return m_value; }
166 PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const final { return creat e(m_value); } 164 InterpolableValue* clone() const final { return create(m_value); }
167 165
168 DECLARE_VIRTUAL_TRACE(); 166 DECLARE_VIRTUAL_TRACE();
169 167
170 private: 168 private:
171 void interpolate(const InterpolableValue &to, const double progress, Interpo lableValue& result) const final; 169 void interpolate(const InterpolableValue &to, const double progress, Interpo lableValue& result) const final;
172 void scaleAndAdd(double scale, const InterpolableValue& other) final { ASSER T_NOT_REACHED(); } 170 void scaleAndAdd(double scale, const InterpolableValue& other) final { ASSER T_NOT_REACHED(); }
173 RefPtrWillBeMember<AnimatableValue> m_value;
174 171
175 InterpolableAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) 172 InterpolableAnimatableValue(AnimatableValue* value)
176 : m_value(value) 173 : m_value(value)
177 { 174 {
178 } 175 }
176
177 Member<AnimatableValue> m_value;
179 }; 178 };
180 179
181 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber()); 180 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber());
182 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool()); 181 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool());
183 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList()); 182 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList());
184 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue()); 183 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue());
185 184
186 } 185 }
187 186
188 #endif 187 #endif
OLDNEW
« no previous file with comments | « Source/core/animation/IntegerSVGInterpolation.h ('k') | Source/core/animation/InterpolableValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698