OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/math_util.h" | 5 #include "cc/math_util.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "ui/gfx/quad_f.h" | 10 #include "ui/gfx/quad_f.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 gfx::Transform rotationAboutZ; | 415 gfx::Transform rotationAboutZ; |
416 | 416 |
417 rotationAboutX.RotateAboutXAxis(eulerX); | 417 rotationAboutX.RotateAboutXAxis(eulerX); |
418 rotationAboutY.RotateAboutYAxis(eulerY); | 418 rotationAboutY.RotateAboutYAxis(eulerY); |
419 rotationAboutZ.RotateAboutZAxis(eulerZ); | 419 rotationAboutZ.RotateAboutZAxis(eulerZ); |
420 | 420 |
421 gfx::Transform composite = rotationAboutZ * rotationAboutY * rotationAboutX; | 421 gfx::Transform composite = rotationAboutZ * rotationAboutY * rotationAboutX; |
422 transform->PreconcatTransform(composite); | 422 transform->PreconcatTransform(composite); |
423 } | 423 } |
424 | 424 |
425 gfx::Transform MathUtil::inverse(const gfx::Transform& transform) | |
426 { | |
427 gfx::Transform result; | |
428 bool invertedSuccessfully = transform.GetInverse(&result); | |
429 | |
430 if (invertedSuccessfully) | |
431 return result; | |
432 | |
433 // If transform was un-invertible, then just return identity. | |
434 return gfx::Transform(); | |
435 } | |
436 | |
437 gfx::Transform MathUtil::to2dTransform(const gfx::Transform& transform) | 425 gfx::Transform MathUtil::to2dTransform(const gfx::Transform& transform) |
438 { | 426 { |
439 gfx::Transform result = transform; | 427 gfx::Transform result = transform; |
440 SkMatrix44& matrix = result.matrix(); | 428 SkMatrix44& matrix = result.matrix(); |
441 matrix.setDouble(0, 2, 0); | 429 matrix.setDouble(0, 2, 0); |
442 matrix.setDouble(1, 2, 0); | 430 matrix.setDouble(1, 2, 0); |
443 matrix.setDouble(2, 2, 1); | 431 matrix.setDouble(2, 2, 1); |
444 matrix.setDouble(3, 2, 0); | 432 matrix.setDouble(3, 2, 0); |
445 | 433 |
446 matrix.setDouble(2, 0, 0); | 434 matrix.setDouble(2, 0, 0); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 matrix.setDouble(1, 0, b); | 482 matrix.setDouble(1, 0, b); |
495 matrix.setDouble(0, 1, c); | 483 matrix.setDouble(0, 1, c); |
496 matrix.setDouble(1, 1, d); | 484 matrix.setDouble(1, 1, d); |
497 matrix.setDouble(0, 3, e); | 485 matrix.setDouble(0, 3, e); |
498 matrix.setDouble(1, 3, f); | 486 matrix.setDouble(1, 3, f); |
499 | 487 |
500 return result; | 488 return result; |
501 } | 489 } |
502 | 490 |
503 } // namespace cc | 491 } // namespace cc |
OLD | NEW |