Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1039)

Unified Diff: src/gpu/GrTestUtils.cpp

Issue 1127183006: tesselating path renderer unit tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698