Change random number generator for 'tests' to SkMWCRandom. Also removes some
unused headers and fixes a couple of bugs exposed by changing the random
number generator:
First, the function SkMatrix::getMaxStretch() had an error where it was testing
the square of a number against near-zero. This led to it occasionally taking a
cheaper but imprecise path for computing the eigenvalues of the matrix. It's
been replaced with a check against the square of SK_ScalarNearlyZero.
The second case was a failure in ClipStackTest, where it hit the rare case of
a practically empty clip stack (it has a single Union) and we set a tight
bounds. The bounds rect doesn't get set by GrReducedClip::ReduceClipStack() in
this case, so when it clips the reduced stack it's clipping against garbage,
and the resulting regions don't match. The solution is to initialize the
tightBounds rect.
git-svn-id: http://skia.googlecode.com/svn/trunk@7952 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index 5c1d4e1..4c4ee60 100644
--- a/tests/AAClipTest.cpp
+++ b/tests/AAClipTest.cpp
@@ -87,7 +87,7 @@
canvas.drawColor(SK_ColorBLACK);
}
-static SkIRect rand_rect(SkRandom& rand, int n) {
+static SkIRect rand_rect(SkMWCRandom& rand, int n) {
int x = rand.nextS() % n;
int y = rand.nextS() % n;
int w = rand.nextU() % n;
@@ -95,7 +95,7 @@
return SkIRect::MakeXYWH(x, y, w, h);
}
-static void make_rand_rgn(SkRegion* rgn, SkRandom& rand) {
+static void make_rand_rgn(SkRegion* rgn, SkMWCRandom& rand) {
int count = rand.nextU() % 20;
for (int i = 0; i < count; ++i) {
rgn->op(rand_rect(rand, 100), SkRegion::kXOR_Op);
@@ -128,7 +128,7 @@
// aaclip.setRegion should create idential masks to the region
static void test_rgn(skiatest::Reporter* reporter) {
- SkRandom rand;
+ SkMWCRandom rand;
for (int i = 0; i < 1000; i++) {
SkRegion rgn;
make_rand_rgn(&rgn, rand);
@@ -232,7 +232,7 @@
REPORTER_ASSERT(reporter, mask.fBounds.isEmpty());
}
-static void rand_irect(SkIRect* r, int N, SkRandom& rand) {
+static void rand_irect(SkIRect* r, int N, SkMWCRandom& rand) {
r->setXYWH(0, 0, rand.nextU() % N, rand.nextU() % N);
int dx = rand.nextU() % (2*N);
int dy = rand.nextU() % (2*N);
@@ -241,7 +241,7 @@
}
static void test_irect(skiatest::Reporter* reporter) {
- SkRandom rand;
+ SkMWCRandom rand;
for (int i = 0; i < 10000; i++) {
SkAAClip clip0, clip1;