| 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 | 7 |
| 8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 cofactor_part_5 - | 238 cofactor_part_5 - |
| 239 cofactor_part_6; | 239 cofactor_part_6; |
| 240 | 240 |
| 241 // Technically the transformed z component is cofactor33 / determinant. But | 241 // Technically the transformed z component is cofactor33 / determinant. But |
| 242 // we can avoid the costly division because we only care about the resulting | 242 // we can avoid the costly division because we only care about the resulting |
| 243 // +/- sign; we can check this equivalently by multiplication. | 243 // +/- sign; we can check this equivalently by multiplication. |
| 244 return cofactor33 * determinant < 0; | 244 return cofactor33 * determinant < 0; |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool Transform::GetInverse(Transform* transform) const { | 247 bool Transform::GetInverse(Transform* transform) const { |
| 248 return matrix_.invert(&transform->matrix_); | 248 if (!matrix_.invert(&transform->matrix_)) { |
| 249 // Initialize the return value to identity if this matrix turned |
| 250 // out to be un-invertible. |
| 251 transform->MakeIdentity(); |
| 252 return false; |
| 253 } |
| 254 |
| 255 return true; |
| 249 } | 256 } |
| 250 | 257 |
| 251 void Transform::Transpose() { | 258 void Transform::Transpose() { |
| 252 matrix_.transpose(); | 259 matrix_.transpose(); |
| 253 } | 260 } |
| 254 | 261 |
| 255 void Transform::TransformPoint(Point& point) const { | 262 void Transform::TransformPoint(Point& point) const { |
| 256 TransformPointInternal(matrix_, point); | 263 TransformPointInternal(matrix_, point); |
| 257 } | 264 } |
| 258 | 265 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 matrix_.getDouble(2, 1), | 390 matrix_.getDouble(2, 1), |
| 384 matrix_.getDouble(2, 2), | 391 matrix_.getDouble(2, 2), |
| 385 matrix_.getDouble(2, 3), | 392 matrix_.getDouble(2, 3), |
| 386 matrix_.getDouble(3, 0), | 393 matrix_.getDouble(3, 0), |
| 387 matrix_.getDouble(3, 1), | 394 matrix_.getDouble(3, 1), |
| 388 matrix_.getDouble(3, 2), | 395 matrix_.getDouble(3, 2), |
| 389 matrix_.getDouble(3, 3)); | 396 matrix_.getDouble(3, 3)); |
| 390 } | 397 } |
| 391 | 398 |
| 392 } // namespace gfx | 399 } // namespace gfx |
| OLD | NEW |