• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include "PathOpsThreadedCommon.h"
9 #include "SkString.h"
10 
11 static int loopNo = 158;
12 
testOpCubicsMain(PathOpsThreadState * data)13 static void testOpCubicsMain(PathOpsThreadState* data) {
14 #if DEBUG_SHOW_TEST_NAME
15     strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
16 #endif
17     SkASSERT(data);
18     PathOpsThreadState& state = *data;
19     SkString pathStr;
20     for (int a = 0 ; a < 6; ++a) {
21         for (int b = a + 1 ; b < 7; ++b) {
22             for (int c = 0 ; c < 6; ++c) {
23                 for (int d = c + 1 ; d < 7; ++d) {
24                     for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
25     for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
26         SkPath pathA, pathB;
27         pathA.setFillType((SkPath::FillType) e);
28         pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
29         pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
30                 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
31         pathA.close();
32         pathB.setFillType((SkPath::FillType) f);
33         pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
34         pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
35                 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
36         pathB.close();
37         for (int op = 0 ; op <= kXOR_SkPathOp; ++op)    {
38             if (state.fReporter->verbose()) {
39                 pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter,"
40                         " const char* filename) {\n", loopNo);
41                 pathStr.appendf("    SkPath path, pathB;\n");
42                 pathStr.appendf("    path.setFillType(SkPath::k%s_FillType);\n",
43                         e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
44                         ? "EvenOdd" : "?UNDEFINED");
45                 pathStr.appendf("    path.moveTo(%d,%d);\n", state.fA, state.fB);
46                 pathStr.appendf("    path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
47                         b, a, d, c);
48                 pathStr.appendf("    path.close();\n");
49                 pathStr.appendf("    pathB.setFillType(SkPath::k%s_FillType);\n",
50                         f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
51                         ? "EvenOdd" : "?UNDEFINED");
52                 pathStr.appendf("    pathB.moveTo(%d,%d);\n", a, b);
53                 pathStr.appendf("    pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
54                         state.fB, state.fA, state.fD, state.fC);
55                 pathStr.appendf("    pathB.close();\n");
56                 pathStr.appendf("    testPathOp(reporter, path, pathB, %s, filename);\n",
57                         SkPathOpsDebug::OpStr((SkPathOp) op));
58                 pathStr.appendf("}\n");
59                 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
60             }
61             if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
62                 if (state.fReporter->verbose()) {
63                     ++loopNo;
64                     goto skipToNext;
65                 }
66             }
67         }
68     }
69                     }
70 skipToNext: ;
71                 }
72             }
73         }
74     }
75 }
76 
DEF_TEST(PathOpsOpCubicsThreaded,reporter)77 DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
78     initializeTests(reporter, "cubicOp");
79     PathOpsThreadedTestRunner testRunner(reporter);
80     for (int a = 0; a < 6; ++a) {  // outermost
81         for (int b = a + 1; b < 7; ++b) {
82             for (int c = 0 ; c < 6; ++c) {
83                 for (int d = c + 1; d < 7; ++d) {
84                     *testRunner.fRunnables.append() =
85                             new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner);
86                 }
87             }
88             if (!reporter->allowExtendedTest()) goto finish;
89         }
90     }
91 finish:
92     testRunner.render();
93 }
94