Chromium Code Reviews| Index: ui/base/animation/tween.cc |
| diff --git a/ui/base/animation/tween.cc b/ui/base/animation/tween.cc |
| index 515ae576ed5c20189c4be94d40b47ea49ad293cc..f866443fec5a2e7ccf5ad4ad24344fa4ddcea704 100644 |
| --- a/ui/base/animation/tween.cc |
| +++ b/ui/base/animation/tween.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/logging.h" |
| #include "ui/gfx/rect.h" |
| +#include "ui/gfx/interpolated_transform.h" |
|
sky
2011/10/20 16:33:03
sort
|
| namespace ui { |
| @@ -83,4 +84,40 @@ gfx::Rect Tween::ValueBetween(double value, |
| target_bounds.height())); |
| } |
| +// static |
| +Transform Tween::ValueBetween(double value, |
| + const Transform& start_transform, |
| + const Transform& end_transform) { |
| + Transform to_return; |
| + gfx::Point start_translation, end_translation; |
| + float start_rotation, end_rotation; |
| + gfx::Point3f start_scale, end_scale; |
| + if (InterpolatedTransform::FactorTRS(start_transform, |
| + &start_translation, |
| + &start_rotation, |
| + &start_scale) && |
| + InterpolatedTransform::FactorTRS(end_transform, |
| + &end_translation, |
| + &end_rotation, |
| + &end_scale)) { |
| + to_return.SetScale(ValueBetween(value, start_scale.x(), end_scale.x()), |
| + ValueBetween(value, start_scale.y(), end_scale.y())); |
| + to_return.ConcatRotate(ValueBetween(value, start_rotation, end_rotation)); |
| + to_return.ConcatTranslate( |
| + ValueBetween(value, start_translation.x(), end_translation.x()), |
| + ValueBetween(value, start_translation.y(), end_translation.y())); |
| + } else { |
| + for (int row = 0; row < 4; ++row) { |
| + for (int col = 0; col < 4; ++col) { |
| + to_return.matrix().set(row, col, |
| + ValueBetween(value, |
| + start_transform.matrix().get(row, col), |
| + end_transform.matrix().get(row, col))); |
| + } |
| + } |
| + } |
| + |
| + return to_return; |
| +} |
| + |
| } // namespace ui |