Chromium Code Reviews| 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 <cfloat> |
|
robertphillips
2016/01/22 14:42:51
Do we actually need all these new headers ?
herb_g
2016/01/22 16:01:05
Done.
| |
| 11 #include <algorithm> | |
| 12 #include <cstdint> | |
| 13 #include <string> | |
| 11 #include "Test.h" | 14 #include "Test.h" |
| 12 | 15 |
| 16 float BToF(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { | |
| 17 uint8_t mem[4] = {a, b, c, d}; | |
| 18 float val; | |
| 19 memcpy(&val, &mem, sizeof(mem)); | |
| 20 //SkDebugf("BToF: %.12e\n", val); | |
| 21 return val; | |
| 22 } | |
| 23 | |
| 13 DEF_TEST(ScaleToSides, reporter) { | 24 DEF_TEST(ScaleToSides, reporter) { |
| 14 float interestingValues[] = { | 25 double interestingValues[] = { |
| 15 0.0f, | 26 // From skp bitbucket |
| 16 0.5f, | 27 111.60000228881836, |
| 17 1.0f, | 28 55.800003051757813, |
| 18 2.0f, | 29 0.99999996581812677920, |
| 19 3.0f, | 30 0.0, |
| 20 33.0f, | 31 0.5, |
| 21 33554430.0f, | 32 1.0, |
| 22 33554431.0f, | 33 2.0, |
| 23 33554464.0f, | 34 3.0, |
| 24 333333332.0f, | 35 33.0, |
| 25 333333333.0f, | 36 33554430.0, |
| 26 333333334.0f, | 37 33554431.0, |
| 38 33554464.0, | |
| 39 333333332.0, | |
| 40 333333333.0, | |
| 41 333333334.0, | |
| 27 FLT_MAX, | 42 FLT_MAX, |
| 28 FLT_EPSILON, | 43 FLT_EPSILON, |
| 29 FLT_MIN | 44 FLT_MIN |
| 30 }; | 45 }; |
| 31 | 46 |
| 32 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues); | 47 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues); |
| 33 | 48 |
| 34 for (int i = 0; i < numInterestingValues; i++) { | 49 for (int s = 0; s <= numInterestingValues; s++) { |
| 35 for (int j = 0; j < numInterestingValues; j++) { | 50 for (int i = 0; i < numInterestingValues; i++) { |
| 36 for (int k = 0; k < numInterestingValues; k++) { | 51 for (int j = 0; j < numInterestingValues; j++) { |
| 37 float radius1 = interestingValues[i]; | 52 for (int k = 0; k < numInterestingValues; k++) { |
| 38 float radius2 = interestingValues[j]; | 53 float radius1 = interestingValues[i]; |
| 39 float width = interestingValues[k]; | 54 float radius2 = interestingValues[j]; |
| 40 if (width > 0.0f) { | 55 double width = interestingValues[k]; |
| 41 double scale = (double)width / ((double)radius1 + (double)ra dius2); | 56 double scale = width / ((double)radius1 + (double)radius2); |
| 42 if (scale < 1.0) { | 57 if (width > 0.0) { |
| 43 ScaleToSides::AdjustRadii(width, scale, &radius1, &radiu s2); | 58 if (s != 0) { |
| 59 scale = std::min(scale, (double)interestingValues[s- 1]); | |
| 60 } | |
| 61 if (scale < 1.0 && scale > 0.0) { | |
| 62 ScaleToSides::AdjustRadii(width, scale, &radius1, &r adius2); | |
| 63 } | |
| 44 } | 64 } |
| 45 } | 65 } |
| 46 } | 66 } |
| 47 } | 67 } |
| 48 } | 68 } |
| 49 } | 69 } |
| OLD | NEW |