blob: 80527f9e5e4d36416479f4388db2225e63ddd7be [file] [log] [blame]
caryclark@google.com818b0cc2013-04-08 11:50:46 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "PathOpsExtendedTest.h"
8
9static THREAD_TYPE testOpCubicsMain(void* data)
10{
11 SkASSERT(data);
12 State4& state = *(State4*) data;
13 char pathStr[1024]; // gdb: set print elements 400
14 sk_bzero(pathStr, sizeof(pathStr));
15 do {
16 for (int a = 0 ; a < 6; ++a) {
17 for (int b = a + 1 ; b < 7; ++b) {
18 for (int c = 0 ; c < 6; ++c) {
19 for (int d = c + 1 ; d < 7; ++d) {
20 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
21 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
22 SkPath pathA, pathB;
23 char* str = pathStr;
24 pathA.setFillType((SkPath::FillType) e);
25 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
26 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
27 ? "EvenOdd" : "?UNDEFINED");
28 pathA.moveTo(SkIntToScalar(state.a), SkIntToScalar(state.b));
29 str += sprintf(str, " path.moveTo(%d,%d);\n", state.a, state.b);
30 pathA.cubicTo(SkIntToScalar(state.c), SkIntToScalar(state.d), SkIntToScalar(b),
31 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
32 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.c, state.d,
33 b, a, d, c);
34 pathA.close();
35 str += sprintf(str, " path.close();\n");
36 pathB.setFillType((SkPath::FillType) f);
37 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
38 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
39 ? "EvenOdd" : "?UNDEFINED");
40 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
41 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
42 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.b),
43 SkIntToScalar(state.a), SkIntToScalar(state.d), SkIntToScalar(state.c));
44 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
45 state.b, state.a, state.d, state.c);
46 pathB.close();
47 str += sprintf(str, " pathB.close();\n");
48 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
49 outputProgress(state, pathStr, (SkPathOp) op);
50 testPathOp(state.reporter, pathA, pathB, (SkPathOp) op);
51 state.testsRun++;
52 }
53 }
54 }
55 }
56 }
57 }
58 }
59 } while (runNextTestSet(state));
60 THREAD_RETURN
61}
62
63static void TestOpCubicsThreaded(skiatest::Reporter* reporter)
64{
65 int testsRun = 0;
66 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__);
67#ifdef SK_DEBUG
68 gDebugMaxWindSum = 4;
69 gDebugMaxWindValue = 4;
70#endif
71 const char testLineStr[] = "cubicOp";
72 initializeTests(reporter, testLineStr, sizeof(testLineStr));
73 for (int a = 0; a < 6; ++a) { // outermost
74 for (int b = a + 1; b < 7; ++b) {
75 for (int c = 0 ; c < 6; ++c) {
76 for (int d = c + 1; d < 7; ++d) {
77 testsRun += dispatchTest4(testOpCubicsMain, a, b, c, d);
78 }
79 if (gShowTestProgress) SkDebugf(".");
80 }
81 if (!gAllowExtendedTest) goto finish;
82 if (gShowTestProgress) SkDebugf("%d", b);
83 }
84 if (gShowTestProgress) SkDebugf("\n%d", a);
85 }
86finish:
87 testsRun += waitForCompletion();
88 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun);
89}
90
91#include "TestClassDef.h"
92DEFINE_TESTCLASS("PathOpsOpCubicsThreaded", OpCubicsThreadedTestClass, \
93 TestOpCubicsThreaded)