aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsExtendedTest.h
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-08 11:50:46 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-08 11:50:46 +0000
commit818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300e (patch)
tree358cf664d3979252f881a6c45c4dfa93fa75de46 /tests/PathOpsExtendedTest.h
parent9166dcb3a0e8784bea83d76ae01aa338c049ae05 (diff)
Add implementation of path ops
This CL depends on https://codereview.chromium.org/12880016/ "Add intersections for path ops" Given a path, iterate through its contour, and construct an array of segments containing its curves. Intersect each curve with every other curve, and for cubics, with itself. Given the set of intersections, find one with the smallest y and sort the curves eminating from the intersection. Assign each curve a winding value. Operate on the curves, keeping and discarding them according to the current operation and the sum of the winding values. Assemble the kept curves into an output path. Review URL: https://codereview.chromium.org/13094010 git-svn-id: http://skia.googlecode.com/svn/trunk@8553 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathOpsExtendedTest.h')
-rw-r--r--tests/PathOpsExtendedTest.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h
new file mode 100644
index 0000000000..59fb92d5b6
--- /dev/null
+++ b/tests/PathOpsExtendedTest.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef PathOpsExtendedTest_DEFINED
+#define PathOpsExtendedTest_DEFINED
+
+#include "Test.h"
+#include "SkPathOpsTypes.h"
+#include "SkBitmap.h"
+#include "SkPath.h"
+#include "SkStream.h"
+
+#ifdef SK_BUILD_FOR_WIN
+#define HARD_CODE_PTHREAD 0
+#else
+#define HARD_CODE_PTHREAD 1
+#endif
+
+#if HARD_CODE_PTHREAD
+#include <pthread.h>
+#else
+#include "SkThread.h"
+#include "../../src/utils/SkThreadUtils.h"
+#endif
+
+#if HARD_CODE_PTHREAD
+typedef void* (*ThreadFunction)(void*);
+#define THREAD_TYPE void*
+#define THREAD_RETURN return NULL;
+#else
+typedef void (*ThreadFunction)(void*);
+#define THREAD_TYPE void
+#define THREAD_RETURN
+#endif
+
+struct State4;
+
+struct TestDesc {
+ void (*fun)(skiatest::Reporter*);
+ const char* str;
+};
+
+extern bool gShowTestProgress;
+extern bool gAllowExtendedTest;
+
+//extern int comparePaths(const SkPath& one, const SkPath& two);
+extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap);
+extern bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths);
+extern void showOp(const SkPathOp op);
+extern void showPath(const SkPath& path, const char* str);
+extern void showPath(const SkPath& path);
+extern void showPathData(const SkPath& path);
+extern bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
+ const SkPathOp );
+extern bool testSimplify(SkPath& path, bool useXor, SkPath& out,
+ State4& state, const char* pathStr);
+extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path);
+
+struct State4 {
+ State4();
+#if HARD_CODE_PTHREAD
+ static pthread_mutex_t addQueue;
+ static pthread_cond_t checkQueue;
+ pthread_cond_t initialized;
+ pthread_t threadID;
+#else
+ SkThread* thread;
+#endif
+ static State4* queue;
+ int index;
+ bool done;
+ bool last;
+ int a;
+ int b;
+ int c;
+ int d; // sometimes 1 if abc_is_a_triangle
+ int testsRun;
+ char filename[256];
+ skiatest::Reporter* reporter;
+ SkBitmap bitmap;
+ mutable SkDynamicMemoryWStream ramStream;
+};
+
+void createThread(State4* statePtr, void* (*test)(void* ));
+int dispatchTest4(ThreadFunction testFun, int a, int b, int c, int d);
+void initializeTests(skiatest::Reporter* reporter, const char* testName, size_t testNameSize);
+void outputProgress(const State4& state, const char* pathStr, SkPath::FillType );
+void outputProgress(const State4& state, const char* pathStr, SkPathOp op);
+void outputToStream(const State4& state, const char* pathStr, const char* pathPrefix,
+ const char* nameSuffix,
+ const char* testFunction, SkWStream& outFile);
+bool runNextTestSet(State4& state);
+int waitForCompletion();
+
+void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
+ void (*firstTest)(skiatest::Reporter* ),
+ void (*stopTest)(skiatest::Reporter* ), bool reverse);
+
+#endif