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 #include "ui/gfx/interpolated_transform.h" | 5 #include "ui/gfx/interpolated_transform.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #ifndef M_PI | 9 #ifndef M_PI |
10 #define M_PI 3.14159265358979323846 | 10 #define M_PI 3.14159265358979323846 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 start_scale_(start_scale), | 223 start_scale_(start_scale), |
224 end_scale_(end_scale) { | 224 end_scale_(end_scale) { |
225 } | 225 } |
226 | 226 |
227 InterpolatedScale::~InterpolatedScale() {} | 227 InterpolatedScale::~InterpolatedScale() {} |
228 | 228 |
229 gfx::Transform InterpolatedScale::InterpolateButDoNotCompose(float t) const { | 229 gfx::Transform InterpolatedScale::InterpolateButDoNotCompose(float t) const { |
230 gfx::Transform result; | 230 gfx::Transform result; |
231 float scale_x = ValueBetween(t, start_scale_.x(), end_scale_.x()); | 231 float scale_x = ValueBetween(t, start_scale_.x(), end_scale_.x()); |
232 float scale_y = ValueBetween(t, start_scale_.y(), end_scale_.y()); | 232 float scale_y = ValueBetween(t, start_scale_.y(), end_scale_.y()); |
233 // TODO(vollick) 3d xforms. | 233 float scale_z = ValueBetween(t, start_scale_.z(), end_scale_.z()); |
234 result.Scale(scale_x, scale_y); | 234 result.Scale3d(scale_x, scale_y, scale_z); |
235 return result; | 235 return result; |
236 } | 236 } |
237 | 237 |
238 /////////////////////////////////////////////////////////////////////////////// | 238 /////////////////////////////////////////////////////////////////////////////// |
239 // InterpolatedTranslation | 239 // InterpolatedTranslation |
240 // | 240 // |
241 | 241 |
242 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point& start_pos, | 242 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point& start_pos, |
243 const gfx::Point& end_pos) | 243 const gfx::Point& end_pos) |
244 : InterpolatedTransform(), | 244 : InterpolatedTransform(), |
245 start_pos_(start_pos), | 245 start_pos_(start_pos), |
246 end_pos_(end_pos) { | 246 end_pos_(end_pos) { |
247 } | 247 } |
248 | 248 |
249 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point& start_pos, | 249 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point& start_pos, |
250 const gfx::Point& end_pos, | 250 const gfx::Point& end_pos, |
251 float start_time, | 251 float start_time, |
252 float end_time) | 252 float end_time) |
253 : InterpolatedTransform(start_time, end_time), | 253 : InterpolatedTransform(start_time, end_time), |
254 start_pos_(start_pos), | 254 start_pos_(start_pos), |
255 end_pos_(end_pos) { | 255 end_pos_(end_pos) { |
256 } | 256 } |
257 | 257 |
| 258 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point3F& start_pos, |
| 259 const gfx::Point3F& end_pos) |
| 260 : InterpolatedTransform(), start_pos_(start_pos), end_pos_(end_pos) { |
| 261 } |
| 262 |
| 263 InterpolatedTranslation::InterpolatedTranslation(const gfx::Point3F& start_pos, |
| 264 const gfx::Point3F& end_pos, |
| 265 float start_time, |
| 266 float end_time) |
| 267 : InterpolatedTransform(start_time, end_time), |
| 268 start_pos_(start_pos), |
| 269 end_pos_(end_pos) { |
| 270 } |
| 271 |
258 InterpolatedTranslation::~InterpolatedTranslation() {} | 272 InterpolatedTranslation::~InterpolatedTranslation() {} |
259 | 273 |
260 gfx::Transform | 274 gfx::Transform |
261 InterpolatedTranslation::InterpolateButDoNotCompose(float t) const { | 275 InterpolatedTranslation::InterpolateButDoNotCompose(float t) const { |
262 gfx::Transform result; | 276 gfx::Transform result; |
263 // TODO(vollick) 3d xforms. | 277 result.Translate3d(ValueBetween(t, start_pos_.x(), end_pos_.x()), |
264 result.Translate(ValueBetween(t, start_pos_.x(), end_pos_.x()), | 278 ValueBetween(t, start_pos_.y(), end_pos_.y()), |
265 ValueBetween(t, start_pos_.y(), end_pos_.y())); | 279 ValueBetween(t, start_pos_.z(), end_pos_.z())); |
266 return result; | 280 return result; |
267 } | 281 } |
268 | 282 |
269 /////////////////////////////////////////////////////////////////////////////// | 283 /////////////////////////////////////////////////////////////////////////////// |
270 // InterpolatedConstantTransform | 284 // InterpolatedConstantTransform |
271 // | 285 // |
272 | 286 |
273 InterpolatedConstantTransform::InterpolatedConstantTransform( | 287 InterpolatedConstantTransform::InterpolatedConstantTransform( |
274 const gfx::Transform& transform) | 288 const gfx::Transform& transform) |
275 : InterpolatedTransform(), | 289 : InterpolatedTransform(), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 375 |
362 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, | 376 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, |
363 const gfx::Transform& end_transform) { | 377 const gfx::Transform& end_transform) { |
364 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); | 378 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); |
365 DCHECK(success); | 379 DCHECK(success); |
366 success = gfx::DecomposeTransform(&end_decomp_, end_transform); | 380 success = gfx::DecomposeTransform(&end_decomp_, end_transform); |
367 DCHECK(success); | 381 DCHECK(success); |
368 } | 382 } |
369 | 383 |
370 } // namespace ui | 384 } // namespace ui |
OLD | NEW |