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

Unified Diff: src/core/SkScaleToSides.h

Issue 1617763003: Fix bounds of checking if a radii are too long for a side. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment. Created 4 years, 11 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 | « fuzz/FuzzScaleToSides.cpp ('k') | 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 77637a3ac2c039da4794369dab0561c810470d5c..c3fa172f672588d27c29e95436c0bc0320d05f3c 100644
--- a/src/core/SkScaleToSides.h
+++ b/src/core/SkScaleToSides.h
@@ -14,7 +14,7 @@
class ScaleToSides {
public:
- // This code assumes that a and b fit in in a float, and therefore the resulting smaller value
+ // This code assumes that a and b fit in a float, and therefore the resulting smaller value
// of a and b will fit in a float. The side of the rectangle may be larger than a float.
// Scale must be less than or equal to the ratio limit / (*a + *b).
// This code assumes that NaN and Inf are never passed in.
@@ -24,8 +24,7 @@ public:
*a = (float)((double)*a * scale);
*b = (float)((double)*b * scale);
- // This check is conservative. (double)*a + (double)*b >= (double)(*a + *b)
- if ((double)*a + (double)*b > limit) {
+ if (*a + *b > limit) {
float* minRadius = a;
float* maxRadius = b;
@@ -48,14 +47,16 @@ public:
// reduced by one ULP to be less than limit - newMinRadius.
// Note: nexttowardf is a c99 call and should be std::nexttoward, but this is not
// implemented in the ARM compiler.
- if ((double)newMaxRadius + (double)newMinRadius > limit) {
+ if (newMaxRadius + newMinRadius > limit) {
newMaxRadius = nexttowardf(newMaxRadius, 0.0);
}
*maxRadius = newMaxRadius;
}
- SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g", *a, *b);
- SkASSERTF((*a + *b) <= limit, "limit: %g, a: %g, b: %g", limit, *a, *b);
+ 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);
}
};
#endif // ScaleToSides_DEFINED
« no previous file with comments | « fuzz/FuzzScaleToSides.cpp ('k') | tests/ScaleToSidesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698