Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1669)

Unified Diff: src/core/SkScaleToSides.h

Issue 1717743004: Fix asserts found in SampleApp and update the tests with additional interesting numbers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove include used for debug. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/ScaleToSidesTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScaleToSides.h
diff --git a/src/core/SkScaleToSides.h b/src/core/SkScaleToSides.h
index 49201d0361b45d35aae4ac3f6dc68f66f49dc167..c70089106156f50d13596d23cfb2087bf628a529 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
« no previous file with comments | « no previous file | tests/ScaleToSidesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698