blob: f4eb031044bc5b0407d396bfb7f5011394d1ea20 [file] [log] [blame]
caryclark@google.comaa358312013-01-29 20:28:49 +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 "EdgeWalker_Test.h"
8#include "Intersection_Tests.h"
9#include "ShapeOps.h"
10
11// four rects, of four sizes
12// for 3 smaller sizes, tall, wide
13 // top upper mid lower bottom aligned (3 bits, 5 values)
14 // same with x (3 bits, 5 values)
15// not included, square, tall, wide (2 bits)
16// cw or ccw (1 bit)
17
18static void* testShapeOps4x4CubicsMain(void* data)
19{
20 SkASSERT(data);
21 State4& state = *(State4*) data;
22 char pathStr[1024]; // gdb: set print elements 400
23 bzero(pathStr, sizeof(pathStr));
24 do {
25 for (int a = 0 ; a < 6; ++a) {
26 for (int b = a + 1 ; b < 7; ++b) {
27 for (int c = 0 ; c < 6; ++c) {
28 for (int d = c + 1 ; d < 7; ++d) {
29 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
30 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
31 SkPath pathA, pathB;
32 char* str = pathStr;
33 pathA.setFillType((SkPath::FillType) e);
34 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
35 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
36 ? "EvenOdd" : "?UNDEFINED");
37 pathA.moveTo(state.a, state.b);
38 str += sprintf(str, " path.moveTo(%d,%d);\n", state.a, state.b);
39 pathA.cubicTo(state.c, state.d, b, a, d, c);
40 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.c, state.d,
41 b, a, d, c);
42 pathA.close();
43 str += sprintf(str, " path.close();\n");
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.moveTo(a, b);
49 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
50 pathB.cubicTo(c, d, state.b, state.a, state.d, state.c);
skia.committer@gmail.com2a772e12013-01-30 07:05:59 +000051 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
caryclark@google.comaa358312013-01-29 20:28:49 +000052 state.b, state.a, state.d, state.c);
53 pathB.close();
54 str += sprintf(str, " pathB.close();\n");
55 for (int op = 0 ; op < kShapeOp_Count; ++op) {
56 outputProgress(state, pathStr, (ShapeOp) op);
57 testShapeOp(pathA, pathB, (ShapeOp) op);
58 state.testsRun++;
59 }
60 }
61 }
62 }
63 }
64 }
65 }
66 } while (runNextTestSet(state));
67 return NULL;
68}
69
70void ShapeOps4x4CubicsThreaded_Test(int& testsRun)
71{
72 SkDebugf("%s\n", __FUNCTION__);
73#ifdef SK_DEBUG
74 gDebugMaxWindSum = 4;
75 gDebugMaxWindValue = 4;
76#endif
77 const char testLineStr[] = "cubicOp";
78 initializeTests(testLineStr, sizeof(testLineStr));
79 int testsStart = testsRun;
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 testsRun += dispatchTest4(testShapeOps4x4CubicsMain, a, b, c, d);
85 }
86 if (!gRunTestsInOneThread) SkDebugf(".");
87 }
88 if (!gRunTestsInOneThread) SkDebugf("%d", b);
89 }
90 if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
91 }
92 testsRun += waitForCompletion();
93 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
94}