OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/animation/tween.h" | 5 #include "ui/base/animation/tween.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <float.h> | 10 #include <float.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 | |
15 #if !defined(OS_MACOSX) | |
16 #include "ui/gfx/interpolated_transform.h" | 14 #include "ui/gfx/interpolated_transform.h" |
17 #endif | |
18 | 15 |
19 namespace ui { | 16 namespace ui { |
20 | 17 |
21 // static | 18 // static |
22 double Tween::CalculateValue(Tween::Type type, double state) { | 19 double Tween::CalculateValue(Tween::Type type, double state) { |
23 DCHECK_GE(state, 0); | 20 DCHECK_GE(state, 0); |
24 DCHECK_LE(state, 1); | 21 DCHECK_LE(state, 1); |
25 | 22 |
26 switch (type) { | 23 switch (type) { |
27 case EASE_IN: | 24 case EASE_IN: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const gfx::Rect& start_bounds, | 76 const gfx::Rect& start_bounds, |
80 const gfx::Rect& target_bounds) { | 77 const gfx::Rect& target_bounds) { |
81 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()), | 78 return gfx::Rect(ValueBetween(value, start_bounds.x(), target_bounds.x()), |
82 ValueBetween(value, start_bounds.y(), target_bounds.y()), | 79 ValueBetween(value, start_bounds.y(), target_bounds.y()), |
83 ValueBetween(value, start_bounds.width(), | 80 ValueBetween(value, start_bounds.width(), |
84 target_bounds.width()), | 81 target_bounds.width()), |
85 ValueBetween(value, start_bounds.height(), | 82 ValueBetween(value, start_bounds.height(), |
86 target_bounds.height())); | 83 target_bounds.height())); |
87 } | 84 } |
88 | 85 |
89 #if !defined(OS_MACOSX) | |
90 // static | 86 // static |
91 Transform Tween::ValueBetween(double value, | 87 Transform Tween::ValueBetween(double value, |
92 const Transform& start_transform, | 88 const Transform& start_transform, |
93 const Transform& end_transform) { | 89 const Transform& end_transform) { |
94 if (value >= 1.0) | 90 if (value >= 1.0) |
95 return end_transform; | 91 return end_transform; |
96 if (value <= 0.0) | 92 if (value <= 0.0) |
97 return start_transform; | 93 return start_transform; |
98 | 94 |
99 Transform to_return; | 95 Transform to_return; |
(...skipping 20 matching lines...) Expand all Loading... |
120 to_return.matrix().set(row, col, | 116 to_return.matrix().set(row, col, |
121 ValueBetween(value, | 117 ValueBetween(value, |
122 start_transform.matrix().get(row, col), | 118 start_transform.matrix().get(row, col), |
123 end_transform.matrix().get(row, col))); | 119 end_transform.matrix().get(row, col))); |
124 } | 120 } |
125 } | 121 } |
126 } | 122 } |
127 | 123 |
128 return to_return; | 124 return to_return; |
129 } | 125 } |
130 #endif | |
131 | 126 |
132 } // namespace ui | 127 } // namespace ui |
OLD | NEW |