};
SkVector fVec[ARRAY];
bool fUsePortable;
-
+
public:
NormalizeBench(void* param, bool usePortable)
: INHERITED(param)
, fUsePortable(usePortable) {
-
+
SkRandom rand;
for (int i = 0; i < ARRAY; ++i) {
fVec[i].set(rand.nextSScalar1(), rand.nextSScalar1());
}
-
+
fName = "point_normalize";
fIsRendering = false;
}
-
+
// just so the compiler doesn't remove our loops
virtual void process(int) {}
-
+
protected:
virtual void onDraw(SkCanvas*) {
int accum = 0;
-
+
for (int j = 0; j < LOOP; ++j) {
for (int i = 0; i < ARRAY; ++i) {
accum += fVec[i].normalize();
this->process(accum);
}
}
-
+
virtual const char* onGetName() {
return fName;
}
-
+
private:
const char* fName;
-
+
typedef SkBenchmark INHERITED;
};
//See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, s2));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, expectedLength));
-
+
test_Normalize(reporter, x, y);
}
static void test_overflow(skiatest::Reporter* reporter) {
SkScalar bigFloat = get_value(reporter, SkFloatToScalar(3.4e38f));
SkPoint pt = { bigFloat, bigFloat };
-
+
SkScalar length = pt.length();
// expect this to be non-finite, but dump the results if not.
if (SkScalarIsFinite(length)) {
{ SkIntToScalar(3), SkIntToScalar(4), SkIntToScalar(5) },
{ SkFloatToScalar(0.6f), SkFloatToScalar(0.8f), SK_Scalar1 },
};
-
+
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) {
test_length(reporter, gRec[i].fX, gRec[i].fY, gRec[i].fLength);
}