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 #ifndef SkScaleToSides_DEFINED | 8 #ifndef SkScaleToSides_DEFINED |
| 9 #define SkScaleToSides_DEFINED | 9 #define SkScaleToSides_DEFINED |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 // is 1/2 the ratio of minRadius : (minRadius + maxRadius), therefor e in the resulting | 38 // is 1/2 the ratio of minRadius : (minRadius + maxRadius), therefor e in the resulting |
| 39 // division, minRadius can be no larger than 1/2 limit + ULP. | 39 // division, minRadius can be no larger than 1/2 limit + ULP. |
| 40 float newMinRadius = *minRadius; | 40 float newMinRadius = *minRadius; |
| 41 | 41 |
| 42 // Because newMaxRadius is the result of a double to float conversio n, it can be larger | 42 // Because newMaxRadius is the result of a double to float conversio n, it can be larger |
| 43 // than limit, but only by one ULP. | 43 // than limit, but only by one ULP. |
| 44 float newMaxRadius = (float)(limit - newMinRadius); | 44 float newMaxRadius = (float)(limit - newMinRadius); |
| 45 | 45 |
| 46 // If newMaxRadius forces the total over the limit, then it needs to be | 46 // If newMaxRadius forces the total over the limit, then it needs to be |
| 47 // reduced by one ULP to be less than limit - newMinRadius. | 47 // reduced by one ULP to be less than limit - newMinRadius. |
| 48 // Note: nexttowardf is a c99 call and should be std::nexttoward, bu t this is not | |
|
mtklein
2016/01/22 17:44:32
The same note does still apply to nextafterf vs. s
herb_g
2016/01/22 17:52:34
Done.
| |
| 49 // implemented in the ARM compiler. | |
| 50 if (newMaxRadius + newMinRadius > limit) { | 48 if (newMaxRadius + newMinRadius > limit) { |
| 51 newMaxRadius = nexttowardf(newMaxRadius, 0.0); | 49 newMaxRadius = nextafterf(newMaxRadius, 0.0f); |
| 52 } | 50 } |
| 53 *maxRadius = newMaxRadius; | 51 *maxRadius = newMaxRadius; |
| 54 } | 52 } |
| 55 | 53 |
| 56 SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g" , *a, *b, limit, | 54 SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g" , *a, *b, limit, |
| 57 scale); | 55 scale); |
| 58 SkASSERTF(*a + *b <= limit, "\nlimit: %.10f, a: %.10f, b: %.10f, scale: %.20f", | 56 SkASSERTF(*a + *b <= limit, "\nlimit: %.10f, a: %.10f, b: %.10f, scale: %.20f", |
| 59 limit, *a, *b, scale); | 57 limit, *a, *b, scale); |
| 60 } | 58 } |
| 61 }; | 59 }; |
| 62 #endif // ScaleToSides_DEFINED | 60 #endif // ScaleToSides_DEFINED |
| OLD | NEW |