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/transform_util.h" | 5 #include "ui/gfx/transform_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 perspective[0], | 508 perspective[0], |
509 perspective[1], | 509 perspective[1], |
510 perspective[2], | 510 perspective[2], |
511 perspective[3], | 511 perspective[3], |
512 quaternion[0], | 512 quaternion[0], |
513 quaternion[1], | 513 quaternion[1], |
514 quaternion[2], | 514 quaternion[2], |
515 quaternion[3]); | 515 quaternion[3]); |
516 } | 516 } |
517 | 517 |
518 float MatrixDistance(const Transform& a, const Transform& b) { | |
519 double sum = 0.0; | |
520 | |
521 const SkMatrix44& a_data = a.matrix(); | |
522 const SkMatrix44& b_data = b.matrix(); | |
523 | |
524 for (int row = 0; row < 4; ++row) { | |
525 for (int col = 0; col < 4; ++col) { | |
526 double diff = a_data.get(row, col) - b_data.get(row, col); | |
527 sum += diff * diff; | |
528 } | |
529 } | |
530 | |
531 return static_cast<float>(std::sqrt(sum)); | |
532 } | |
533 | |
534 } // namespace gfx | 518 } // namespace gfx |
OLD | NEW |