aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTestUtils.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-05-07 13:06:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-07 13:06:42 -0700
commit2fbd4068bde6a9fb50341c0bdfbb8bf18b70d015 (patch)
tree66315ce7a175ec4d25fd89f21ea2e7cdd97f5931 /src/gpu/GrTestUtils.cpp
parent96287f7af7ff6aaa48b8d28ec6b7b79836da2d7c (diff)
tesselating path renderer unit tests
Diffstat (limited to 'src/gpu/GrTestUtils.cpp')
-rw-r--r--src/gpu/GrTestUtils.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 163fb56389..0bb4044eaa 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;