caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 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 "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 | |
caryclark@google.com | 1304bb2 | 2013-03-13 20:29:41 +0000 | [diff] [blame] | 18 | int failSet[][8] = { |
| 19 | { 0, 1, 0, 6, 2, 3, 1, 4 } |
| 20 | }; |
| 21 | |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 22 | static void* testShapeOps4x4CubicsMain(void* data) |
| 23 | { |
| 24 | SkASSERT(data); |
| 25 | State4& state = *(State4*) data; |
| 26 | char pathStr[1024]; // gdb: set print elements 400 |
| 27 | bzero(pathStr, sizeof(pathStr)); |
| 28 | do { |
| 29 | for (int a = 0 ; a < 6; ++a) { |
| 30 | for (int b = a + 1 ; b < 7; ++b) { |
| 31 | for (int c = 0 ; c < 6; ++c) { |
| 32 | for (int d = c + 1 ; d < 7; ++d) { |
| 33 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 34 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
skia.committer@gmail.com | 03682be | 2013-03-14 07:02:51 +0000 | [diff] [blame] | 35 | |
caryclark@google.com | 1304bb2 | 2013-03-13 20:29:41 +0000 | [diff] [blame] | 36 | #if 0 |
| 37 | if (state.a == fail[0] && state.b == fail[1] && state.c == fail[2] && state.d == fail[3] |
| 38 | && a == fail[4] && b == fail[5] && c == fail[6] && d == fail[7]) { |
| 39 | SkDebugf("skip failing case\n"); |
| 40 | } |
| 41 | // skip this troublesome cubic pair |
| 42 | #endif |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 43 | SkPath pathA, pathB; |
| 44 | char* str = pathStr; |
| 45 | pathA.setFillType((SkPath::FillType) e); |
| 46 | str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
| 47 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 48 | ? "EvenOdd" : "?UNDEFINED"); |
| 49 | pathA.moveTo(state.a, state.b); |
| 50 | str += sprintf(str, " path.moveTo(%d,%d);\n", state.a, state.b); |
| 51 | pathA.cubicTo(state.c, state.d, b, a, d, c); |
| 52 | str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.c, state.d, |
| 53 | b, a, d, c); |
| 54 | pathA.close(); |
| 55 | str += sprintf(str, " path.close();\n"); |
| 56 | pathB.setFillType((SkPath::FillType) f); |
| 57 | str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", |
| 58 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 59 | ? "EvenOdd" : "?UNDEFINED"); |
| 60 | pathB.moveTo(a, b); |
| 61 | str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b); |
| 62 | pathB.cubicTo(c, d, state.b, state.a, state.d, state.c); |
skia.committer@gmail.com | 2a772e1 | 2013-01-30 07:05:59 +0000 | [diff] [blame] | 63 | str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d, |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 64 | state.b, state.a, state.d, state.c); |
| 65 | pathB.close(); |
| 66 | str += sprintf(str, " pathB.close();\n"); |
| 67 | for (int op = 0 ; op < kShapeOp_Count; ++op) { |
| 68 | outputProgress(state, pathStr, (ShapeOp) op); |
| 69 | testShapeOp(pathA, pathB, (ShapeOp) op); |
| 70 | state.testsRun++; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } while (runNextTestSet(state)); |
| 79 | return NULL; |
| 80 | } |
| 81 | |
| 82 | void ShapeOps4x4CubicsThreaded_Test(int& testsRun) |
| 83 | { |
| 84 | SkDebugf("%s\n", __FUNCTION__); |
| 85 | #ifdef SK_DEBUG |
| 86 | gDebugMaxWindSum = 4; |
| 87 | gDebugMaxWindValue = 4; |
| 88 | #endif |
| 89 | const char testLineStr[] = "cubicOp"; |
| 90 | initializeTests(testLineStr, sizeof(testLineStr)); |
| 91 | int testsStart = testsRun; |
| 92 | for (int a = 0; a < 6; ++a) { // outermost |
| 93 | for (int b = a + 1; b < 7; ++b) { |
| 94 | for (int c = 0 ; c < 6; ++c) { |
| 95 | for (int d = c + 1; d < 7; ++d) { |
| 96 | testsRun += dispatchTest4(testShapeOps4x4CubicsMain, a, b, c, d); |
| 97 | } |
| 98 | if (!gRunTestsInOneThread) SkDebugf("."); |
| 99 | } |
| 100 | if (!gRunTestsInOneThread) SkDebugf("%d", b); |
| 101 | } |
| 102 | if (!gRunTestsInOneThread) SkDebugf("\n%d", a); |
| 103 | } |
| 104 | testsRun += waitForCompletion(); |
| 105 | SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); |
| 106 | } |