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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/ScaleToSidesTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 float* maxRadius = b; 29 float* maxRadius = b;
30 30
31 // Force minRadius to be the smaller of the two. 31 // Force minRadius to be the smaller of the two.
32 if (*minRadius > *maxRadius) { 32 if (*minRadius > *maxRadius) {
33 SkTSwap(minRadius, maxRadius); 33 SkTSwap(minRadius, maxRadius);
34 } 34 }
35 35
36 // newMinRadius must be float in order to give the actual value of t he radius. 36 // newMinRadius must be float in order to give the actual value of t he radius.
37 // The newMinRadius will always be smaller than limit. The largest t hat minRadius can be 37 // The newMinRadius will always be smaller than limit. The largest t hat minRadius can be
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. The ne wMinRadius can be
40 // 1/2 a ULP off at this point.
40 float newMinRadius = *minRadius; 41 float newMinRadius = *minRadius;
41 42
42 // Because newMaxRadius is the result of a double to float conversio n, it can be larger 43 // Because newMaxRadius is the result of a double to float conversio n, it can be larger
43 // than limit, but only by one ULP. 44 // than limit, but only by one ULP.
44 float newMaxRadius = (float)(limit - newMinRadius); 45 float newMaxRadius = (float)(limit - newMinRadius);
45 46
46 // If newMaxRadius forces the total over the limit, then it needs to be 47 // The total sum of newMinRadius and newMaxRadius can be upto 1.5 UL Ps off. If the
47 // reduced by one ULP to be less than limit - newMinRadius. 48 // sum is greater than the limit then newMaxRadius may have to be re duced twice.
48 // Note: nextafterf is a c99 call and should be std::nextafter, but this is not 49 // Note: nextafterf is a c99 call and should be std::nextafter, but this is not
49 // implemented in the GCC ARM compiler. 50 // implemented in the GCC ARM compiler.
50 if (newMaxRadius + newMinRadius > limit) { 51 if (newMaxRadius + newMinRadius > limit) {
51 newMaxRadius = nextafterf(newMaxRadius, 0.0f); 52 newMaxRadius = nextafterf(newMaxRadius, 0.0f);
53 if (newMaxRadius + newMinRadius > limit) {
54 newMaxRadius = nextafterf(newMaxRadius, 0.0f);
55 }
52 } 56 }
53 *maxRadius = newMaxRadius; 57 *maxRadius = newMaxRadius;
54 } 58 }
55 59
56 SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g" , *a, *b, limit, 60 SkASSERTF(*a >= 0.0f && *b >= 0.0f, "a: %g, b: %g, limit: %g, scale: %g" , *a, *b, limit,
57 scale); 61 scale);
58 SkASSERTF(*a + *b <= limit, "\nlimit: %.10f, a: %.10f, b: %.10f, scale: %.20f", 62
59 limit, *a, *b, scale); 63 SkASSERTF(*a + *b <= limit,
64 "\nlimit: %.17f, sum: %.17f, a: %.10f, b: %.10f, scale: %.20f" ,
65 limit, *a + *b, *a, *b, scale);
60 } 66 }
61 }; 67 };
62 #endif // ScaleToSides_DEFINED 68 #endif // ScaleToSides_DEFINED
OLDNEW
« 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