OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_GFX_INTERPOLATED_TRANSFORM_H_ | 5 #ifndef UI_GFX_INTERPOLATED_TRANSFORM_H_ |
6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_ | 6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Represents an animated rotation. | 84 // Represents an animated rotation. |
85 // | 85 // |
86 /////////////////////////////////////////////////////////////////////////////// | 86 /////////////////////////////////////////////////////////////////////////////// |
87 class GFX_EXPORT InterpolatedRotation : public InterpolatedTransform { | 87 class GFX_EXPORT InterpolatedRotation : public InterpolatedTransform { |
88 public: | 88 public: |
89 InterpolatedRotation(float start_degrees, float end_degrees); | 89 InterpolatedRotation(float start_degrees, float end_degrees); |
90 InterpolatedRotation(float start_degrees, | 90 InterpolatedRotation(float start_degrees, |
91 float end_degrees, | 91 float end_degrees, |
92 float start_time, | 92 float start_time, |
93 float end_time); | 93 float end_time); |
94 virtual ~InterpolatedRotation(); | 94 ~InterpolatedRotation() override; |
95 | 95 |
96 protected: | 96 protected: |
97 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 97 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
98 | 98 |
99 private: | 99 private: |
100 const float start_degrees_; | 100 const float start_degrees_; |
101 const float end_degrees_; | 101 const float end_degrees_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation); | 103 DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation); |
104 }; | 104 }; |
105 | 105 |
106 /////////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////////// |
107 // class InterpolatedAxisAngleRotation | 107 // class InterpolatedAxisAngleRotation |
108 // | 108 // |
109 // Represents an animated rotation. | 109 // Represents an animated rotation. |
110 // | 110 // |
111 /////////////////////////////////////////////////////////////////////////////// | 111 /////////////////////////////////////////////////////////////////////////////// |
112 class GFX_EXPORT InterpolatedAxisAngleRotation : public InterpolatedTransform { | 112 class GFX_EXPORT InterpolatedAxisAngleRotation : public InterpolatedTransform { |
113 public: | 113 public: |
114 InterpolatedAxisAngleRotation(const gfx::Vector3dF& axis, | 114 InterpolatedAxisAngleRotation(const gfx::Vector3dF& axis, |
115 float start_degrees, | 115 float start_degrees, |
116 float end_degrees); | 116 float end_degrees); |
117 InterpolatedAxisAngleRotation(const gfx::Vector3dF& axis, | 117 InterpolatedAxisAngleRotation(const gfx::Vector3dF& axis, |
118 float start_degrees, | 118 float start_degrees, |
119 float end_degrees, | 119 float end_degrees, |
120 float start_time, | 120 float start_time, |
121 float end_time); | 121 float end_time); |
122 virtual ~InterpolatedAxisAngleRotation(); | 122 ~InterpolatedAxisAngleRotation() override; |
123 | 123 |
124 protected: | 124 protected: |
125 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 125 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
126 | 126 |
127 private: | 127 private: |
128 gfx::Vector3dF axis_; | 128 gfx::Vector3dF axis_; |
129 const float start_degrees_; | 129 const float start_degrees_; |
130 const float end_degrees_; | 130 const float end_degrees_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(InterpolatedAxisAngleRotation); | 132 DISALLOW_COPY_AND_ASSIGN(InterpolatedAxisAngleRotation); |
133 }; | 133 }; |
134 | 134 |
135 /////////////////////////////////////////////////////////////////////////////// | 135 /////////////////////////////////////////////////////////////////////////////// |
136 // class InterpolatedScale | 136 // class InterpolatedScale |
137 // | 137 // |
138 // Represents an animated scale. | 138 // Represents an animated scale. |
139 // | 139 // |
140 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
141 class GFX_EXPORT InterpolatedScale : public InterpolatedTransform { | 141 class GFX_EXPORT InterpolatedScale : public InterpolatedTransform { |
142 public: | 142 public: |
143 InterpolatedScale(float start_scale, float end_scale); | 143 InterpolatedScale(float start_scale, float end_scale); |
144 InterpolatedScale(float start_scale, float end_scale, | 144 InterpolatedScale(float start_scale, float end_scale, |
145 float start_time, float end_time); | 145 float start_time, float end_time); |
146 InterpolatedScale(const gfx::Point3F& start_scale, | 146 InterpolatedScale(const gfx::Point3F& start_scale, |
147 const gfx::Point3F& end_scale); | 147 const gfx::Point3F& end_scale); |
148 InterpolatedScale(const gfx::Point3F& start_scale, | 148 InterpolatedScale(const gfx::Point3F& start_scale, |
149 const gfx::Point3F& end_scale, | 149 const gfx::Point3F& end_scale, |
150 float start_time, | 150 float start_time, |
151 float end_time); | 151 float end_time); |
152 virtual ~InterpolatedScale(); | 152 ~InterpolatedScale() override; |
153 | 153 |
154 protected: | 154 protected: |
155 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 155 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
156 | 156 |
157 private: | 157 private: |
158 const gfx::Point3F start_scale_; | 158 const gfx::Point3F start_scale_; |
159 const gfx::Point3F end_scale_; | 159 const gfx::Point3F end_scale_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(InterpolatedScale); | 161 DISALLOW_COPY_AND_ASSIGN(InterpolatedScale); |
162 }; | 162 }; |
163 | 163 |
164 class GFX_EXPORT InterpolatedTranslation : public InterpolatedTransform { | 164 class GFX_EXPORT InterpolatedTranslation : public InterpolatedTransform { |
165 public: | 165 public: |
166 InterpolatedTranslation(const gfx::Point& start_pos, | 166 InterpolatedTranslation(const gfx::Point& start_pos, |
167 const gfx::Point& end_pos); | 167 const gfx::Point& end_pos); |
168 InterpolatedTranslation(const gfx::Point& start_pos, | 168 InterpolatedTranslation(const gfx::Point& start_pos, |
169 const gfx::Point& end_pos, | 169 const gfx::Point& end_pos, |
170 float start_time, | 170 float start_time, |
171 float end_time); | 171 float end_time); |
172 InterpolatedTranslation(const gfx::Point3F& start_pos, | 172 InterpolatedTranslation(const gfx::Point3F& start_pos, |
173 const gfx::Point3F& end_pos); | 173 const gfx::Point3F& end_pos); |
174 InterpolatedTranslation(const gfx::Point3F& start_pos, | 174 InterpolatedTranslation(const gfx::Point3F& start_pos, |
175 const gfx::Point3F& end_pos, | 175 const gfx::Point3F& end_pos, |
176 float start_time, | 176 float start_time, |
177 float end_time); | 177 float end_time); |
178 virtual ~InterpolatedTranslation(); | 178 ~InterpolatedTranslation() override; |
179 | 179 |
180 protected: | 180 protected: |
181 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 181 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
182 | 182 |
183 private: | 183 private: |
184 const gfx::Point3F start_pos_; | 184 const gfx::Point3F start_pos_; |
185 const gfx::Point3F end_pos_; | 185 const gfx::Point3F end_pos_; |
186 | 186 |
187 DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation); | 187 DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation); |
188 }; | 188 }; |
189 | 189 |
190 /////////////////////////////////////////////////////////////////////////////// | 190 /////////////////////////////////////////////////////////////////////////////// |
191 // class InterpolatedConstantTransform | 191 // class InterpolatedConstantTransform |
192 // | 192 // |
193 // Represents a transform that is constant over time. This is only useful when | 193 // Represents a transform that is constant over time. This is only useful when |
194 // composed with other interpolated transforms. | 194 // composed with other interpolated transforms. |
195 // | 195 // |
196 // See InterpolatedTransformAboutPivot for an example of its usage. | 196 // See InterpolatedTransformAboutPivot for an example of its usage. |
197 // | 197 // |
198 /////////////////////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////////////////////// |
199 class GFX_EXPORT InterpolatedConstantTransform : public InterpolatedTransform { | 199 class GFX_EXPORT InterpolatedConstantTransform : public InterpolatedTransform { |
200 public: | 200 public: |
201 explicit InterpolatedConstantTransform(const gfx::Transform& transform); | 201 explicit InterpolatedConstantTransform(const gfx::Transform& transform); |
202 virtual ~InterpolatedConstantTransform(); | 202 ~InterpolatedConstantTransform() override; |
203 | 203 |
204 protected: | 204 protected: |
205 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 205 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
206 | 206 |
207 private: | 207 private: |
208 const gfx::Transform transform_; | 208 const gfx::Transform transform_; |
209 | 209 |
210 DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform); | 210 DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform); |
211 }; | 211 }; |
212 | 212 |
213 /////////////////////////////////////////////////////////////////////////////// | 213 /////////////////////////////////////////////////////////////////////////////// |
214 // class InterpolatedTransformAboutPivot | 214 // class InterpolatedTransformAboutPivot |
215 // | 215 // |
216 // Represents an animated transform with a transformed origin. Essentially, | 216 // Represents an animated transform with a transformed origin. Essentially, |
217 // at each time, t, the interpolated transform is created by composing | 217 // at each time, t, the interpolated transform is created by composing |
218 // P * T * P^-1 where P is a constant transform to the new origin. | 218 // P * T * P^-1 where P is a constant transform to the new origin. |
219 // | 219 // |
220 /////////////////////////////////////////////////////////////////////////////// | 220 /////////////////////////////////////////////////////////////////////////////// |
221 class GFX_EXPORT InterpolatedTransformAboutPivot | 221 class GFX_EXPORT InterpolatedTransformAboutPivot |
222 : public InterpolatedTransform { | 222 : public InterpolatedTransform { |
223 public: | 223 public: |
224 // Takes ownership of the passed transform. | 224 // Takes ownership of the passed transform. |
225 InterpolatedTransformAboutPivot(const gfx::Point& pivot, | 225 InterpolatedTransformAboutPivot(const gfx::Point& pivot, |
226 InterpolatedTransform* transform); | 226 InterpolatedTransform* transform); |
227 | 227 |
228 // Takes ownership of the passed transform. | 228 // Takes ownership of the passed transform. |
229 InterpolatedTransformAboutPivot(const gfx::Point& pivot, | 229 InterpolatedTransformAboutPivot(const gfx::Point& pivot, |
230 InterpolatedTransform* transform, | 230 InterpolatedTransform* transform, |
231 float start_time, | 231 float start_time, |
232 float end_time); | 232 float end_time); |
233 virtual ~InterpolatedTransformAboutPivot(); | 233 ~InterpolatedTransformAboutPivot() override; |
234 | 234 |
235 protected: | 235 protected: |
236 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 236 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
237 | 237 |
238 private: | 238 private: |
239 void Init(const gfx::Point& pivot, InterpolatedTransform* transform); | 239 void Init(const gfx::Point& pivot, InterpolatedTransform* transform); |
240 | 240 |
241 scoped_ptr<InterpolatedTransform> transform_; | 241 scoped_ptr<InterpolatedTransform> transform_; |
242 | 242 |
243 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); | 243 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); |
244 }; | 244 }; |
245 | 245 |
246 class GFX_EXPORT InterpolatedMatrixTransform : public InterpolatedTransform { | 246 class GFX_EXPORT InterpolatedMatrixTransform : public InterpolatedTransform { |
247 public: | 247 public: |
248 InterpolatedMatrixTransform(const gfx::Transform& start_transform, | 248 InterpolatedMatrixTransform(const gfx::Transform& start_transform, |
249 const gfx::Transform& end_transform); | 249 const gfx::Transform& end_transform); |
250 | 250 |
251 InterpolatedMatrixTransform(const gfx::Transform& start_transform, | 251 InterpolatedMatrixTransform(const gfx::Transform& start_transform, |
252 const gfx::Transform& end_transform, | 252 const gfx::Transform& end_transform, |
253 float start_time, | 253 float start_time, |
254 float end_time); | 254 float end_time); |
255 | 255 |
256 virtual ~InterpolatedMatrixTransform(); | 256 ~InterpolatedMatrixTransform() override; |
257 | 257 |
258 protected: | 258 protected: |
259 virtual gfx::Transform InterpolateButDoNotCompose(float t) const override; | 259 gfx::Transform InterpolateButDoNotCompose(float t) const override; |
260 | 260 |
261 private: | 261 private: |
262 void Init(const gfx::Transform& start_transform, | 262 void Init(const gfx::Transform& start_transform, |
263 const gfx::Transform& end_transform); | 263 const gfx::Transform& end_transform); |
264 | 264 |
265 gfx::DecomposedTransform start_decomp_; | 265 gfx::DecomposedTransform start_decomp_; |
266 gfx::DecomposedTransform end_decomp_; | 266 gfx::DecomposedTransform end_decomp_; |
267 }; | 267 }; |
268 | 268 |
269 } // namespace ui | 269 } // namespace ui |
270 | 270 |
271 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ | 271 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ |
OLD | NEW |