blob: 99e68daae618a9aeae82d47ce64fb0d89e77cb2b [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"
caryclark@google.com66089e42013-04-10 15:55:37 +00008#include "PathOpsThreadedCommon.h"
caryclark@google.com818b0cc2013-04-08 11:50:46 +00009
caryclark@google.com66089e42013-04-10 15:55:37 +000010static void testOpCubicsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000011{
caryclark@google.comfa2aeee2013-07-15 13:29:13 +000012#if DEBUG_SHOW_TEST_NAME
13 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
14#endif
caryclark@google.com818b0cc2013-04-08 11:50:46 +000015 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000016 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000017 char pathStr[1024]; // gdb: set print elements 400
caryclark@google.com8d0a5242013-07-16 16:11:16 +000018 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
19 if (progress) {
20 sk_bzero(pathStr, sizeof(pathStr));
21 }
caryclark@google.com66089e42013-04-10 15:55:37 +000022 for (int a = 0 ; a < 6; ++a) {
23 for (int b = a + 1 ; b < 7; ++b) {
24 for (int c = 0 ; c < 6; ++c) {
25 for (int d = c + 1 ; d < 7; ++d) {
26 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
27 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
28 SkPath pathA, pathB;
caryclark@google.com8d0a5242013-07-16 16:11:16 +000029 if (progress) {
30 char* str = pathStr;
31 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
32 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
33 ? "EvenOdd" : "?UNDEFINED");
34 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB);
35 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
36 b, a, d, c);
37 str += sprintf(str, " path.close();\n");
38 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
39 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
40 ? "EvenOdd" : "?UNDEFINED");
41 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
42 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
43 state.fB, state.fA, state.fD, state.fC);
44 str += sprintf(str, " pathB.close();\n");
45 }
caryclark@google.com66089e42013-04-10 15:55:37 +000046 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com66089e42013-04-10 15:55:37 +000047 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
caryclark@google.com66089e42013-04-10 15:55:37 +000048 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
49 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
caryclark@google.com66089e42013-04-10 15:55:37 +000050 pathA.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000051 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com66089e42013-04-10 15:55:37 +000052 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
caryclark@google.com66089e42013-04-10 15:55:37 +000053 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
54 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
caryclark@google.com66089e42013-04-10 15:55:37 +000055 pathB.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000056 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
caryclark@google.com8d0a5242013-07-16 16:11:16 +000057 if (progress) {
58 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
59 }
60 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op);
caryclark@google.com66089e42013-04-10 15:55:37 +000061 }
62 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000063 }
64 }
65 }
caryclark@google.com66089e42013-04-10 15:55:37 +000066 }
67 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000068}
69
caryclark@google.comad65a3e2013-04-15 19:13:59 +000070static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000071{
caryclark@google.com16cfe402013-04-18 18:47:37 +000072 int threadCount = initializeTests(reporter, "cubicOp");
caryclark@google.com66089e42013-04-10 15:55:37 +000073 PathOpsThreadedTestRunner testRunner(reporter, threadCount);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000074 for (int a = 0; a < 6; ++a) { // outermost
75 for (int b = a + 1; b < 7; ++b) {
76 for (int c = 0 ; c < 6; ++c) {
77 for (int d = c + 1; d < 7; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000078 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
79 (&testOpCubicsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000080 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000081 }
caryclark@google.com66089e42013-04-10 15:55:37 +000082 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000083 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000084 }
85finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000086 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000087}
88
89#include "TestClassDef.h"
caryclark@google.comad65a3e2013-04-15 19:13:59 +000090DEFINE_TESTCLASS_SHORT(PathOpsOpCubicsThreadedTest)