Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: ui/gfx/transform_util.cc

Issue 1071803003: Update matrix distance metric to account for snapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grammar Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/transform_util.h ('k') | ui/gfx/transform_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/gfx/transform_util.h ('k') | ui/gfx/transform_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698