blob: e6e44c14412bc10e073e110a8bb9d3571cead04c [file] [log] [blame]
caryclark@google.comb1c42bb2012-11-16 13:16:41 +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* testShapeOps4x4RectsMain(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) {
caryclark@google.come7bd5f42012-12-13 19:47:53 +000026 for (int b = a + 1 ; b < 7; ++b) {
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000027 for (int c = 0 ; c < 6; ++c) {
28 for (int d = c + 1 ; d < 7; ++d) {
caryclark@google.com4eeda372012-12-06 21:47:48 +000029 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
30 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000031 SkPath pathA, pathB;
32 char* str = pathStr;
33 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com4eeda372012-12-06 21:47:48 +000034 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
35 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
36 ? "EvenOdd" : "?UNDEFINED");
caryclark@google.com7fce0de2012-11-29 14:31:50 +000037 pathA.addRect(state.a, state.a, state.b, state.b, SkPath::kCW_Direction);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000038 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
caryclark@google.com7fce0de2012-11-29 14:31:50 +000039 " SkPath::kCW_Direction);\n", state.a, state.a, state.b, state.b);
40 pathA.addRect(state.c, state.c, state.d, state.d, SkPath::kCW_Direction);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000041 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
caryclark@google.com7fce0de2012-11-29 14:31:50 +000042 " SkPath::kCW_Direction);\n", state.c, state.c, state.d, state.d);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000043 pathA.close();
44 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com4eeda372012-12-06 21:47:48 +000045 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
47 ? "EvenOdd" : "?UNDEFINED");
caryclark@google.com7fce0de2012-11-29 14:31:50 +000048 pathB.addRect(a, a, b, b, SkPath::kCW_Direction);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000049 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
caryclark@google.com7fce0de2012-11-29 14:31:50 +000050 " SkPath::kCW_Direction);\n", a, a, b, b);
51 pathB.addRect(c, c, d, d, SkPath::kCW_Direction);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000052 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
caryclark@google.com7fce0de2012-11-29 14:31:50 +000053 " SkPath::kCW_Direction);\n", c, c, d, d);
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000054 pathB.close();
caryclark@google.comaa358312013-01-29 20:28:49 +000055 for (int op = 0 ; op < kShapeOp_Count; ++op) {
56 outputProgress(state, pathStr, (ShapeOp) op);
57 testShapeOp(pathA, pathB, (ShapeOp) op);
58 state.testsRun++;
59 }
caryclark@google.comb1c42bb2012-11-16 13:16:41 +000060 }
61 }
62 }
63 }
64 }
65 }
66 } while (runNextTestSet(state));
67 return NULL;
68}
69
70void ShapeOps4x4RectsThreaded_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[] = "testOp";
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(testShapeOps4x4RectsMain, 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}