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 |
11 #endif | 11 #endif |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "ui/base/animation/tween.h" | 14 #include "ui/gfx/animation/tween.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 static const double EPSILON = 1e-6; | 18 static const double EPSILON = 1e-6; |
19 | 19 |
20 bool IsMultipleOfNinetyDegrees(double degrees) { | 20 bool IsMultipleOfNinetyDegrees(double degrees) { |
21 double remainder = fabs(fmod(degrees, 90.0)); | 21 double remainder = fabs(fmod(degrees, 90.0)); |
22 return remainder < EPSILON || 90.0 - remainder < EPSILON; | 22 return remainder < EPSILON || 90.0 - remainder < EPSILON; |
23 } | 23 } |
24 | 24 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // due to one of the following if statements. | 118 // due to one of the following if statements. |
119 DCHECK(end_time_ >= start_time_); | 119 DCHECK(end_time_ >= start_time_); |
120 | 120 |
121 if (time < start_time_) | 121 if (time < start_time_) |
122 return start_value; | 122 return start_value; |
123 | 123 |
124 if (time >= end_time_) | 124 if (time >= end_time_) |
125 return end_value; | 125 return end_value; |
126 | 126 |
127 float t = (time - start_time_) / (end_time_ - start_time_); | 127 float t = (time - start_time_) / (end_time_ - start_time_); |
128 return static_cast<float>(Tween::ValueBetween(t, start_value, end_value)); | 128 return static_cast<float>( |
| 129 gfx::Tween::ValueBetween(t, start_value, end_value)); |
129 } | 130 } |
130 | 131 |
131 /////////////////////////////////////////////////////////////////////////////// | 132 /////////////////////////////////////////////////////////////////////////////// |
132 // InterpolatedRotation | 133 // InterpolatedRotation |
133 // | 134 // |
134 | 135 |
135 InterpolatedRotation::InterpolatedRotation(float start_degrees, | 136 InterpolatedRotation::InterpolatedRotation(float start_degrees, |
136 float end_degrees) | 137 float end_degrees) |
137 : InterpolatedTransform(), | 138 : InterpolatedTransform(), |
138 start_degrees_(start_degrees), | 139 start_degrees_(start_degrees), |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 365 |
365 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, | 366 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, |
366 const gfx::Transform& end_transform) { | 367 const gfx::Transform& end_transform) { |
367 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); | 368 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); |
368 DCHECK(success); | 369 DCHECK(success); |
369 success = gfx::DecomposeTransform(&end_decomp_, end_transform); | 370 success = gfx::DecomposeTransform(&end_decomp_, end_transform); |
370 DCHECK(success); | 371 DCHECK(success); |
371 } | 372 } |
372 | 373 |
373 } // namespace ui | 374 } // namespace ui |
OLD | NEW |