blob: 58e470702087d56774642009dfccbd20826035df [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
10// four rects, of four sizes
11// for 3 smaller sizes, tall, wide
12 // top upper mid lower bottom aligned (3 bits, 5 values)
13 // same with x (3 bits, 5 values)
14// not included, square, tall, wide (2 bits)
15// cw or ccw (1 bit)
16
caryclark@google.com66089e42013-04-10 15:55:37 +000017static void testPathOpsRectsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000018{
19 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000020 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000021 char pathStr[1024]; // gdb: set print elements 400
22 sk_bzero(pathStr, sizeof(pathStr));
caryclark@google.com66089e42013-04-10 15:55:37 +000023 for (int a = 0 ; a < 6; ++a) {
24 for (int b = a + 1 ; b < 7; ++b) {
25 for (int c = 0 ; c < 6; ++c) {
26 for (int d = c + 1 ; d < 7; ++d) {
27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
29 SkPath pathA, pathB;
30 char* str = pathStr;
31 pathA.setFillType((SkPath::FillType) e);
32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
34 ? "EvenOdd" : "?UNDEFINED");
35 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
36 SkIntToScalar(state.fB), SkPath::kCW_Direction);
37 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
38 " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
39 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD),
40 SkIntToScalar(state.fD), SkPath::kCW_Direction);
41 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
42 " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
43 pathA.close();
44 pathB.setFillType((SkPath::FillType) f);
45 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
47 ? "EvenOdd" : "?UNDEFINED");
48 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b),
49 SkIntToScalar(b), SkPath::kCW_Direction);
50 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
51 " SkPath::kCW_Direction);\n", a, a, b, b);
52 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d),
53 SkIntToScalar(d), SkPath::kCW_Direction);
54 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
55 " SkPath::kCW_Direction);\n", c, c, d, d);
56 pathB.close();
57 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
58 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
59 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op);
60 }
61 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000062 }
63 }
64 }
caryclark@google.com66089e42013-04-10 15:55:37 +000065 }
66 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000067}
68
caryclark@google.comad65a3e2013-04-15 19:13:59 +000069static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) {
caryclark@google.com16cfe402013-04-18 18:47:37 +000070 int threadCount = initializeTests(reporter, "testOp");
caryclark@google.com66089e42013-04-10 15:55:37 +000071 PathOpsThreadedTestRunner testRunner(reporter, threadCount);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000072 for (int a = 0; a < 6; ++a) { // outermost
73 for (int b = a + 1; b < 7; ++b) {
74 for (int c = 0 ; c < 6; ++c) {
75 for (int d = c + 1; d < 7; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000076 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
77 (&testPathOpsRectsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000078 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000079 }
caryclark@google.com66089e42013-04-10 15:55:37 +000080 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000081 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000082 }
83finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000084 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000085}
86
87#include "TestClassDef.h"
caryclark@google.comad65a3e2013-04-15 19:13:59 +000088DEFINE_TESTCLASS_SHORT(PathOpsRectsThreadedTest)