// 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);
}
}
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);
}
}
/* 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
-
}
}
+#endif // SK_SCALAR_IS_FLOAT
+
///////////////////////////////////////////////////////////////////////////////
#define SkAlphaMulRound(a, b) SkMulDiv255Round(a, b)
innerstrokedot8(L, T, R, B, blitter);
}
}
-
-#endif
-
-
#if defined(SK_SCALAR_IS_FIXED)
- stream->wrieScalarAsText(value);
+ stream->writeScalarAsText(value);
return;
#endif // SK_SCALAR_IS_FIXED
// 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);
#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;
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);
}