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
This commit is contained in:
epoger@google.com 2011-05-17 17:36:59 +00:00
Родитель d31cbc4650
Коммит 2047f00e46
7 изменённых файлов: 27 добавлений и 25 удалений

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}