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

Side by Side Diff: tests/Matrix44Test.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 #include "SkMatrix44.h" 10 #include "SkMatrix44.h"
11 11
12 static bool nearly_equal_double(double a, double b) { 12 static bool nearly_equal_double(double a, double b) {
13 const double tolerance = 1e-7; 13 const double tolerance = 1e-7;
14 double diff = a - b; 14 double diff = a - b;
15 if (diff < 0) 15 if (diff < 0)
16 diff = -diff; 16 diff = -diff;
17 return diff <= tolerance; 17 return diff <= tolerance;
18 } 18 }
19 19
20 static bool nearly_equal_mscalar(SkMScalar a, SkMScalar b) { 20 static bool nearly_equal_mscalar(SkMScalar a, SkMScalar b) {
21 const SkMScalar tolerance = SK_MScalar1 / 200000; 21 const SkMScalar tolerance = SK_MScalar1 / 200000;
22 22
23 return SkTAbs<SkMScalar>(a - b) <= tolerance; 23 return SkTAbs<SkMScalar>(a - b) <= tolerance;
24 } 24 }
25 25
26 static bool nearly_equal_scalar(SkScalar a, SkScalar b) { 26 static bool nearly_equal_scalar(SkScalar a, SkScalar b) {
27 // Note that we get more compounded error for multiple operations when
28 // SK_SCALAR_IS_FIXED.
29 #ifdef SK_SCALAR_IS_FLOAT
30 const SkScalar tolerance = SK_Scalar1 / 200000; 27 const SkScalar tolerance = SK_Scalar1 / 200000;
31 #else
32 const SkScalar tolerance = SK_Scalar1 / 1024;
33 #endif
34
35 return SkScalarAbs(a - b) <= tolerance; 28 return SkScalarAbs(a - b) <= tolerance;
36 } 29 }
37 30
38 template <typename T> void assert16(skiatest::Reporter* reporter, const T data[] , 31 template <typename T> void assert16(skiatest::Reporter* reporter, const T data[] ,
39 T m0, T m1, T m2, T m3, 32 T m0, T m1, T m2, T m3,
40 T m4, T m5, T m6, T m7, 33 T m4, T m5, T m6, T m7,
41 T m8, T m9, T m10, T m11, 34 T m8, T m9, T m10, T m11,
42 T m12, T m13, T m14, T m15) { 35 T m12, T m13, T m14, T m15) {
43 REPORTER_ASSERT(reporter, data[0] == m0); 36 REPORTER_ASSERT(reporter, data[0] == m0);
44 REPORTER_ASSERT(reporter, data[1] == m1); 37 REPORTER_ASSERT(reporter, data[1] == m1);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 test_determinant(reporter); 621 test_determinant(reporter);
629 test_invert(reporter); 622 test_invert(reporter);
630 test_transpose(reporter); 623 test_transpose(reporter);
631 test_get_set_double(reporter); 624 test_get_set_double(reporter);
632 test_set_row_col_major(reporter); 625 test_set_row_col_major(reporter);
633 test_translate(reporter); 626 test_translate(reporter);
634 test_scale(reporter); 627 test_scale(reporter);
635 test_map2(reporter); 628 test_map2(reporter);
636 test_3x3_conversion(reporter); 629 test_3x3_conversion(reporter);
637 } 630 }
OLDNEW
« src/core/SkCanvas.cpp ('K') | « tests/MathTest.cpp ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698