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

Unified Diff: trunk/tests/PointTest.cpp

Issue 14884011: by hook or by crook, force gcc to return the value of SkPoint::length() to actually be a float (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/tests/PointTest.cpp
===================================================================
--- trunk/tests/PointTest.cpp (revision 9012)
+++ trunk/tests/PointTest.cpp (working copy)
@@ -61,6 +61,26 @@
return reporter ? value : 0;
}
robertphillips 2013/05/06 15:42:23 propagate
+// On linux gcc, 32bit, we are seeing the compiler propogate up the value
+// of SkPoint::length() as a double (which we use sometimes to avoid overflow
+// during the computation), even though the signature says float (SkScalar).
+//
robertphillips 2013/05/06 15:42:23 rm "must"?
+// force_as_float is must meant to capture our latest technique (horrible as
+// it is) to force the value to be a float, so we can test whether it was
+// finite or not.
+static float force_as_float(skiatest::Reporter* reporter, float value) {
+ uint32_t storage;
+ memcpy(&storage, &value, 4);
+ // even the pair of memcpy calls are not sufficient, since those seem to
+ // be no-op'd, so we add a runtime tests (just like get_value) to force
+ // the compiler to give us an actual float.
+ if (NULL == reporter) {
+ storage = ~storage;
+ }
+ memcpy(&value, &storage, 4);
+ return value;
+}
+
// test that we handle very large values correctly. i.e. that we can
// successfully normalize something whose mag overflows a float.
static void test_overflow(skiatest::Reporter* reporter) {
@@ -68,6 +88,8 @@
SkPoint pt = { bigFloat, bigFloat };
SkScalar length = pt.length();
+ length = force_as_float(reporter, length);
+
// expect this to be non-finite, but dump the results if not.
if (SkScalarIsFinite(length)) {
SkDebugf("length(%g, %g) == %g\n", pt.fX, pt.fY, length);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698