| 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/gfx/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 |
| 25 bool IsApproximatelyZero(double value) { | |
| 26 return fabs(value) < EPSILON; | |
| 27 } | |
| 28 | |
| 29 // Returns false if |degrees| is not a multiple of ninety degrees or if | 25 // Returns false if |degrees| is not a multiple of ninety degrees or if |
| 30 // |rotation| is NULL. It does not affect |rotation| in this case. Otherwise | 26 // |rotation| is NULL. It does not affect |rotation| in this case. Otherwise |
| 31 // *rotation is set to be the appropriate sanitized rotation matrix. That is, | 27 // *rotation is set to be the appropriate sanitized rotation matrix. That is, |
| 32 // the rotation matrix corresponding to |degrees| which has entries that are all | 28 // the rotation matrix corresponding to |degrees| which has entries that are all |
| 33 // either 0, 1 or -1. | 29 // either 0, 1 or -1. |
| 34 bool MassageRotationIfMultipleOfNinetyDegrees(gfx::Transform* rotation, | 30 bool MassageRotationIfMultipleOfNinetyDegrees(gfx::Transform* rotation, |
| 35 float degrees) { | 31 float degrees) { |
| 36 if (!IsMultipleOfNinetyDegrees(degrees) || !rotation) | 32 if (!IsMultipleOfNinetyDegrees(degrees) || !rotation) |
| 37 return false; | 33 return false; |
| 38 | 34 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 361 |
| 366 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, | 362 void InterpolatedMatrixTransform::Init(const gfx::Transform& start_transform, |
| 367 const gfx::Transform& end_transform) { | 363 const gfx::Transform& end_transform) { |
| 368 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); | 364 bool success = gfx::DecomposeTransform(&start_decomp_, start_transform); |
| 369 DCHECK(success); | 365 DCHECK(success); |
| 370 success = gfx::DecomposeTransform(&end_decomp_, end_transform); | 366 success = gfx::DecomposeTransform(&end_decomp_, end_transform); |
| 371 DCHECK(success); | 367 DCHECK(success); |
| 372 } | 368 } |
| 373 | 369 |
| 374 } // namespace ui | 370 } // namespace ui |
| OLD | NEW |