OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkScaleToSides.h" | 8 #include "SkScaleToSides.h" |
9 | 9 |
10 #include <cfloat> | 10 #include <algorithm> |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 DEF_TEST(ScaleToSides, reporter) { | 13 DEF_TEST(ScaleToSides, reporter) { |
14 float interestingValues[] = { | 14 double interestingValues[] = { |
15 0.0f, | 15 // From skp bitbucket |
16 0.5f, | 16 111.60000228881836, |
17 1.0f, | 17 55.800003051757813, |
18 2.0f, | 18 0.99999996581812677920, |
19 3.0f, | 19 0.0, |
20 33.0f, | 20 0.5, |
21 33554430.0f, | 21 1.0, |
22 33554431.0f, | 22 2.0, |
23 33554464.0f, | 23 3.0, |
24 333333332.0f, | 24 33.0, |
25 333333333.0f, | 25 33554430.0, |
26 333333334.0f, | 26 33554431.0, |
| 27 33554464.0, |
| 28 333333332.0, |
| 29 333333333.0, |
| 30 333333334.0, |
27 FLT_MAX, | 31 FLT_MAX, |
28 FLT_EPSILON, | 32 FLT_EPSILON, |
29 FLT_MIN | 33 FLT_MIN |
30 }; | 34 }; |
31 | 35 |
32 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues); | 36 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues); |
33 | 37 |
34 for (int i = 0; i < numInterestingValues; i++) { | 38 for (int s = 0; s <= numInterestingValues; s++) { |
35 for (int j = 0; j < numInterestingValues; j++) { | 39 for (int i = 0; i < numInterestingValues; i++) { |
36 for (int k = 0; k < numInterestingValues; k++) { | 40 for (int j = 0; j < numInterestingValues; j++) { |
37 float radius1 = interestingValues[i]; | 41 for (int k = 0; k < numInterestingValues; k++) { |
38 float radius2 = interestingValues[j]; | 42 float radius1 = (float)interestingValues[i]; |
39 float width = interestingValues[k]; | 43 float radius2 = (float)interestingValues[j]; |
40 if (width > 0.0f) { | 44 double width = interestingValues[k]; |
41 double scale = (double)width / ((double)radius1 + (double)ra
dius2); | 45 double scale = width / ((double)radius1 + (double)radius2); |
42 if (scale < 1.0) { | 46 if (width > 0.0) { |
43 ScaleToSides::AdjustRadii(width, scale, &radius1, &radiu
s2); | 47 if (s != 0) { |
| 48 scale = std::min(scale, interestingValues[s-1]); |
| 49 } |
| 50 if (scale < 1.0 && scale > 0.0) { |
| 51 ScaleToSides::AdjustRadii(width, scale, &radius1, &r
adius2); |
| 52 } |
44 } | 53 } |
45 } | 54 } |
46 } | 55 } |
47 } | 56 } |
48 } | 57 } |
49 } | 58 } |
OLD | NEW |