Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Needed on Windows to get |M_PI| from <cmath> | 5 // Needed on Windows to get |M_PI| from <cmath> |
| 6 #ifdef _WIN32 | 6 #ifdef _WIN32 |
| 7 #define _USE_MATH_DEFINES | 7 #define _USE_MATH_DEFINES |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 bool TransformOperation::IsIdentity() const { | 27 bool TransformOperation::IsIdentity() const { |
| 28 return matrix.IsIdentity(); | 28 return matrix.IsIdentity(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static bool IsOperationIdentity(const TransformOperation* operation) { | 31 static bool IsOperationIdentity(const TransformOperation* operation) { |
| 32 return !operation || operation->IsIdentity(); | 32 return !operation || operation->IsIdentity(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 static bool Is3DRotation(const TransformOperation* operation) { | |
| 36 if (IsOperationIdentity(operation)) | |
| 37 return false; | |
| 38 return operation->rotate.axis.x != 0 || operation->rotate.axis.y != 0; | |
| 39 } | |
| 40 | |
| 35 static bool ShareSameAxis(const TransformOperation* from, | 41 static bool ShareSameAxis(const TransformOperation* from, |
| 36 const TransformOperation* to, | 42 const TransformOperation* to, |
| 37 SkMScalar* axis_x, | 43 SkMScalar* axis_x, |
| 38 SkMScalar* axis_y, | 44 SkMScalar* axis_y, |
| 39 SkMScalar* axis_z, | 45 SkMScalar* axis_z, |
| 40 SkMScalar* angle_from) { | 46 SkMScalar* angle_from) { |
| 41 if (IsOperationIdentity(from) && IsOperationIdentity(to)) | 47 if (IsOperationIdentity(from) && IsOperationIdentity(to)) |
| 42 return false; | 48 return false; |
| 43 | 49 |
| 44 if (IsOperationIdentity(from) && !IsOperationIdentity(to)) { | 50 if (IsOperationIdentity(from) && !IsOperationIdentity(to)) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 BlendSkMScalars(from_y, to_y, progress), | 123 BlendSkMScalars(from_y, to_y, progress), |
| 118 BlendSkMScalars(from_z, to_z, progress)); | 124 BlendSkMScalars(from_z, to_z, progress)); |
| 119 break; | 125 break; |
| 120 } | 126 } |
| 121 case TransformOperation::TRANSFORM_OPERATION_ROTATE: { | 127 case TransformOperation::TRANSFORM_OPERATION_ROTATE: { |
| 122 SkMScalar axis_x = 0; | 128 SkMScalar axis_x = 0; |
| 123 SkMScalar axis_y = 0; | 129 SkMScalar axis_y = 0; |
| 124 SkMScalar axis_z = 1; | 130 SkMScalar axis_z = 1; |
| 125 SkMScalar from_angle = 0; | 131 SkMScalar from_angle = 0; |
| 126 SkMScalar to_angle = IsOperationIdentity(to) ? 0 : to->rotate.angle; | 132 SkMScalar to_angle = IsOperationIdentity(to) ? 0 : to->rotate.angle; |
| 127 if (ShareSameAxis(from, to, &axis_x, &axis_y, &axis_z, &from_angle)) { | 133 if (ShareSameAxis(from, to, &axis_x, &axis_y, &axis_z, &from_angle) && |
| 134 !Is3DRotation(from) && !Is3DRotation(to)) { | |
|
ajuma
2015/06/23 13:24:58
I'm not sure I follow how this corresponds to the
soonm
2015/06/23 23:43:42
Thanks ajuma, I think you're right. I misunderstoo
| |
| 128 result->RotateAbout(gfx::Vector3dF(axis_x, axis_y, axis_z), | 135 result->RotateAbout(gfx::Vector3dF(axis_x, axis_y, axis_z), |
| 129 BlendSkMScalars(from_angle, to_angle, progress)); | 136 BlendSkMScalars(from_angle, to_angle, progress)); |
| 130 } else { | 137 } else { |
| 131 gfx::Transform to_matrix; | 138 gfx::Transform to_matrix; |
| 132 if (!IsOperationIdentity(to)) | 139 if (!IsOperationIdentity(to)) |
| 133 to_matrix = to->matrix; | 140 to_matrix = to->matrix; |
| 134 gfx::Transform from_matrix; | 141 gfx::Transform from_matrix; |
| 135 if (!IsOperationIdentity(from)) | 142 if (!IsOperationIdentity(from)) |
| 136 from_matrix = from->matrix; | 143 from_matrix = from->matrix; |
| 137 *result = to_matrix; | 144 *result = to_matrix; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 return true; | 437 return true; |
| 431 } | 438 } |
| 432 case TransformOperation::TRANSFORM_OPERATION_MATRIX: | 439 case TransformOperation::TRANSFORM_OPERATION_MATRIX: |
| 433 return false; | 440 return false; |
| 434 } | 441 } |
| 435 NOTREACHED(); | 442 NOTREACHED(); |
| 436 return false; | 443 return false; |
| 437 } | 444 } |
| 438 | 445 |
| 439 } // namespace cc | 446 } // namespace cc |
| OLD | NEW |