diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-17 16:44:46 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-17 16:44:46 +0000 |
commit | 8f4d2306fa866a26f9448048ff63f692b2ba43aa (patch) | |
tree | 7a48d817cb5220f87e81781320b002eead2495a0 /tests | |
parent | a34b638b909f58dd7c66546a0f49923112f7f785 (diff) |
remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats
To keep the CL (slightly) managable, this does not make any changes to
existing macros (e.g. SkScalarMul). Just tackling #ifdef constructs this
time around.
BUG=
R=bsalomon@google.com, caryclark@google.com
Review URL: https://codereview.chromium.org/117053002
git-svn-id: http://skia.googlecode.com/svn/trunk@12712 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/DrawBitmapRectTest.cpp | 2 | ||||
-rw-r--r-- | tests/DrawPathTest.cpp | 8 | ||||
-rw-r--r-- | tests/InfRectTest.cpp | 7 | ||||
-rw-r--r-- | tests/MathTest.cpp | 37 | ||||
-rw-r--r-- | tests/Matrix44Test.cpp | 7 | ||||
-rw-r--r-- | tests/MatrixTest.cpp | 27 | ||||
-rw-r--r-- | tests/PDFPrimitivesTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathMeasureTest.cpp | 6 | ||||
-rw-r--r-- | tests/PathTest.cpp | 2 | ||||
-rw-r--r-- | tests/ScalarTest.cpp | 2 | ||||
-rw-r--r-- | tests/StringTest.cpp | 2 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 2 | ||||
-rw-r--r-- | tests/skia_test.cpp | 5 |
13 files changed, 1 insertions, 108 deletions
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp index f2e4837c63..c8718489c4 100644 --- a/tests/DrawBitmapRectTest.cpp +++ b/tests/DrawBitmapRectTest.cpp @@ -241,7 +241,6 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter, * memory allocation limit). */ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { -#ifdef SK_SCALAR_IS_FLOAT static const struct { int fWidth; int fHeight; @@ -258,7 +257,6 @@ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { gTests[i].fWidth, gTests[i].fHeight, gTests[i].fExpectedToDraw); } -#endif } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp index 9a49adfff4..8c77ffe031 100644 --- a/tests/DrawPathTest.cpp +++ b/tests/DrawPathTest.cpp @@ -181,7 +181,6 @@ static void test_inversepathwithclip() { } static void test_bug533() { -#ifdef SK_SCALAR_IS_FLOAT /* http://code.google.com/p/skia/issues/detail?id=533 This particular test/bug only applies to the float case, where the @@ -196,7 +195,6 @@ static void test_bug533() { SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); canvas.get()->drawPath(path, paint); -#endif } static void test_crbug_140642() { @@ -215,14 +213,11 @@ static void test_crbug_140642() { stroke-dashoffset="-248.135982067"> */ -#ifdef SK_SCALAR_IS_FLOAT const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; SkDashPathEffect dontAssert(vals, 4, -248.135982067f); -#endif } static void test_crbug_124652() { -#ifdef SK_SCALAR_IS_FLOAT /* http://code.google.com/p/chromium/issues/detail?id=124652 This particular test/bug only applies to the float case, where @@ -231,11 +226,9 @@ static void test_crbug_124652() { SkScalar intervals[2] = {837099584, 33450}; SkAutoTUnref<SkDashPathEffect> dash( new SkDashPathEffect(intervals, 2, -10, false)); -#endif } static void test_bigcubic() { -#ifdef SK_SCALAR_IS_FLOAT SkPath path; path.moveTo(64, 3); path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); @@ -245,7 +238,6 @@ static void test_bigcubic() { SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); canvas.get()->drawPath(path, paint); -#endif } // we used to assert if the bounds of the device (clip) was larger than 32K diff --git a/tests/InfRectTest.cpp b/tests/InfRectTest.cpp index 3d964bdccf..674cf5b802 100644 --- a/tests/InfRectTest.cpp +++ b/tests/InfRectTest.cpp @@ -10,11 +10,9 @@ #include "SkRandom.h" #include "SkRect.h" -#ifdef SK_SCALAR_IS_FLOAT static float make_zero() { return sk_float_sin(0); } -#endif struct RectCenter { SkIRect fRect; @@ -59,14 +57,9 @@ static void check_invalid(skiatest::Reporter* reporter, // Tests that isFinite() will reject any rect with +/-inf values // as one of its coordinates. DEF_TEST(InfRect, reporter) { -#ifdef SK_SCALAR_IS_FLOAT float inf = 1 / make_zero(); // infinity float nan = inf * 0; SkASSERT(!(nan == nan)); -#else - SkFixed inf = SK_FixedNaN; - SkFixed nan = SK_FixedNaN; -#endif SkScalar small = SkIntToScalar(10); SkScalar big = SkIntToScalar(100); diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index 22680c13e6..d6649542c2 100644 --- a/tests/MathTest.cpp +++ b/tests/MathTest.cpp @@ -328,14 +328,11 @@ static void unittest_fastfloat(skiatest::Reporter* reporter) { } } -#ifdef SK_SCALAR_IS_FLOAT static float make_zero() { return sk_float_sin(0); } -#endif static void unittest_isfinite(skiatest::Reporter* reporter) { -#ifdef SK_SCALAR_IS_FLOAT float nan = sk_float_asin(2); float inf = 1.0f / make_zero(); float big = 3.40282e+038f; @@ -344,10 +341,6 @@ static void unittest_isfinite(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, !SkScalarIsNaN(-inf)); REPORTER_ASSERT(reporter, !SkScalarIsFinite(inf)); REPORTER_ASSERT(reporter, !SkScalarIsFinite(-inf)); -#else - SkFixed nan = SK_FixedNaN; - SkFixed big = SK_FixedMax; -#endif REPORTER_ASSERT(reporter, SkScalarIsNaN(nan)); REPORTER_ASSERT(reporter, !SkScalarIsNaN(big)); @@ -607,37 +600,7 @@ DEF_TEST(Math, reporter) { REPORTER_ASSERT(reporter, xr == check || xr == check-1); } -#if !defined(SK_SCALAR_IS_FLOAT) - { - SkFixed s, c; - s = SkFixedSinCos(0, &c); - REPORTER_ASSERT(reporter, s == 0); - REPORTER_ASSERT(reporter, c == SK_Fixed1); - } - - int maxDiff = 0; - for (i = 0; i < 1000; i++) { - SkFixed rads = rand.nextS() >> 10; - double frads = SkFixedToFloat(rads); - - SkFixed s, c; - s = SkScalarSinCos(rads, &c); - - double fs = sin(frads); - double fc = cos(frads); - - SkFixed is = SkFloatToFixed(fs); - SkFixed ic = SkFloatToFixed(fc); - - maxDiff = SkMax32(maxDiff, SkAbs32(is - s)); - maxDiff = SkMax32(maxDiff, SkAbs32(ic - c)); - } - SkDebugf("SinCos: maximum error = %d\n", maxDiff); -#endif - -#ifdef SK_SCALAR_IS_FLOAT test_blend(reporter); -#endif if (false) test_floor(reporter); diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index afd2762a7a..8fd84d858c 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -24,14 +24,7 @@ static bool nearly_equal_mscalar(SkMScalar a, SkMScalar b) { } 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 SkScalar tolerance = SK_Scalar1 / 200000; -#else - const SkScalar tolerance = SK_Scalar1 / 1024; -#endif - return SkScalarAbs(a - b) <= tolerance; } diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index a6d4edabc0..d0fff54c95 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -13,14 +13,7 @@ #include "SkRandom.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 SkScalar tolerance = SK_Scalar1 / 200000; -#else - const SkScalar tolerance = SK_Scalar1 / 1024; -#endif - return SkScalarAbs(a - b) <= tolerance; } @@ -40,7 +33,6 @@ static bool are_equal(skiatest::Reporter* reporter, bool equal = a == b; bool cheapEqual = a.cheapEqualTo(b); if (equal != cheapEqual) { -#ifdef SK_SCALAR_IS_FLOAT if (equal) { bool foundZeroSignDiff = false; for (int i = 0; i < 9; ++i) { @@ -70,9 +62,6 @@ static bool are_equal(skiatest::Reporter* reporter, } REPORTER_ASSERT(reporter, foundNaN); } -#else - REPORTER_ASSERT(reporter, false); -#endif } return equal; } @@ -299,16 +288,6 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) { mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2)); REPORTER_ASSERT(reporter, !mat.isSimilarity()); -#ifdef SK_SCALAR_IS_FLOAT - /* We bypass the following tests for SK_SCALAR_IS_FIXED build. - * The long discussion can be found in this issue: - * http://codereview.appspot.com/5999050/ - * In short, we haven't found a perfect way to fix the precision - * issue, i.e. the way we use tolerance in isSimilarityTransformation - * is incorrect. The situation becomes worse in fixed build, so - * we disabled rotation related tests for fixed build. - */ - // rotate for (int angle = 0; angle < 360; ++angle) { mat.reset(); @@ -340,7 +319,6 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) { mat.setRotate(SkIntToScalar(30)); mat.postScale(SkIntToScalar(3), SkIntToScalar(2)); REPORTER_ASSERT(reporter, !mat.isSimilarity()); -#endif // all zero mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0); @@ -800,12 +778,7 @@ DEF_TEST(Matrix, reporter) { mat.reset(); mat.set(SkMatrix::kMSkewX, SK_ScalarNaN); mat2.set(SkMatrix::kMSkewX, SK_ScalarNaN); - // fixed pt doesn't have the property that NaN does not equal itself. -#ifdef SK_SCALAR_IS_FIXED - REPORTER_ASSERT(reporter, are_equal(reporter, mat, mat2)); -#else REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2)); -#endif test_matrix_min_max_stretch(reporter); test_matrix_is_similarity(reporter); diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index 9b9569d367..5f0750d77a 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -353,7 +353,6 @@ DEF_TEST(PDFPrimitives, reporter) { SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf)); SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5"); -#if defined(SK_SCALAR_IS_FLOAT) SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f)); #if !defined(SK_ALLOW_LARGE_PDF_SCALARS) SimpleCheckObjectOutput(reporter, bigScalar.get(), "111000"); @@ -366,7 +365,6 @@ DEF_TEST(PDFPrimitives, reporter) { SkAutoTUnref<SkPDFScalar> smallestScalar(new SkPDFScalar(1.0/65536)); SimpleCheckObjectOutput(reporter, smallestScalar.get(), "0.00001526"); #endif -#endif SkAutoTUnref<SkPDFString> stringSimple( new SkPDFString("test ) string ( foo")); diff --git a/tests/PathMeasureTest.cpp b/tests/PathMeasureTest.cpp index 5c92ca1686..2d7b64ec36 100644 --- a/tests/PathMeasureTest.cpp +++ b/tests/PathMeasureTest.cpp @@ -10,7 +10,6 @@ #include "SkPathMeasure.h" static void test_small_segment3() { -#ifdef SK_SCALAR_IS_FLOAT SkPath path; const SkPoint pts[] = { { 0, 0 }, @@ -25,11 +24,9 @@ static void test_small_segment3() { SkPathMeasure meas(path, false); meas.getLength(); -#endif } static void test_small_segment2() { -#ifdef SK_SCALAR_IS_FLOAT SkPath path; const SkPoint pts[] = { { 0, 0 }, @@ -43,11 +40,9 @@ static void test_small_segment2() { } SkPathMeasure meas(path, false); meas.getLength(); -#endif } static void test_small_segment() { -#ifdef SK_SCALAR_IS_FLOAT SkPath path; const SkPoint pts[] = { { 100000, 100000}, @@ -77,7 +72,6 @@ static void test_small_segment() { because distance >>> d. */ meas.getLength(); -#endif } DEF_TEST(PathMeasure, reporter) { diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index b33ef97eae..3f07ae04bc 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -830,7 +830,6 @@ static void test_direction(skiatest::Reporter* reporter) { path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction); check_direction(reporter, path, SkPath::kCCW_Direction); -#ifdef SK_SCALAR_IS_FLOAT // triangle with one point really far from the origin. path.reset(); // the first point is roughly 1.05e10, 1.05e10 @@ -838,7 +837,6 @@ static void test_direction(skiatest::Reporter* reporter) { path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); check_direction(reporter, path, SkPath::kCCW_Direction); -#endif path.reset(); path.conicTo(20, 0, 20, 20, 0.5f); diff --git a/tests/ScalarTest.cpp b/tests/ScalarTest.cpp index 47d3226343..eb52b8adf3 100644 --- a/tests/ScalarTest.cpp +++ b/tests/ScalarTest.cpp @@ -20,7 +20,6 @@ struct PointSet { }; static void test_isRectFinite(skiatest::Reporter* reporter) { -#ifdef SK_SCALAR_IS_FLOAT static const SkPoint gF0[] = { { 0, 0 }, { 1, 1 } }; @@ -61,7 +60,6 @@ static void test_isRectFinite(skiatest::Reporter* reporter) { bool rectIsFinite = !r.isEmpty(); REPORTER_ASSERT(reporter, gSets[i].fIsFinite == rectIsFinite); } -#endif } static bool isFinite_int(float x) { diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp index 04e04704ab..ceb4df5308 100644 --- a/tests/StringTest.cpp +++ b/tests/StringTest.cpp @@ -157,7 +157,6 @@ DEF_TEST(String, reporter) { { SK_Scalar1, "1" }, { -SK_Scalar1, "-1" }, { SK_Scalar1/2, "0.5" }, -#ifdef SK_SCALAR_IS_FLOAT #ifdef SK_BUILD_FOR_WIN { 3.4028234e38f, "3.4028235e+038" }, { -3.4028234e38f, "-3.4028235e+038" }, @@ -165,7 +164,6 @@ DEF_TEST(String, reporter) { { 3.4028234e38f, "3.4028235e+38" }, { -3.4028234e38f, "-3.4028235e+38" }, #endif -#endif }; for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { a.reset(); diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index 95cae6a8c8..c7f77a7fb2 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -297,7 +297,7 @@ struct CanvasConfig { static const CanvasConfig gCanvasConfigs[] = { {kRaster_DevType, true}, {kRaster_DevType, false}, -#if SK_SUPPORT_GPU && defined(SK_SCALAR_IS_FLOAT) +#if SK_SUPPORT_GPU {kGpu_BottomLeft_DevType, true}, // row bytes has no meaning on gpu devices {kGpu_TopLeft_DevType, true}, // row bytes has no meaning on gpu devices #endif diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index 3d2955975e..a1d4bf799b 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -196,11 +196,6 @@ int tool_main(int argc, char** argv) { #else header.append(" SK_RELEASE"); #endif -#ifdef SK_SCALAR_IS_FIXED - header.append(" SK_SCALAR_IS_FIXED"); -#else - header.append(" SK_SCALAR_IS_FLOAT"); -#endif header.appendf(" skia_arch_width=%d", (int)sizeof(void*) * 8); SkDebugf("%s\n", header.c_str()); } |