diff options
-rw-r--r-- | src/core/SkScaleToSides.h | 16 | ||||
-rw-r--r-- | tests/ScaleToSidesTest.cpp | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/core/SkScaleToSides.h b/src/core/SkScaleToSides.h index 49201d0361..c700891061 100644 --- a/src/core/SkScaleToSides.h +++ b/src/core/SkScaleToSides.h @@ -36,27 +36,33 @@ public: // newMinRadius must be float in order to give the actual value of the radius. // The newMinRadius will always be smaller than limit. The largest that minRadius can be // is 1/2 the ratio of minRadius : (minRadius + maxRadius), therefore in the resulting - // division, minRadius can be no larger than 1/2 limit + ULP. + // division, minRadius can be no larger than 1/2 limit + ULP. The newMinRadius can be + // 1/2 a ULP off at this point. float newMinRadius = *minRadius; // Because newMaxRadius is the result of a double to float conversion, it can be larger // than limit, but only by one ULP. float newMaxRadius = (float)(limit - newMinRadius); - // If newMaxRadius forces the total over the limit, then it needs to be - // reduced by one ULP to be less than limit - newMinRadius. + // The total sum of newMinRadius and newMaxRadius can be upto 1.5 ULPs off. If the + // sum is greater than the limit then newMaxRadius may have to be reduced twice. // Note: nextafterf is a c99 call and should be std::nextafter, but this is not // implemented in the GCC ARM compiler. if (newMaxRadius + newMinRadius > limit) { newMaxRadius = nextafterf(newMaxRadius, 0.0f); + if (newMaxRadius + newMinRadius > limit) { + newMaxRadius = nextafterf(newMaxRadius, 0.0f); + } } *maxRadius = newMaxRadius; } SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g", *a, *b, limit, scale); - SkASSERTF(*a + *b <= limit, "\nlimit: %.10f, a: %.10f, b: %.10f, scale: %.20f", - limit, *a, *b, scale); + + SkASSERTF(*a + *b <= limit, + "\nlimit: %.17f, sum: %.17f, a: %.10f, b: %.10f, scale: %.20f", + limit, *a + *b, *a, *b, scale); } }; #endif // ScaleToSides_DEFINED diff --git a/tests/ScaleToSidesTest.cpp b/tests/ScaleToSidesTest.cpp index 4159ce48fd..430bb8cf81 100644 --- a/tests/ScaleToSidesTest.cpp +++ b/tests/ScaleToSidesTest.cpp @@ -12,6 +12,13 @@ DEF_TEST(ScaleToSides, reporter) { double interestingValues[] = { + // From sample app - PathFuzzer + 260.01662826538085938, + 63.61007690429687500, + 795.98901367187500000, + 217.71697616577148438, + 686.15960693359375000, + 556.57641601562500000, // From skp bitbucket 111.60000228881836, 55.800003051757813, |