get tests closer to passing for SKIA_SCALAR=fixed
authorepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 17 May 2011 17:36:59 +0000 (17:36 +0000)
committerepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 17 May 2011 17:36:59 +0000 (17:36 +0000)
http://codereview.appspot.com/4532064/

git-svn-id: http://skia.googlecode.com/svn/trunk@1351 2bbb7eff-a529-9590-31e7-b0007b416f81

gpu/src/GrPathUtils.cpp
include/config/SkUserConfig.h
src/core/SkScan_Antihair.cpp
src/pdf/SkPDFTypes.cpp
tests/ClipStackTest.cpp
tests/MatrixTest.cpp
tests/PathTest.cpp

index 69dd0e6..1fb043c 100644 (file)
@@ -31,8 +31,8 @@ uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[],
         // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x)
         // points.
         // 2^(log4(x)) = sqrt(x);
-        d = ceilf(sqrtf(d/tol));
-        return GrMin(GrNextPow2((uint32_t)d), MAX_POINTS_PER_CURVE);
+        int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
+        return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
     }
 }
 
@@ -65,12 +65,12 @@ uint32_t GrPathUtils::cubicPointCount(const GrPoint points[],
                                            GrScalar tol) {
     GrScalar d = GrMax(points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]),
                        points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
-    d = sqrtf(d);
+    d = SkScalarSqrt(d);
     if (d < tol) {
         return 1;
     } else {
-        d = ceilf(sqrtf(d/tol));
-        return GrMin(GrNextPow2((uint32_t)d), MAX_POINTS_PER_CURVE);
+        int temp = SkScalarCeil(SkScalarSqrt(SkScalarDiv(d, tol)));
+        return GrMin(GrNextPow2(temp), MAX_POINTS_PER_CURVE);
     }
 }
 
index aa2e6cf..c56d8cf 100644 (file)
@@ -54,7 +54,7 @@
 
 /*  Somewhat independent of how SkScalar is implemented, Skia also wants to know
     if it can use floats at all. Naturally, if SK_SCALAR_IS_FLOAT is defined,
-    then so muse SK_CAN_USE_FLOAT, but if scalars are fixed, SK_CAN_USE_FLOAT
+    SK_CAN_USE_FLOAT must be too; but if scalars are fixed, SK_CAN_USE_FLOAT
     can go either way.
  */
 //#define SK_CAN_USE_FLOAT
 #endif
 
 #endif
-
index b84c576..52f2a32 100644 (file)
@@ -653,6 +653,8 @@ void SkScan::AntiFillRect(const SkRect& origR, const SkRegion* clip,
     }
 }
 
+#endif // SK_SCALAR_IS_FLOAT
+
 ///////////////////////////////////////////////////////////////////////////////
 
 #define SkAlphaMulRound(a, b)   SkMulDiv255Round(a, b)
@@ -811,7 +813,3 @@ void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize,
         innerstrokedot8(L, T, R, B, blitter);
     }
 }
-
-#endif
-
-
index cb1c178..b9420eb 100644 (file)
@@ -112,7 +112,7 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
 
 
 #if defined(SK_SCALAR_IS_FIXED)
-    stream->wrieScalarAsText(value);
+    stream->writeScalarAsText(value);
     return;
 #endif  // SK_SCALAR_IS_FIXED
 
index 4ef33ff..eafdd69 100644 (file)
@@ -107,7 +107,8 @@ static void TestClipStack(skiatest::Reporter* reporter) {
     // all of the above rects should have been intersected, leaving only 1 rect
     SkClipStack::B2FIter iter(stack);
     const SkClipStack::B2FIter::Clip* clip = iter.next();
-    const SkRect answer = { 25, 25, 75, 75 };
+    SkRect answer;
+    answer.iset(25, 25, 75, 75);
 
     REPORTER_ASSERT(reporter, clip);
     REPORTER_ASSERT(reporter, clip->fRect);
index 49a98c2..4125f9f 100644 (file)
@@ -2,10 +2,12 @@
 #include "SkMatrix.h"
 
 static bool nearly_equal_scalar(SkScalar a, SkScalar b) {
+    // Note that we get more compounded error for multiple operations when
+    // SK_SCALAR_IS_FIXED.
 #ifdef SK_SCALAR_IS_FLOAT
-    const float tolerance = 0.000005f;
+    const SkScalar tolerance = SK_Scalar1 / 200000;
 #else
-    const int32_t tolerance = 8;
+    const SkScalar tolerance = SK_Scalar1 / 1024;
 #endif
 
     return SkScalarAbs(a - b) <= tolerance;
index a20e431..844b593 100644 (file)
@@ -77,21 +77,23 @@ static void test_convexity2(skiatest::Reporter* reporter) {
     
     SkPath spiral;
     spiral.moveTo(0, 0);
-    spiral.lineTo(1, 0);
-    spiral.lineTo(1, 1);
-    spiral.lineTo(0, 1);
-    spiral.lineTo(0,.5);
-    spiral.lineTo(.5,.5);
-    spiral.lineTo(.5,.75);
+    spiral.lineTo(100, 0);
+    spiral.lineTo(100, 100);
+    spiral.lineTo(0, 100);
+    spiral.lineTo(0, 50);
+    spiral.lineTo(50, 50);
+    spiral.lineTo(50, 75);
     spiral.close();
     check_convexity(reporter, spiral, SkPath::kConcave_Convexity);
     
+    // TODO(reed): We evaluate this path as concave for SK_SCALAR_IS_FLOAT,
+    // but convex for SK_SCALAR_IS_FIXED.
     SkPath dent;
     dent.moveTo(0, 0);
-    dent.lineTo(1, 1);
-    dent.lineTo(0, 1);
-    dent.lineTo(-.5,2);
-    dent.lineTo(-2, 1);
+    dent.lineTo(100, 100);
+    dent.lineTo(0, 100);
+    dent.lineTo(-50, 200);
+    dent.lineTo(-200, 100);
     dent.close();
     check_convexity(reporter, dent, SkPath::kConcave_Convexity);
 }