caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +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 | |
| 18 | static 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) { |
| 26 | for (int b = a + 1 ; a < 7; ++b) { |
| 27 | for (int c = 0 ; c < 6; ++c) { |
| 28 | for (int d = c + 1 ; d < 7; ++d) { |
| 29 | for (int op = 0 ; op < kShapeOp_Count; ++op) { |
| 30 | for (int e = 0 ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 31 | for (int f = 0 ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 32 | SkPath pathA, pathB; |
| 33 | char* str = pathStr; |
| 34 | pathA.setFillType((SkPath::FillType) e); |
| 35 | str += sprintf(str, " path.setFillType((SkPath::FillType) %d);\n", e); |
| 36 | pathA.addRect(state.a, state.a, state.b, state.b, (SkPath::Direction) 0); |
| 37 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 38 | " (SkPath::Direction) %d);\n", state.a, state.a, state.b, state.b, 0); |
| 39 | pathA.addRect(state.c, state.c, state.d, state.d, (SkPath::Direction) 0); |
| 40 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 41 | " (SkPath::Direction) %d);\n", state.c, state.c, state.d, state.d, 0); |
| 42 | pathA.close(); |
| 43 | pathB.setFillType((SkPath::FillType) f); |
| 44 | str += sprintf(str, " pathB.setFillType((SkPath::FillType) %d);\n", f); |
| 45 | pathB.addRect(a, a, b, b, (SkPath::Direction) 0); |
| 46 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 47 | " (SkPath::Direction) %d);\n", a, a, b, b, 0); |
| 48 | pathB.addRect(c, c, d, d, (SkPath::Direction) 0); |
| 49 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 50 | " (SkPath::Direction) %d);\n", c, c, d, d, 0); |
| 51 | pathB.close(); |
| 52 | outputProgress(state, pathStr, kDifference_Op); |
| 53 | testShapeOp(pathA, pathB, kDifference_Op); |
| 54 | state.testsRun++; |
| 55 | outputProgress(state, pathStr, kIntersect_Op); |
| 56 | testShapeOp(pathA, pathB, kIntersect_Op); |
| 57 | state.testsRun++; |
| 58 | outputProgress(state, pathStr, kUnion_Op); |
| 59 | testShapeOp(pathA, pathB, kUnion_Op); |
| 60 | state.testsRun++; |
| 61 | outputProgress(state, pathStr, kXor_Op); |
| 62 | testShapeOp(pathA, pathB, kXor_Op); |
| 63 | state.testsRun++; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } while (runNextTestSet(state)); |
| 72 | return NULL; |
| 73 | } |
| 74 | |
| 75 | void ShapeOps4x4RectsThreaded_Test(int& testsRun) |
| 76 | { |
| 77 | SkDebugf("%s\n", __FUNCTION__); |
| 78 | #ifdef SK_DEBUG |
| 79 | gDebugMaxWindSum = 4; |
| 80 | gDebugMaxWindValue = 4; |
| 81 | #endif |
| 82 | const char testLineStr[] = "testOp"; |
| 83 | initializeTests(testLineStr, sizeof(testLineStr)); |
| 84 | int testsStart = testsRun; |
| 85 | for (int a = 0; a < 6; ++a) { // outermost |
| 86 | for (int b = a + 1; b < 7; ++b) { |
| 87 | for (int c = 0 ; c < 6; ++c) { |
| 88 | for (int d = c + 1; d < 7; ++d) { |
| 89 | testsRun += dispatchTest4(testShapeOps4x4RectsMain, a, b, c, d); |
| 90 | } |
| 91 | if (!gRunTestsInOneThread) SkDebugf("."); |
| 92 | } |
| 93 | if (!gRunTestsInOneThread) SkDebugf("%d", b); |
| 94 | } |
| 95 | if (!gRunTestsInOneThread) SkDebugf("\n%d", a); |
| 96 | } |
| 97 | testsRun += waitForCompletion(); |
| 98 | SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); |
| 99 | } |