diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-17 17:36:59 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-17 17:36:59 +0000 |
commit | 2047f00e4698f83499ab91911999a65c21a951c9 (patch) | |
tree | 404b1c30d3f764fa05e3770c09fc1e43449a4d65 | |
parent | d31cbc465088a253b5574b0305e09f9301b2bf81 (diff) |
get tests closer to passing for SKIA_SCALAR=fixed
http://codereview.appspot.com/4532064/
git-svn-id: http://skia.googlecode.com/svn/trunk@1351 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gpu/src/GrPathUtils.cpp | 10 | ||||
-rw-r--r-- | include/config/SkUserConfig.h | 3 | ||||
-rw-r--r-- | src/core/SkScan_Antihair.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.cpp | 2 | ||||
-rw-r--r-- | tests/ClipStackTest.cpp | 3 | ||||
-rw-r--r-- | tests/MatrixTest.cpp | 6 | ||||
-rw-r--r-- | tests/PathTest.cpp | 22 |
7 files changed, 27 insertions, 25 deletions
diff --git a/gpu/src/GrPathUtils.cpp b/gpu/src/GrPathUtils.cpp index 69dd0e6aef..1fb043c83f 100644 --- a/gpu/src/GrPathUtils.cpp +++ b/gpu/src/GrPathUtils.cpp @@ -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); } } diff --git a/include/config/SkUserConfig.h b/include/config/SkUserConfig.h index aa2e6cf40b..c56d8cfa78 100644 --- a/include/config/SkUserConfig.h +++ b/include/config/SkUserConfig.h @@ -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 @@ -151,4 +151,3 @@ #endif #endif - diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp index b84c576c15..52f2a321aa 100644 --- a/src/core/SkScan_Antihair.cpp +++ b/src/core/SkScan_Antihair.cpp @@ -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 - - diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp index cb1c178e22..b9420eba83 100644 --- a/src/pdf/SkPDFTypes.cpp +++ b/src/pdf/SkPDFTypes.cpp @@ -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 diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index 4ef33ff35b..eafdd69052 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -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); diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index 49a98c2c2c..4125f9f243 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -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; diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index a20e431b6b..844b5934e1 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -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); } |