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) { |
caryclark@google.com | e7bd5f4 | 2012-12-13 19:47:53 +0000 | [diff] [blame] | 26 | for (int b = a + 1 ; b < 7; ++b) { |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 27 | for (int c = 0 ; c < 6; ++c) { |
| 28 | for (int d = c + 1 ; d < 7; ++d) { |
caryclark@google.com | 4eeda37 | 2012-12-06 21:47:48 +0000 | [diff] [blame] | 29 | 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.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 31 | SkPath pathA, pathB; |
| 32 | char* str = pathStr; |
| 33 | pathA.setFillType((SkPath::FillType) e); |
caryclark@google.com | 4eeda37 | 2012-12-06 21:47:48 +0000 | [diff] [blame] | 34 | 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.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 37 | pathA.addRect(state.a, state.a, state.b, state.b, SkPath::kCW_Direction); |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 38 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
caryclark@google.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 39 | " 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.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 41 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
caryclark@google.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 42 | " SkPath::kCW_Direction);\n", state.c, state.c, state.d, state.d); |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 43 | pathA.close(); |
| 44 | pathB.setFillType((SkPath::FillType) f); |
caryclark@google.com | 4eeda37 | 2012-12-06 21:47:48 +0000 | [diff] [blame] | 45 | 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.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 48 | pathB.addRect(a, a, b, b, SkPath::kCW_Direction); |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 49 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
caryclark@google.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 50 | " SkPath::kCW_Direction);\n", a, a, b, b); |
| 51 | pathB.addRect(c, c, d, d, SkPath::kCW_Direction); |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 52 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
caryclark@google.com | 7fce0de | 2012-11-29 14:31:50 +0000 | [diff] [blame] | 53 | " SkPath::kCW_Direction);\n", c, c, d, d); |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 54 | pathB.close(); |
caryclark@google.com | aa35831 | 2013-01-29 20:28:49 +0000 | [diff] [blame] | 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 | } |
caryclark@google.com | b1c42bb | 2012-11-16 13:16:41 +0000 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } while (runNextTestSet(state)); |
| 67 | return NULL; |
| 68 | } |
| 69 | |
| 70 | void 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 | } |