| OLD | NEW |
| 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 "SkMath.h" | 8 #include "SkMath.h" |
| 9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 #include "SkMatrixUtils.h" | 10 #include "SkMatrixUtils.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 vectors[i].fX = rand.nextSScalar1(); | 263 vectors[i].fX = rand.nextSScalar1(); |
| 264 vectors[i].fY = rand.nextSScalar1(); | 264 vectors[i].fY = rand.nextSScalar1(); |
| 265 if (!vectors[i].normalize()) { | 265 if (!vectors[i].normalize()) { |
| 266 i -= 1; | 266 i -= 1; |
| 267 continue; | 267 continue; |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors)); | 270 mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors)); |
| 271 for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) { | 271 for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) { |
| 272 SkScalar d = vectors[i].length(); | 272 SkScalar d = vectors[i].length(); |
| 273 REPORTER_ASSERT(reporter, SkScalarDiv(d, maxScale) < gVectorScaleTol
); | 273 REPORTER_ASSERT(reporter, d / maxScale < gVectorScaleTol); |
| 274 REPORTER_ASSERT(reporter, SkScalarDiv(minScale, d) < gVectorScaleTol
); | 274 REPORTER_ASSERT(reporter, minScale / d < gVectorScaleTol); |
| 275 if (max < d) { | 275 if (max < d) { |
| 276 max = d; | 276 max = d; |
| 277 } | 277 } |
| 278 if (min > d) { | 278 if (min > d) { |
| 279 min = d; | 279 min = d; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 REPORTER_ASSERT(reporter, SkScalarDiv(max, maxScale) >= gCloseScaleTol); | 282 REPORTER_ASSERT(reporter, max / maxScale >= gCloseScaleTol); |
| 283 REPORTER_ASSERT(reporter, SkScalarDiv(minScale, min) >= gCloseScaleTol); | 283 REPORTER_ASSERT(reporter, minScale / min >= gCloseScaleTol); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 static void test_matrix_preserve_shape(skiatest::Reporter* reporter) { | 287 static void test_matrix_preserve_shape(skiatest::Reporter* reporter) { |
| 288 SkMatrix mat; | 288 SkMatrix mat; |
| 289 | 289 |
| 290 // identity | 290 // identity |
| 291 mat.setIdentity(); | 291 mat.setIdentity(); |
| 292 REPORTER_ASSERT(reporter, mat.isSimilarity()); | 292 REPORTER_ASSERT(reporter, mat.isSimilarity()); |
| 293 REPORTER_ASSERT(reporter, mat.preservesRightAngles()); | 293 REPORTER_ASSERT(reporter, mat.preservesRightAngles()); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 a.setTranslate(10, 20); | 926 a.setTranslate(10, 20); |
| 927 | 927 |
| 928 SkMatrix b; | 928 SkMatrix b; |
| 929 b.setScale(3, 5); | 929 b.setScale(3, 5); |
| 930 | 930 |
| 931 SkMatrix expected; | 931 SkMatrix expected; |
| 932 expected.setConcat(a,b); | 932 expected.setConcat(a,b); |
| 933 | 933 |
| 934 REPORTER_ASSERT(r, expected == SkMatrix::Concat(a, b)); | 934 REPORTER_ASSERT(r, expected == SkMatrix::Concat(a, b)); |
| 935 } | 935 } |
| OLD | NEW |