Index: src/gpu/GrTestUtils.cpp |
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp |
index 163fb56389ef1f6c308adc794d97bf8c6e41a7a3..0bb4044eaaf1299a1ecb99e74c270b4397b7b9d2 100644 |
--- a/src/gpu/GrTestUtils.cpp |
+++ b/src/gpu/GrTestUtils.cpp |
@@ -12,9 +12,9 @@ |
#ifdef GR_TEST_UTILS |
-namespace GrTest { |
-const SkMatrix& TestMatrix(SkRandom* random) { |
+static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) { |
static SkMatrix gMatrices[5]; |
+ static const int kPerspectiveCount = 1; |
static bool gOnce; |
if (!gOnce) { |
gOnce = true; |
@@ -24,13 +24,24 @@ const SkMatrix& TestMatrix(SkRandom* random) { |
gMatrices[3].setRotate(SkIntToScalar(185)); |
gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); |
gMatrices[3].postScale(SkIntToScalar(2), SK_ScalarHalf); |
+ |
+ // Perspective matrices |
gMatrices[4].setRotate(SkIntToScalar(215)); |
gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); |
gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); |
} |
- return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
+ |
+ uint32_t count = static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)); |
+ if (includePerspective) { |
+ return gMatrices[random->nextULessThan(count)]; |
+ } else { |
+ return gMatrices[random->nextULessThan(count - kPerspectiveCount)]; |
+ } |
} |
+namespace GrTest { |
+const SkMatrix& TestMatrix(SkRandom* random) { return test_matrix(random, true); } |
+ |
const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) { |
static SkMatrix gMatrices[5]; |
static bool gOnce; |
@@ -83,6 +94,8 @@ const SkMatrix& TestMatrixRectStaysRect(SkRandom* random) { |
return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
} |
+const SkMatrix& TestMatrixInvertible(SkRandom* random) { return test_matrix(random, false); } |
+ |
const SkRect& TestRect(SkRandom* random) { |
static SkRect gRects[7]; |
static bool gOnce; |