Index: src/gpu/GrTestUtils.cpp |
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp |
index d0cea5565ce9c2c39af51b7b06ec08526980ec29..36256c31736b5e8b159e5b7537f2f4b184a01f9d 100644 |
--- a/src/gpu/GrTestUtils.cpp |
+++ b/src/gpu/GrTestUtils.cpp |
@@ -7,6 +7,7 @@ |
#include "GrTestUtils.h" |
#include "SkMatrix.h" |
+#include "SkRRect.h" |
#ifdef GR_TEST_UTILS |
@@ -15,6 +16,7 @@ const SkMatrix& TestMatrix(SkRandom* random) { |
static SkMatrix gMatrices[5]; |
static bool gOnce; |
if (!gOnce) { |
+ gOnce = true; |
gMatrices[0].reset(); |
gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); |
gMatrices[2].setRotate(SkIntToScalar(17)); |
@@ -24,15 +26,15 @@ const SkMatrix& TestMatrix(SkRandom* random) { |
gMatrices[4].setRotate(SkIntToScalar(215)); |
gMatrices[4].set(SkMatrix::kMPersp0, 0.00013f); |
gMatrices[4].set(SkMatrix::kMPersp1, -0.000039f); |
- gOnce = true; |
} |
return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
} |
const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) { |
- static SkMatrix gMatrices[4]; |
+ static SkMatrix gMatrices[5]; |
static bool gOnce; |
if (!gOnce) { |
+ gOnce = true; |
// identity |
gMatrices[0].reset(); |
// translation |
@@ -46,7 +48,6 @@ const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) { |
gMatrices[4].reset(); |
gMatrices[4].setScale(SkIntToScalar(-1), SkIntToScalar(-1)); |
gMatrices[4].setRotate(47); |
- gOnce = true; |
for (size_t i = 0; i < SK_ARRAY_COUNT(gMatrices); i++) { |
SkASSERT(gMatrices[i].preservesRightAngles()); |
@@ -55,20 +56,70 @@ const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) { |
return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
} |
+const SkMatrix& TestMatrixRectStaysRect(SkRandom* random) { |
+ static SkMatrix gMatrices[6]; |
+ static bool gOnce; |
+ if (!gOnce) { |
+ gOnce = true; |
+ // identity |
+ gMatrices[0].reset(); |
+ // translation |
+ gMatrices[1].setTranslate(SkIntToScalar(-100), SkIntToScalar(100)); |
+ // scale |
+ gMatrices[2].setScale(SkIntToScalar(17), SkIntToScalar(17)); |
+ // scale + translation |
+ gMatrices[3].setScale(SkIntToScalar(-17), SkIntToScalar(-17)); |
+ gMatrices[3].postTranslate(SkIntToScalar(66), SkIntToScalar(-33)); |
+ // reflection |
+ gMatrices[4].setScale(SkIntToScalar(-1), SkIntToScalar(-1)); |
+ // 90 degress rotation |
+ gMatrices[5].setRotate(90); |
+ |
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gMatrices); i++) { |
+ SkASSERT(gMatrices[i].rectStaysRect()); |
+ } |
+ } |
+ return gMatrices[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gMatrices)))]; |
+} |
+ |
const SkRect& TestRect(SkRandom* random) { |
- static SkRect gRects[1]; |
+ static SkRect gRects[7]; |
static bool gOnce; |
if (!gOnce) { |
+ gOnce = true; |
gRects[0] = SkRect::MakeWH(1.f, 1.f); |
gRects[1] = SkRect::MakeWH(1.0f, 256.0f); |
gRects[2] = SkRect::MakeWH(256.0f, 1.0f); |
gRects[4] = SkRect::MakeLargest(); |
gRects[5] = SkRect::MakeLTRB(-65535.0f, -65535.0f, 65535.0f, 65535.0f); |
gRects[6] = SkRect::MakeLTRB(10.0f, 10.0f, -10.0f, -10.0f); |
- gOnce = true; |
} |
return gRects[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRects)))]; |
} |
+ |
+const SkRRect& TestRRectSimple(SkRandom* random) { |
+ static SkRRect gRRect[4]; |
+ static bool gOnce; |
+ if (!gOnce) { |
+ gOnce = true; |
+ SkRect square = SkRect::MakeWH(10.f, 10.f); |
+ SkRect rectangle = SkRect::MakeWH(10.f, 20.f); |
+ // rect |
+ gRRect[0].setRect(square); |
+ // oval |
+ gRRect[1].setOval(rectangle); |
+ // true round rect with circular corners |
+ gRRect[2].setRectXY(rectangle, 1.f, 1.f); |
+ // true round rect with elliptical corners |
+ gRRect[3].setRectXY(rectangle, 2.0f, 1.0f); |
+ |
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gRRect); i++) { |
+ SkASSERT(gRRect[i].isSimple()); |
+ } |
+ } |
+ return gRRect[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRRect)))]; |
+} |
+ |
}; |
#endif |