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

Unified Diff: src/gpu/GrTestUtils.cpp

Issue 1108403005: Add batch unit tests for ovals (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tidy Created 5 years, 8 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
« src/gpu/GrOvalRenderer.cpp ('K') | « src/gpu/GrOvalRenderer.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 d0cea5565ce9c2c39af51b7b06ec08526980ec29..2e573ce49a9a004539240766271900844781e38d 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
@@ -30,7 +31,7 @@ const SkMatrix& TestMatrix(SkRandom* random) {
}
const SkMatrix& TestMatrixPreservesRightAngles(SkRandom* random) {
- static SkMatrix gMatrices[4];
+ static SkMatrix gMatrices[5];
static bool gOnce;
if (!gOnce) {
// identity
@@ -55,8 +56,34 @@ 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) {
+ // 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);
robertphillips 2015/04/30 14:07:32 Move this up to first line in the if-block?
+ gOnce = true;
+
+ 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) {
gRects[0] = SkRect::MakeWH(1.f, 1.f);
@@ -69,6 +96,28 @@ const SkRect& TestRect(SkRandom* random) {
}
return gRects[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRects)))];
}
+
+const SkRRect& TestRRectSimple(SkRandom* random) {
+ static SkRRect gRRect[3];
+ static bool gOnce;
+ if (!gOnce) {
+ 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
robertphillips 2015/04/30 14:07:32 // true round rect with circular corners
+ gRRect[2].setRectXY(rectangle, 1.f, 1.f);
robertphillips 2015/04/30 14:07:32 // true round rect with elliptical corners gRRect[
robertphillips 2015/04/30 14:07:32 same here ?
+ gOnce = true;
+
+ 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
« src/gpu/GrOvalRenderer.cpp ('K') | « src/gpu/GrOvalRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698