diff options
author | 2012-05-22 21:12:00 +0000 | |
---|---|---|
committer | 2012-05-22 21:12:00 +0000 | |
commit | af46cff4ee6099cebf3aa395805748af7d193a31 (patch) | |
tree | fbf16ce8481671edbe3f20f58e98e32d81a7539c /experimental/Intersection/SimplifyNew_Test.cpp | |
parent | 2c75681e36b33fcafc5665d7012bbd4fc6647d83 (diff) |
shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@4033 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/SimplifyNew_Test.cpp')
-rw-r--r-- | experimental/Intersection/SimplifyNew_Test.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/experimental/Intersection/SimplifyNew_Test.cpp b/experimental/Intersection/SimplifyNew_Test.cpp new file mode 100644 index 0000000000..b989ebada0 --- /dev/null +++ b/experimental/Intersection/SimplifyNew_Test.cpp @@ -0,0 +1,103 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "Simplify.h" + +namespace SimplifyNewTest { + +#include "Simplify.cpp" + +} // end of SimplifyNewTest namespace + +#include "EdgeWalker_Test.h" +#include "Intersection_Tests.h" + +static SkBitmap bitmap; + +static bool testSimplifyx(const SkPath& path, bool fill, SkPath& out, + SkBitmap& bitmap) { + if (false) { + showPath(path); + } + simplifyx(path, fill, out); + if (false) { + return true; + } + return comparePaths(path, out, bitmap, 0) == 0; +} + +static void testLine1() { + SkPath path, simple; + path.moveTo(2,0); + path.lineTo(1,1); + path.lineTo(0,0); + path.close(); + testSimplifyx(path, true, simple, bitmap); +} + +static void addInnerCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(4,1); + path.lineTo(2,1); + path.close(); +} + +static void addInnerCCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(2,1); + path.lineTo(4,1); + path.close(); +} + +static void addOuterCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(6,2); + path.lineTo(0,2); + path.close(); +} + +static void addOuterCCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(0,2); + path.lineTo(6,2); + path.close(); +} + +static void testLine2() { + SkPath path, simple; + addInnerCWTriangle(path); + addOuterCWTriangle(path); + testSimplifyx(path, true, simple, bitmap); +} + + +static void (*tests[])() = { + testLine1, + testLine2, +}; + +static const size_t testCount = sizeof(tests) / sizeof(tests[0]); + +static void (*firstTest)() = testLine2; +static bool skipAll = false; + +void SimplifyNew_Test() { + if (skipAll) { + return; + } + size_t index = 0; + if (firstTest) { + while (index < testCount && tests[index] != firstTest) { + ++index; + } + } + bool firstTestComplete = false; + for ( ; index < testCount; ++index) { + (*tests[index])(); + firstTestComplete = true; + } +} |