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

Unified Diff: tests/PathOpsTestCommon.cpp

Issue 19374003: harden and speed up path op unit tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename threaded to single Created 7 years, 5 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 | « tests/PathOpsTestCommon.h ('k') | tests/Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsTestCommon.cpp
diff --git a/tests/PathOpsTestCommon.cpp b/tests/PathOpsTestCommon.cpp
index 4356b42414774c327751f33228072a6883476f9f..dd9b34761826bab12db19a45167ab7d4f358ed79 100644
--- a/tests/PathOpsTestCommon.cpp
+++ b/tests/PathOpsTestCommon.cpp
@@ -5,7 +5,11 @@
* found in the LICENSE file.
*/
#include "PathOpsTestCommon.h"
+#include "SkPathOpsBounds.h"
#include "SkPathOpsCubic.h"
+#include "SkPathOpsLine.h"
+#include "SkPathOpsQuad.h"
+#include "SkPathOpsTriangle.h"
void CubicToQuads(const SkDCubic& cubic, double precision, SkTArray<SkDQuad, true>& quads) {
SkTArray<double, true> ts;
@@ -24,3 +28,82 @@ void CubicToQuads(const SkDCubic& cubic, double precision, SkTArray<SkDQuad, tru
tStart = tEnd;
}
}
+
+static bool SkDoubleIsNaN(double x) {
+ return x != x;
+}
+
+bool ValidBounds(const SkPathOpsBounds& bounds) {
+ if (SkScalarIsNaN(bounds.fLeft)) {
+ return false;
+ }
+ if (SkScalarIsNaN(bounds.fTop)) {
+ return false;
+ }
+ if (SkScalarIsNaN(bounds.fRight)) {
+ return false;
+ }
+ return !SkScalarIsNaN(bounds.fBottom);
+}
+
+bool ValidCubic(const SkDCubic& cubic) {
+ for (int index = 0; index < 4; ++index) {
+ if (!ValidPoint(cubic[index])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ValidLine(const SkDLine& line) {
+ for (int index = 0; index < 2; ++index) {
+ if (!ValidPoint(line[index])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ValidPoint(const SkDPoint& pt) {
+ if (SkDoubleIsNaN(pt.fX)) {
+ return false;
+ }
+ return !SkDoubleIsNaN(pt.fY);
+}
+
+bool ValidPoints(const SkPoint* pts, int count) {
+ for (int index = 0; index < count; ++index) {
+ if (SkScalarIsNaN(pts[index].fX)) {
+ return false;
+ }
+ if (SkScalarIsNaN(pts[index].fY)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ValidQuad(const SkDQuad& quad) {
+ for (int index = 0; index < 3; ++index) {
+ if (!ValidPoint(quad[index])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ValidTriangle(const SkDTriangle& triangle) {
+ for (int index = 0; index < 3; ++index) {
+ if (!ValidPoint(triangle.fPts[index])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ValidVector(const SkDVector& v) {
+ if (SkDoubleIsNaN(v.fX)) {
+ return false;
+ }
+ return !SkDoubleIsNaN(v.fY);
+}
« no previous file with comments | « tests/PathOpsTestCommon.h ('k') | tests/Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698