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/compositor/transform_animation_curve_adapter.h" | 5 #include "ui/compositor/transform_animation_curve_adapter.h" |
6 | 6 |
7 namespace ui { | 7 namespace ui { |
8 | 8 |
9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter( | 9 TransformAnimationCurveAdapter::TransformAnimationCurveAdapter( |
10 Tween::Type tween_type, | 10 Tween::Type tween_type, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 bool TransformAnimationCurveAdapter::AnimatedBoundsForBox( | 54 bool TransformAnimationCurveAdapter::AnimatedBoundsForBox( |
55 const gfx::BoxF& box, | 55 const gfx::BoxF& box, |
56 gfx::BoxF* bounds) const { | 56 gfx::BoxF* bounds) const { |
57 // TODO(ajuma): Once cc::TransformOperation::BlendedBoundsForBox supports | 57 // TODO(ajuma): Once cc::TransformOperation::BlendedBoundsForBox supports |
58 // computing bounds for TransformOperationMatrix, use that to compute | 58 // computing bounds for TransformOperationMatrix, use that to compute |
59 // the bounds we need here. | 59 // the bounds we need here. |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
| 63 InverseTransformCurveAdapter::InverseTransformCurveAdapter( |
| 64 TransformAnimationCurveAdapter base_curve, |
| 65 gfx::Transform initial_value, |
| 66 base::TimeDelta duration) |
| 67 : base_curve_(base_curve), |
| 68 initial_value_(initial_value), |
| 69 duration_(duration) { |
| 70 effective_initial_value_ = base_curve_.GetValue(0.0) * initial_value_; |
| 71 } |
| 72 |
| 73 InverseTransformCurveAdapter::~InverseTransformCurveAdapter() { |
| 74 } |
| 75 |
| 76 double InverseTransformCurveAdapter::Duration() const { |
| 77 return duration_.InSeconds(); |
| 78 } |
| 79 |
| 80 scoped_ptr<cc::AnimationCurve> InverseTransformCurveAdapter::Clone() const { |
| 81 scoped_ptr<InverseTransformCurveAdapter> to_return( |
| 82 new InverseTransformCurveAdapter(base_curve_, |
| 83 initial_value_, |
| 84 duration_)); |
| 85 return to_return.PassAs<cc::AnimationCurve>(); |
| 86 } |
| 87 |
| 88 gfx::Transform InverseTransformCurveAdapter::GetValue( |
| 89 double t) const { |
| 90 if (t <= 0.0) |
| 91 return initial_value_; |
| 92 |
| 93 gfx::Transform base_transform = base_curve_.GetValue(t); |
| 94 // Invert base |
| 95 gfx::Transform to_return(gfx::Transform::kSkipInitialization); |
| 96 bool is_invertible = base_transform.GetInverse(&to_return); |
| 97 DCHECK(is_invertible); |
| 98 |
| 99 to_return.PreconcatTransform(effective_initial_value_); |
| 100 return to_return; |
| 101 } |
| 102 |
| 103 bool InverseTransformCurveAdapter::AnimatedBoundsForBox( |
| 104 const gfx::BoxF& box, |
| 105 gfx::BoxF* bounds) const { |
| 106 // TODO(ajuma): Once cc::TransformOperation::BlendedBoundsForBox supports |
| 107 // computing bounds for TransformOperationMatrix, use that to compute |
| 108 // the bounds we need here. |
| 109 return false; |
| 110 } |
| 111 |
63 } // namespace ui | 112 } // namespace ui |
OLD | NEW |